首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检查Runbook History Azure powershell

检查Runbook History Azure powershell
EN

Stack Overflow用户
提问于 2021-02-05 21:47:24
回答 1查看 68关注 0票数 1

我正在用Powershell写一本Azure Runbook,我想知道脚本最后一次运行的时候有没有我能看到的。我尝试过以下几种方法:

代码语言:javascript
复制
    $History = Get-History

if ($History.EndExecutionTime = 5){

$Message = "Ran whithin last five Minutes"
}
else{
$Message = "Starting Runbook"
}

我正在尝试查看runbook powershell脚本是否在最近5分钟内运行,但它不工作

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-08 15:05:29

可以使用Get-AzAutomationJob命令获取runbook的作业(运行历史记录)。下面是我的runbook示例:

代码语言:javascript
复制
$User = "my user name"
$PWord = ConvertTo-SecureString -String "my password" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
Connect-AzAccount -Credential $Credential

$jobs = Get-AzAutomationJob -AutomationAccountName "<automation account name>" -ResourceGroupName "<resource group name>" -RunbookName "<runbook name>"

然后使用$jobs[0].StartTime获取最新的运行记录时间,并检查是否在5分钟内完成。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66064448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档