Skip to content

Commit d636f81

Browse files
author
Jeffrey Robinson
committed
Added should process to New-AzsSubscription
1 parent 39cc0ce commit d636f81

File tree

1 file changed

+34
-32
lines changed
  • src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Generated.PowerShell.Commands/SwaggerPathCommands

1 file changed

+34
-32
lines changed

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsSubscription.ps1

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -104,44 +104,46 @@ function New-AzsSubscription {
104104
$PSBoundParameters.Add("SubscriptionId", $SubscriptionId)
105105
}
106106

107-
# Validate this resource does not exist.
108-
$_objectCheck = $null
109-
try {
110-
$_objectCheck = Get-AzsSubscription -SubscriptionId $SubscriptionId
111-
} catch {
112-
# No op
113-
} finally {
114-
if ($_objectCheck -ne $null) {
115-
throw "A subscription with identifier $SubscriptionId already exists."
107+
if ($PSCmdlet.ShouldProcess("$SubscriptionId", "Create new subscription")) {
108+
109+
# Validate this resource does not exist.
110+
$_objectCheck = $null
111+
try {
112+
$_objectCheck = Get-AzsSubscription -SubscriptionId $SubscriptionId
113+
} catch {
114+
# No op
115+
} finally {
116+
if ($_objectCheck -ne $null) {
117+
throw "A subscription with identifier $SubscriptionId already exists."
118+
}
116119
}
117-
}
118120

119-
$NewServiceClient_params = @{
120-
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.SubscriptionsManagementClient'
121-
}
122-
$GlobalParameterHashtable = @{}
123-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
124-
$SubscriptionsManagementClient = New-ServiceClient @NewServiceClient_params
125-
126-
$flattenedParameters = @('OfferId', 'Id', 'SubscriptionId', 'State', 'TenantId', 'DisplayName')
127-
$utilityCmdParams = @{}
128-
$flattenedParameters | ForEach-Object {
129-
if ($PSBoundParameters.ContainsKey($_)) {
130-
$utilityCmdParams[$_] = $PSBoundParameters[$_]
121+
$NewServiceClient_params = @{
122+
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.SubscriptionsManagementClient'
131123
}
132-
}
133-
$NewSubscription = New-SubscriptionObject @utilityCmdParams
134-
135-
Write-Verbose -Message 'Performing operation create on $SubscriptionsManagementClient.'
136-
$TaskResult = $SubscriptionsManagementClient.Subscriptions.CreateOrUpdateWithHttpMessagesAsync($SubscriptionId, $NewSubscription)
137-
138-
if ($TaskResult) {
139-
$GetTaskResult_params = @{
140-
TaskResult = $TaskResult
124+
$GlobalParameterHashtable = @{}
125+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
126+
$SubscriptionsManagementClient = New-ServiceClient @NewServiceClient_params
127+
128+
$flattenedParameters = @('OfferId', 'Id', 'SubscriptionId', 'State', 'TenantId', 'DisplayName')
129+
$utilityCmdParams = @{}
130+
$flattenedParameters | ForEach-Object {
131+
if ($PSBoundParameters.ContainsKey($_)) {
132+
$utilityCmdParams[$_] = $PSBoundParameters[$_]
133+
}
141134
}
135+
$NewSubscription = New-SubscriptionObject @utilityCmdParams
136+
137+
Write-Verbose -Message 'Performing operation create on $SubscriptionsManagementClient.'
138+
$TaskResult = $SubscriptionsManagementClient.Subscriptions.CreateOrUpdateWithHttpMessagesAsync($SubscriptionId, $NewSubscription)
142139

143-
Get-TaskResult @GetTaskResult_params
140+
if ($TaskResult) {
141+
$GetTaskResult_params = @{
142+
TaskResult = $TaskResult
143+
}
144144

145+
Get-TaskResult @GetTaskResult_params
146+
}
145147
}
146148
}
147149

0 commit comments

Comments
 (0)