3939 Optional. If specified, excludes the resources that have this tag assigned.
4040
4141. PARAMETER TenantId
42- Optional . If specified, this tenant id to log in both PowerShell and CLI. Otherwise, the current login context is used.
42+ Required . If specified, this tenant id to log in both PowerShell and CLI. Otherwise, the current login context is used.
4343
4444. PARAMETER ReportOnly
4545 Optional. If true, generates a csv file with the list of resources that are to be modified, but doesn't make the actual change.
@@ -81,7 +81,7 @@ param (
8181 [Parameter (Mandatory = $false )]
8282 [object ] $ExclusionTags ,
8383
84- [Parameter (Mandatory = $false )]
84+ [Parameter (Mandatory = $true )]
8585 [string ] $TenantId ,
8686
8787 [Parameter (Mandatory = $false )]
@@ -123,6 +123,7 @@ function Connect-Azure {
123123 }
124124 Write-Output " Connected to Azure PowerShell as: $ ( $ctx.Account ) "
125125
126+
126127}
127128
128129
@@ -152,21 +153,7 @@ if ($UseManagedIdentity) {
152153}
153154
154155# Ensure the required modules are imported
155- try {
156- # Check if Microsoft.Graph module is installed
157- if (-not (Get-Module - ListAvailable - Name Microsoft.Graph)) {
158- Write-Host " Microsoft.Graph module not found. Installing..."
159- Install-Module - Name Microsoft.Graph - Scope CurrentUser - Force
160- }else {
161- Write-Host " Microsoft.Graph module is already installed."
162- }
163156
164- # Import the module
165- Import-Module Microsoft.Graph
166- }
167- catch {
168- Write-Output " Can't import module Microsoft.Graph"
169- }
170157try {
171158 Import-Module Az.Accounts
172159}catch {
@@ -190,7 +177,6 @@ $modifiedResources = @()
190177if ($SubId -like " *.csv" ) {
191178 $subscriptions = Import-Csv $SubId
192179}elseif ($SubId -ne " " ) {
193- Write-Output " Passed Subscription $ ( $SubId ) "
194180 $subscriptions = Get-AzSubscription - SubscriptionId $SubId
195181}else {
196182 $subscriptions = Get-AzSubscription | Where-Object { $_.TenantId -eq $tenantId }
@@ -264,7 +250,7 @@ foreach ($sub in $subscriptions) {
264250 | project machineName, extensionName, resourceGroup, location, subscriptionId, extensionPublisher, extensionType
265251 "
266252
267- Write-Output $query
253+ # Write-Output $query
268254
269255 $resources = Search-AzGraph - Query " $ ( $query ) "
270256 Write-Output " Found $ ( $resources.Count ) resource(s) to update"
0 commit comments