13
13
# -ResourceGroup [resource_goup] (Limit scope to a specific resoure group)
14
14
# -MachineName [machine_name] (Limit scope to a specific machine)
15
15
# -LicenseType [license_type_value] (Specific LT value)
16
- # -All (Required. Set the new license type on all installed extensions.
16
+ # -Force (Required. Set the new license type on all installed extensions.
17
17
# By default the value is set only if license type is undefined undefined)
18
18
#
19
19
# The script uses a function ConvertTo-HashTable that was created by Adam Bertram (@adam-bertram).
@@ -32,7 +32,7 @@ param (
32
32
[ValidateSet (" PAYG" , " Paid" , " LicenseOnly" , IgnoreCase= $false )]
33
33
[string ] $LicenseType ,
34
34
[Parameter (Mandatory = $false )]
35
- [boolean ] $All = $false
35
+ [boolean ] $Force = $false
36
36
)
37
37
38
38
function CheckModule ($m ) {
@@ -117,12 +117,14 @@ $requiredModules | Foreach-Object {CheckModule $_}
117
117
118
118
# Subscriptions to scan
119
119
120
+ $tenantID = (Get-AzureADTenantDetail ).ObjectId
121
+
120
122
if ($SubId -like " *.csv" ) {
121
123
$subscriptions = Import-Csv $SubId
122
124
}elseif ($SubId -ne " " ){
123
- $subscriptions = [PSCustomObject ]@ {SubscriptionId = $SubId } | Get-AzSubscription
125
+ $subscriptions = [PSCustomObject ]@ {SubscriptionId = $SubId } | Get-AzSubscription - TenantID $tenantID
124
126
}else {
125
- $subscriptions = Get-AzSubscription
127
+ $subscriptions = Get-AzSubscription - TenantID $tenantID
126
128
}
127
129
128
130
@@ -135,7 +137,7 @@ foreach ($sub in $subscriptions){
135
137
if ($sub.State -ne " Enabled" ) {continue }
136
138
137
139
try {
138
- Set-AzContext - SubscriptionId $sub.Id
140
+ Set-AzContext - SubscriptionId $sub.Id - Tenant $tenantID
139
141
}catch {
140
142
write-host " Invalid subscription: $ ( $sub.Id ) "
141
143
{continue }
@@ -180,7 +182,7 @@ foreach ($sub in $subscriptions){
180
182
$settings = $r.properties.settings | ConvertTo-Json | ConvertFrom-Json | ConvertTo-Hashtable
181
183
182
184
if ($settings.ContainsKey (" LicenseType" )) {
183
- if ($All ) {
185
+ if ($Force ) {
184
186
if ($settings [" LicenseType" ] -ne $LicenseType ) {
185
187
$settings [" LicenseType" ] = $LicenseType
186
188
Write-Host " Resource group: [$ ( $r.resourceGroup ) ] Connected machine: [$ ( $r.MachineName ) ] : License type: [$ ( $settings [" LicenseType" ]) ]"
0 commit comments