Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions src/StackHCI/StackHCI.Autorest/custom/stackhci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4723,7 +4723,6 @@ param(
$nodeSessionParams = @{}
$subscriptionId = [string]::Empty
$armResourceId = [string]::Empty
$armResource = $null

$successMessage = New-Object -TypeName System.Text.StringBuilder

Expand Down Expand Up @@ -4845,50 +4844,36 @@ param(
$TenantId = Azure-Login @azureLoginParameters
}

$armResource = Get-AzResource -ResourceId $armResourceId -ExpandProperties -ApiVersion $RPAPIVersion -ErrorAction Stop

$properties = [PSCustomObject]@{
desiredProperties = $armResource.Properties.desiredProperties
aadClientId = $armResource.Properties.aadClientId
aadTenantId = $armResource.Properties.aadTenantId
aadServicePrincipalObjectId = $armResource.Properties.aadServicePrincipalObjectId
aadApplicationObjectId = $armResource.Properties.aadApplicationObjectId
}

if ($properties.desiredProperties -eq $null)
{
#
# Create desiredProperties object with default values
#
$desiredProperties = New-Object -TypeName PSObject
$desiredProperties | Add-Member -MemberType NoteProperty -Name 'windowsServerSubscription' -Value 'Disabled'
$desiredProperties | Add-Member -MemberType NoteProperty -Name 'diagnosticLevel' -Value 'Basic'

$properties | Add-Member -MemberType NoteProperty -Name 'desiredProperties' -Value $desiredProperties
desiredProperties = New-Object -TypeName PSObject
}

if ($PSBoundParameters.ContainsKey('EnableWSSubscription'))
{
$windowsServerSubscriptionValue = $Null

if ($EnableWSSubscription -eq $true)
{
$properties.desiredProperties.windowsServerSubscription = 'Enabled';
$windowsServerSubscriptionValue = 'Enabled';

$successMessage.Append($SetAzResourceSuccessWSSE) | Out-Null;
}
else
{
$properties.desiredProperties.windowsServerSubscription = 'Disabled';
$windowsServerSubscriptionValue = 'Disabled';

$successMessage.Append($SetAzResourceSuccessWSSD) | Out-Null;
}

$properties.desiredProperties | Add-Member -MemberType NoteProperty -Name 'windowsServerSubscription' -Value $windowsServerSubscriptionValue

$doSetResource = $true
$needShouldContinue = $true
}

if ($PSBoundParameters.ContainsKey('DiagnosticLevel'))
{
$properties.desiredProperties.diagnosticLevel = $DiagnosticLevel.ToString()
$properties.desiredProperties | Add-Member -MemberType NoteProperty -Name 'diagnosticLevel' -Value $($DiagnosticLevel.ToString())

if ($successMessage.Length -gt 0)
{
Expand Down Expand Up @@ -4917,12 +4902,12 @@ param(
Write-Progress -Id $MainProgressBarId -Activity $SetProgressActivityName -Status $SetProgressStatusUpdatingProps -PercentComplete 60

$setAzResourceParameters = @{
'ResourceId' = $armResource.Id;
'ResourceId' = $armResourceId;
'Properties' = $properties;
'ApiVersion' = $RPAPIVersion
}

$localResult = Set-AzResource @setAzResourceParameters -Confirm:$false -Force -ErrorAction Stop
$localResult = Set-AzResource @setAzResourceParameters -UsePatchSemantics -Confirm:$false -Force -ErrorAction Stop

if ($PSBoundParameters.ContainsKey('EnableWSSubscription') -and ($EnableWSSubscription -eq $false))
{
Expand Down