When iam trying to create lock using powershell Azure automation runbook by using below script
New-AzResourceLock -LockName test -LockLevel CanNotDelete -ResourceGroupName rg -ResourceName resorcename -LockNotes Protection Auto created by Azure Backup -ResourceType Microsoft.Storage/storageAccounts -Force
error getting: A positional parameter cannot be found that accepts argument ‘Auto’enter image description here Hope you can help me with a problem trying to execute a script block, Thanks in Advance.
3
Answers
The lockNotes parameter must be between quotes.
Source: https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azresourcelock?view=azps-9.1.0
Try the following command
Hope this helps!
You should either have string variabel that contains Lock Notes or put the lock notes string in quotes,
Or
I tried in my environment and same error:
Commands:
Initially i have tried same command:
After I changed the Lock notes in String its worked.
Commands:
Reference:
New-AzResourceLock (Az.Resources) | Microsoft Learn