By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SkillieSkillie
  • Azure DevOps
  • AZURE
  • DevOps Fundamentals
  • PowerShell
Reading: Create StorageAccounts Using PowerShell
Share
Aa
SkillieSkillie
Aa
Search
Have an existing account? Sign In
Follow US
  • Azure DevOps
  • AZURE
  • DevOps Fundamentals
  • PowerShell
© Skillie.co.in. All Rights Reserved.
Skillie > PowerShell > Create StorageAccounts Using PowerShell
PowerShell

Create StorageAccounts Using PowerShell

Skillie
Last updated: 2024/12/19 at 4:55 PM
Skillie
Share
SHARE

Here, we will see how to automate the creation of storage accounts using PowerShell. We are using Cloud Shell. The intent is to understand the script.

Contents
Pre RequisitesScriptTo define the underlying variables needed, we need to define a resource Group name in which the storage account exists and the desired location.Using for loop to create storage accounts. Loop to create 10 storage accountsExplanation:Output:

Pre Requisites

  • An Azure account with elevated privileges.
  • Install Azure PowerShell Modules from here.
  • Otherwise, use Azure CloudShell from Azure Portal.

Script

To define the underlying variables needed, we need to define a resource Group name in which the storage account exists and the desired location.

$resourceGroupName = "AZ-140"
$location = "East US"

Using for loop to create storage accounts. Loop to create 10 storage accounts

for ($i = 1; $i -le 10; $i++) {
$storageAccountName = “strgdemoacc$i”

$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName -Location $location -SkuName Standard_LRS

Write-Output “Created storage account: $storageAccountName”

}

Explanation:

  • For loop will do three things. First, it will define all the storage account names here. $storageAccountName = “strgdemoacc$i”
  • Second, $storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName -Location $location -SkuName Standard_LRS, this command will create all storage accounts defined in the first bullet.
  • Once the loop does its job, it will output a message stating “Created storage account: $storageAccountName” 10 times with the storage account name created.

Output:

Categories

  • AZURE
  • Azure Policy
  • Cloud
  • Cloud basics
  • Cybersecurity
  • PowerShell
  • Uncategorized
Skillie December 19, 2024
Share this Article
Facebook Twitter Copy Link Print
Share
Previous Article What is Social Engineering? What is Social Engineering?
Next Article Azure policy questions and answers
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent posts

  • Azure policy questions and answers
  • Create StorageAccounts Using PowerShell
  • What is Social Engineering?
  • What is a Malware?
  • What is Phishing Attack?
SKILLIE SKILLIE
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms Of Use
SKILLIE SKILLIE
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of use

© Skillie.co.in. All Rights Reserved.

Removed from reading list

Undo
Welcome Back!

Sign in to your account

Lost your password?