我正在尝试为虚拟机创建启动/停止计划。简单的安排:
早上10点开始,下午5点停止,周末不要跑步
尝试创建这个自动时间表变成了一场噩梦!我没有时间学PowerShell。
我想通过自动化门户来做这件事。我已经通过存储库导入了一个脚本。
"Name of Script: Scheduled Virtual Machine Shutdown/Startup by Automys"
,如Azure门户中所示:
"assert-autoshutdownshedule."
我现在需要编辑这个脚本。
我在哪里/如何输入我的凭证/参数?需要改变什么?
在azure门户中创建运行为自动化帐户然后将下面的脚本导入到Runbook中。
if(-not (@('Saturday', 'Sunday') -contains (Get-Date).DayOfWeek)) #skip execution if the day of week is Saturday or Sunday
{
$cred = Get-AutomationPSCredential -Name "Your Automation Account"
Login-AzureRmAccount -Credential $cred
Get-AzureRmSubscription
Select-AzureRmSubscription -SubscriptionName "Your Subscription Name"
Start-AzureRmVM -Name "VM001" -ResourceGroupName "Your Resource group" -ErrorAction Continue -Force
}
祝你一切顺利:)
让我知道这是否有效