File tree Expand file tree Collapse file tree
samples/manage/azure-arc-enabled-sql-server
uninstall-azure-extension-for-sql-server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ Update-AzConfig -DisplayBreakingChangeWarning $false
108108
109109# Load required modules
110110$requiredModules = @ (
111+ " AzureAD" ,
111112 " Az.Accounts" ,
112113 " Az.ConnectedMachine" ,
113114 " Az.ResourceGraph"
Original file line number Diff line number Diff line change @@ -84,10 +84,10 @@ This option is recommended because Cloud shell has the Azure PowerShell modules
8484 curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/uninstall-azure-extension-for-sql-server/uninstall-azure-extension-for-sql-server.ps1 -o uninstall-azure-extension-for-sql-server.ps1
8585 ```
8686
87- 1. Run the script.
87+ 1. Run the script using the desired scope. For example:
8888
8989 ```console
90- .\uninstall-azure-extension-for-sql-server.ps1 -SubId ALL
90+ .\uninstall-azure-extension-for-sql-server.ps1 -SubId <sub_id>
9191 ```
9292
9393> [! NOTE]
@@ -124,8 +124,8 @@ Use the following steps to run the script in a PowerShell session on your PC.
124124 Connect-AzAccount -TenantID (Get-AzureADTenantDetail).ObjectId
125125 ```
126126
127- 1. Run the script using the desired scope.
127+ 1. Run the script using the desired scope. For example:
128128
129129 ```console
130- .\uninstall-azure-extension-for-sql-server.ps1 -All $True
130+ .\uninstall-azure-extension-for-sql-server.ps1 -SubId <sub_id> -ResourceGroup <resource_group>
131131 ```
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ foreach ($sub in $subscriptions){
8888 try {
8989 Set-AzContext - SubscriptionId $sub.Id
9090 }catch {
91- write-host " [Environment]::NewLine + Invalid subscription: $ ( $sub.Id ) "
91+ write-host ( [Environment ]::NewLine + " Invalid subscription: $ ( $sub.Id ) " )
9292 {continue }
9393 }
9494
@@ -142,8 +142,9 @@ foreach ($sub in $subscriptions){
142142 $resources = Search-AzGraph - Query " $ ( $query2 ) "
143143
144144 foreach ($r in $resources ) {
145-
146- Remove-AzResource - ResourceId $r.resourceId - Force | Out-Null
145+
146+ $job = Remove-AzResource - ResourceId $r.resourceId - Force - AsJob | Out-Null
147+ write-host ([Environment ]::NewLine + " Removing resource: $ ( $r.resourceId ) " )
147148
148149 }
149150
You can’t perform that action at this time.
0 commit comments