Having banged my head against this misleading error message, I thought I’d post this.
it’s nothing to do with any of the parameters you’re passing in, believe me I checked.
It’s actually complaining that the Credential already exists! I was doing a redeployment and the credential hadn’t been removed.
And in other useful annoyances, Find-AzureRmResource doesn’t work for Automation Credentials. So now my deployment scripts looks like this:
if ((Get-AzureRmAutomationCredential -ResourceGroupName $rgname -name "meadmin" -AutomationAccountName $AutoName)){ Remove-AzureRmAutomationCredential -ResourceGroupName $rgname -name "meadmin" -AutomationAccountName $AutoName } New-AzureRmAutomationCredential -AutomationAccountName $autoname -ResourceGroupName $rgname -name "meadmin" -Value $acred -Verbose