2016-11-01 20 views
0

スケジュールでランブラを実行したいが、最後のジョブが実行を終了していない場合(つまり、スケジュールが2時間ごとで、ジョブが2.5時間かかる場合は次のジョブ実行しないでください)。Azure Runbookでジョブのステータスを取得

Get-AzureAutomationJobを使用して最後のジョブステータス(https://azure.microsoft.com/en-gb/documentation/articles/automation-runbook-execution/#retrieving-job-status-using-windows-powershell)を取得しようとしましたが、動作させることができません。私は購読などを得るためのすべてのプリアンブルが必要であると推測します。

"Get-AzureAutomationJob:オートメーションアカウントが見つかりませんでした。"

$ConnectionAssetName = "AzureClassicRunAsConnection" 

# Get the connection 
$connection = Get-AutomationConnection -Name $connectionAssetName   

# Authenticate to Azure with certificate 
Write-Verbose "Get connection asset: $ConnectionAssetName" -Verbose 
$Conn = Get-AutomationConnection -Name $ConnectionAssetName 
if ($Conn -eq $null) 
{ 
    throw "Could not retrieve connection asset: $ConnectionAssetName. Assure   that this asset exists in the Automation account." 
} 

$CertificateAssetName = $Conn.CertificateAssetName 
Write-Verbose "Getting the certificate: $CertificateAssetName" -Verbose 
$AzureCert = Get-AutomationCertificate -Name $CertificateAssetName 
if ($AzureCert -eq $null) 
{ 
    throw "Could not retrieve certificate asset: $CertificateAssetName.  Assure that this asset exists in the Automation account." 
} 

Write-Verbose "Authenticating to Azure with certificate." -Verbose 
Set-AzureSubscription -SubscriptionName $Conn.SubscriptionName -  SubscriptionId $Conn.SubscriptionID -Certificate $AzureCert 
Select-AzureSubscription -SubscriptionId $Conn.SubscriptionID 

$job = (Get-AzureAutomationJob –AutomationAccountName "THE NAME OF THE AUTOMATION ACCOUNT AS IT APPEARS IN THE PORTAL" –Name "JobStatusTest" | sort LastModifiedDate –desc)[0] 

答えて

0

さて、Get-AzureRMAutomationジョブを使用する必要があります。私は2016年3月にMicrosoftが古い青空モデルからAzure Automationを削除したと思っています。今は新しいバージョンにのみ存在しています。あなたのコマンドレットにRMを追加する必要があります

+0

ありがとうございました。私はそれを試みましたが、私は同じエラーを取得します。 "Get-AzureRmAutomationJob:オートメーションアカウントが見つかりませんでした" – SturmUndDrang

+0

まあ、スペルをチェックする必要があります。 -ResourceGroupスイッチとリソースグループスイッチを指定することもできます – 4c74356b41

関連する問題