在很多情況下,當我們使用完Azure資源組之后總是忘記刪除它們,所以我創建了下面的PowerShell腳本來幫助清理它們。它適用于所有的賬戶訂閱。如果您的賬戶中有很多人在管理不同的Azure Resource但其并而不是自己清理空的資源組,那么這個腳本就很有用
創新互聯專注于博州網站建設服務及定制,我們擁有豐富的企業做網站經驗。 熱誠為您提供博州營銷型網站建設,博州網站制作、博州網頁設計、博州網站官網定制、重慶小程序開發服務,打造博州網絡公司原創品牌,更為您提供博州網站排名全網營銷落地服務。
#Log in to Azure account Login-AzureRmAccount #Global Login-AzureRmAccount -Environment AzureChinaCloud #21V #Get list of Azure Subscription ID's $Subs = (get-AzureRMSubscription).ID #Loop through the subscriptions to find all empty Resource Groups and store them in $EmptyRGs ForEach ($sub in $Subs) { Select-AzureRmSubscription -SubscriptionId $Sub $AllRGs = (Get-AzureRmResourceGroup).ResourceGroupName $UsedRGs = (Get-AzureRMResource | Group-Object ResourceGroupName).Name $EmptyRGs = $AllRGs | Where-Object {$_ -notin $UsedRGs} #Loop through the empty Resorce Groups asking if you would like to delete them. And then deletes them. foreach ($EmptyRG in $EmptyRGs){ $Confirmation = Read-Host "Would you like to delete $EmptyRG '(Y)es' or '(N)o'" IF ($Confirmation -eq "y" -or $Confirmation -eq "Yes"){ Write-Host "Deleting" $EmptyRG "Resource Group" Remove-AzureRmResourceGroup -Name $EmptyRG -Force } } }
網站名稱:使用PowerShell查找和刪除所有Azure訂閱中的空資源組
當前鏈接:http://m.newbst.com/article38/jeejpp.html
成都網站建設公司_創新互聯,為您提供ChatGPT、網站內鏈、面包屑導航、響應式網站、服務器托管、搜索引擎優化
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯