1
votes

I am trying hands on on azure automation runbook, below is the small script i am using to create a storage account.

Param
(   
    [Parameter(Mandatory=$true)]
    [String]
    $AzureResourceGroup,
    [Parameter(Mandatory=$true)]
    [String]
    $StorageAC,
    [Parameter(Mandatory=$true)]
    [String]
    $Loc,
    [Parameter(Mandatory=$true)]
    [String]
    $sku
)

$CredentialAssetName = "AutomationAccount";
$Cred = Get-AutomationPSCredential -Name $CredentialAssetName
if(!$Cred) {
    Throw "Could not find an Automation Credential Asset named 
'${CredentialAssetName}'. Make sure you have created one in this Automation 
 Account."
 }

Add-AzureRmAccount -Credential $Cred
Add-AzureAccount -Credential $Cred

$storeac = Get-AzureRmStorageAccount -ResourceGroupName $AzureResourceGroup
if ($storeac.StorageAccountName -eq "testdd" ){
 write-output " AC found !";

} else {
New-AzureRmStorageAccount -ResourceGroupName $AzureResourceGroup -Name 
$StorageAC -Location $Loc -SkuName $sku
}

However, when ever i run it after publishing, the job is completed with an error (New-AzureRmStorageAccount : A parameter cannot be found that matches parameter name 'SkuName')

Can someone tell me what am i doing wrong ??

1
do you have a line ending after -Name? you should fix it4c74356b41
its one complete statement ( New-AzureRmStorageAccount -ResourceGroupName $AzureResourceGroup -Name $StorageAC -Location $Loc -SkuName $sku) and no parentheses or brackets are left openGavinAzure

1 Answers

1
votes

To resolve the error :

New-AzureRmStorageAccount : A parameter cannot be found that matches parameter name 'SkuName'

Please update the Azure modules in you automation account and by clicking : "Update Azure Modules" under Automation Accounts => Modules and retry the runbook

Update Azure Modules