Skip to content

Commit 40f4a6e

Browse files
vishalk9040sihegde
authored andcommitted
Upgrade all the GPv1 or legacy blob‑only storage account in a subscription to General Purpose v2 (GPv2).ps1
This PowerShell script upgrades all GPv1 or legacy blob-only storage accounts in a subscription to General Purpose v2 (GPv2).
1 parent 0c53c56 commit 40f4a6e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
The below PowerShell script helps to upgrade all the GPv1 or legacy blob‑only storage account in a subscription to General Purpose v2 (GPv2).
2+
3+
#DISCLAIMER:
4+
#By using the following materials or sample code you agree to be bound by the license terms below and the Microsoft Partner Program Agreement the terms of which are incorporated herein by this reference.
5+
#These license terms are an agreement between Microsoft Corporation (or, if applicable based on where you are located, one of its affiliates) and you. Any materials (other than this sample code) we provide to you are for your internal use only. Any sample code is provided for the purpose of illustration only and is
6+
#not intended to be used in a production environment. We grant you a nonexclusive, royalty-free right to use and modify the sample code and to reproduce and distribute the object code form of the sample code, provided that you agree: (i) to not use Microsoft’s name, logo, or trademarks to market your software product
7+
#in which the sample code is embedded; (ii) to include a valid copyright notice on your software product in which the sample code is embedded; (iii) to provide on behalf of and for the benefit of your subcontractors a disclaimer of warranties, exclusion of liability for indirect and consequential damages and a reasonable
8+
#limitation of liability; and (iv) to indemnify, hold harmless, and defend Microsoft, its affiliates and suppliers from and against any third party claims or lawsuits, including attorneys’ fees, that arise or result from the use or distribution of the sample code."
9+
10+
# Login to Azure
11+
Connect-AzAccount
12+
13+
# Get all storage accounts in the subscription
14+
$storageAccounts = Get-AzStorageAccount
15+
16+
# Filter only those accounts where Kind != StorageV2
17+
$nonV2Accounts = $storageAccounts | Where-Object { $_.Kind -ne "StorageV2" }
18+
19+
foreach ($sa in $nonV2Accounts)
20+
{
21+
Write-Host "Upgrading Storage Account:" $sa.StorageAccountName "in Resource Group:" $sa.ResourceGroupName -ForegroundColor Yellow
22+
23+
Set-AzStorageAccount -ResourceGroupName $sa.ResourceGroupName -Name $sa.StorageAccountName -UpgradeToStorageV2 -AccessTier Hot
24+
25+
Write-Host "✔ Successfully upgraded:" $sa.StorageAccountName -ForegroundColor Green
26+
}
27+
28+
Write-Host "Completed processing all non-StorageV2 accounts." -ForegroundColor Cyan

0 commit comments

Comments
 (0)