Azure – 为更新管理创建部署

这是我目前的剧本

#Script to create Resource Groups and Setup Windows Updates
$SubscriptionID = ""
#Connect to Azure and Creates an Resource Groups
Connect-AzAccount
    Set-AzContext -SubscriptionId $SubscriptionID
    function AzureUpdate(){
        $CompanyName = Read-Host -Prompt "Enter Company Name without spaces but use _ update" 
        $Location = "UK South"
        $WorkspaceName = Read-Host -prompt "Enter Workspace Name without spaces but add update at the end" 
        $ResourceGroupName = $CompanyName 
        New-AzResourceGroup -Name $CompanyName -Location $Location -Tag @{Update="Windows Update"}


#Creates the Log Analytics workspace    
New-AzOperationalInsightsWorkspace -Location $Location -Name $WorkspaceName -Sku Standard -ResourceGroupName $ResourceGroupName

#Create an automation Account
New-AzAutomationAccount -Name (Read-Host -prompt "Enter a name for the Automation Account") -ResourceGroupName $ResourceGroupName -Location $Location -Verbose
}

DO{
    Write-host "Would you like to create Update management?" -NoNewline; $run = read-host

    If($run -match '[yY]'){
        AzureUpdate
    }
    else{cls
        exit
    }
}until($run -match '[nN]'){Disconnect-AzAccount}

我很难找到一个命令,让我在自动化账户中设置更新管理,而不是手动进入并将其连接到日志分析工作区。

非常感谢!这是我目前的脚本。

解决方案:

创建工作区和自动化账户后,请尝试以下脚本。

$WorkspaceName = "<WorkspaceName>"
$Location = "<Location of the workspace>"
$SubscriptionID = "<SubscriptionID>"
$ResourceGroupName = "<ResourceGroupName>"
$AutomationAccountName = "<AutomationAccountName>"

$AutomationAccountId = (Get-AzResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Automation/AutomationAccounts -Name $AutomationAccountName).ResourceId
$PropertiesObject = @{
        "resourceId" = $AutomationAccountId
    }
New-AzResource -PropertyObject $PropertiesObject -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.OperationalInsights/workspaces/linkedServices -ResourceName "$WorkspaceName/Automation" -ApiVersion 2015-11-01-preview -Force

$workspaceResourceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $ResourceGroupName -Name $WorkspaceName).ResourceId
$PropertiesObject2 = @{
        "workspaceResourceId" = $workspaceResourceId

    }
$Plan = @{
    "name" = "Updates($WorkspaceName)"
    "publisher" = "Microsoft"
    "promotionCode" = ""
    "product" = "OMSGallery/Updates"
}
New-AzResource -Location $Location -Plan $Plan -PropertyObject $PropertiesObject2 -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.OperationsManagement/solutions -ResourceName "Updates($WorkspaceName)" -ApiVersion 2015-11-01-preview -Force

enter image description here

enter image description here

给TA打赏
共{{data.count}}人
人已打赏
未分类

vuex状态下应该初始化哪种类型的数据,什么时候初始化?

2022-9-8 17:58:16

未分类

如何将HTML元素分配给JavaScript全局变量?

2022-9-8 17:58:18

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索