The following script below worked for awhile, not sure why I keep getting this error:
Select-AzureSubscription : The subscription name Visual Studio Ultimate with MSDN doesn't exist. Parameter name: name
...etc..
Get-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default to set the default subscription. At RICSVMStartup:13 char:13
Here's the powerscript:
workflow RICSVMStartup
{
# Grab the credential to use to authenticate
$Cred = Get-AutomationPSCredential -Name 'AzureCredential'
#Connect to Azure
Add-AzureAccount -Credential $Cred
#Select the Azure subscription you want to work against
Select-AzureSubscription -SubscriptionName "Visual Studio Ultimate with MSDN"
# Get all Azure VMs in the subscription that are not stopped and deallocated and shut down
inlinescript
{
Get-AzureVM | where{$_.status -ne 'Started' -and $_.name -like 'RICS*' -and $_.name -ne 'RICSDC2'} | start-AzureVM
}
}
In brief, you must have a
server administrator
account and create a AD account, set the new AD Account as co-administrator inSETTING>Administrators
, set the new AD account as credential inAutomation>ASSET
, and run your code:$Cred = Get-AutomationPSCredential -Name 'your new AD account'
. The above answer refers to more information links.