【问题标题】:azure startup shutdown automation天蓝色启动关闭自动化
【发布时间】:2016-04-26 14:40:31
【问题描述】:

我正在尝试为我的虚拟机创建启动/停止计划。简单的时间表:

上午 10 点开始,下午 5 点停止,周末不要跑步

试图创建这个自动日程表正在变成一场噩梦! 我没有时间学习 PowerShell。

我通过自动化门户研究过这样做。我已经通过存储库导入了一个脚本。

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

如 Azure 门户中所示:

"assert-autoshutdownshedule."

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

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

【问题讨论】:

    标签: azure azure-automation


    【解决方案1】:

    在 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
    
    
    
    
    
    }
    

    一切顺利:)

    让我知道这是否有效

    【讨论】:

    • 您好,谢谢您的回复。我们已停止使用 Azure,但我肯定会遵守说明,以备将来使用。
    猜你喜欢
    • 1970-01-01
    • 2022-08-21
    • 1970-01-01
    • 2022-10-20
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多