0

cmdletsAzure Runbook からAzure Automation を使用して何にもアクセスできないようです。以下では、サブスクリプション内のすべての VM を正常に取得していますが、 を呼び出すとGet-AzureAutomationAccount空のコレクションが返されます (2 つのオートメーション アカウントがある場合)。自動化を使用して実行できるその他の呼び出しは、cmdlets空の例外または見つからない例外を返します。

提案をお寄せいただきありがとうございます!

workflow Get-AzureVMTutorial
{
#The name of the Automation Credential Asset this runbook will use to authenticate to Azure.
$CredentialAssetName = 'AaronCred'

#Get the credential with the above name from the Automation Asset store
$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."
}

#Connect to your Azure Account
$Account = Add-AzureAccount -Credential $Cred
if(!$Account) {
    Throw "Could not authenticate to Azure using the credential asset '${CredentialAssetName}'. Make sure the user name and password are correct."
}

#TODO (optional): pick the right subscription to use. Without this line, the default subscription for your Azure Account will be used.
#Select-AzureSubscription -SubscriptionName "TODO: your Azure subscription name here"

#Get all the VMs you have in your Azure subscription
$VMs = Get-AzureVM

#Print out up to 10 of those VMs
if(!$VMs) {
    Write-Output "No VMs were found in your subscription."
} else {
    Write-Output $VMs[0..9]
}

# PROBLEM - No accounts are returned even though I have 2
$automationAccounts = Get-AzureAutomationAccount

#Print out up to 10 of those automation accounts
if(!$automationAccounts) {
    Write-Output "No automation accounts were found in your subscription."
} else {
    Write-Output $VMs[0..9]
}
}
4

1 に答える 1