首页 > 解决方案 > 用于标记的 Azure powerhsell Runbook

问题描述

我正在尝试运行一个用于标记的 powershell runbook...

我已经开始尝试标记虚拟机,我检查了 powershell 代码并且它正在运行,我已经在 azure 门户的 powershell 控制台中逐行运行代码,它正在运行,但运行手册中的相同代码不起作用.....

............................代码..................... ............

    #credentials
    $CredentialAssetName = "kevin";
    $Cred = Get-AutomationPSCredential -Name $CredentialAssetName;
    Add-AzureRmAccount -Credential $Cred;
    #----------------------------------------------------------------

    #
    #take tags
    $r = Get-AzureRmResource -ResourceName "centos-master" -ResourceGroupName VirtualMachines;
    $tags=$r.Tags;
    #----------------------------------------------------------------

    #assign tag to resource
    $tags+=@{test3="kevin3"};
    Set-AzureRmResource -ResourceGroupName "VirtualMachines" -Name "centos-master" -ResourceType "Microsoft.Compute/VirtualMachines" -Tag $tags -Force;
    #----------------------------------------------------------------

提前致谢

标签: azureazure-runbookrunbook

解决方案


推荐阅读