2015-09-16 76 views
1

我正在尝试为我的虚拟机创建启动/停止计划。简单计划:蔚蓝启动关机自动化

开始上午10点,止损@下午5时,不要在周末

运行来创建这样一种自动计划正在变成一场噩梦! 我没时间学习PowerShell。

我打算通过自动化门户进行此操作。我已经通过存储库导入了一个脚本。

"Name of Script: Scheduled Virtual Machine Shutdown/Startup by Automys" 

,并因为它显示在Azure的门户网站:

"assert-autoshutdownshedule." 

我现在需要编辑这个脚本。

我在哪里/如何输入我的凭证/参数?什么需要改变?

回答

0

在天青门户 中创建以自动化帐户运行,然后将以下脚本导入到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 





} 

一切顺利:)

让我知道这工作

+0

嗨,THX,您的答复。我们已经停止使用Azure,但我一定会坚持使用Azure,以便将来使用。 – Terra