azure - 以与单个 DSC 配置不同的名称编译 Powershell DSC
问题描述
我正在使用单个 PS 脚本自动化整个 DSC 解决方案,我已经将 DSC 配置上传到自动化帐户,并且我想为每个应用程序创建单独的节点配置。我的计划是将 DSC 模板从自动化帐户导出到本地计算机并以不同的名称导入,但是当我运行 Export-AzAutomationDscConfiguration 时出现此错误:
Export-AzAutomationDscConfiguration:配置内容在当前预览中不能处于编辑/草稿模式。使用已发布选项。
这基本上是一个谎言,因为 DSC 处于 Published 状态。
所有这些的目的是为每个应用程序提供单独的节点配置(从 Azure 中现有的 DSC 配置编译而来),因为 VM 被添加到相同的域,但不同的 OU。到目前为止,我准备了这个脚本:
$user = "***"
$pass = "***"
$OU = "***"
$Params = @{"Username"=$user;"Password"=$pass;"OU"=$OU}
$DSCName = "dsc1"
$ResourceGroupName = "rg1"
$AutomationAccountName = "aa1"
$ConfigurationData = @{
AllNodes = @(
@{
PSDscAllowPlainTextPassword = $true
}
)
}
Export-AzAutomationDscConfiguration -Name $DSCName -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Slot Published -OutputFolder C:\Temp\dsc.ps1
#some commands that will add OU name to configuration name within the exported file
#$newDSCName = $DSCName + "." + $OU
Import-AzAutomationDscConfiguration -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName -SourcePath C:\Temp\dsc.ps1 -Force
Start-AzAutomationDscCompilationJob -ConfigurationName $newDSCName -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Parameters $Params -ConfigurationData $ConfigurationData
还有一个用于编译命令的标志,称为 -IncrementNodeConfigurationBuild,但我无法区分它们,它只会在配置名称的末尾添加数字。
我想知道在 DSC 中使用 RenameAndDomainJoin 或 DomainMembership 资源,但是对于 50 多个具有不同 OU 的应用程序,这些并不是真正有用的,据我所知,我必须在一个 DSC 文件中为每个应用程序创建单独的配置,这是一个非常糟糕的解决方案。因此,我在 DSC 中使用了带有 Restart 标志的 Add-Computer 命令,该命令使用来自 $param 变量的参数(不确定这是否可行,尚未测试)。
您是否知道为什么 Export-AzAutomationDscConfiguration 命令会出现错误,即使 DSC 处于已发布状态,或者您有任何其他想法或我可能在此处实施的解决方案的文档?
解决方案
推荐阅读
- c# - RectTransform.deltaSize 在 Unity 中不起作用
- css - 我的页面底部有一个可折叠元素,当我单击以折叠它时,它不会锚定到新打开的元素
- date - 轴上日期/时间的 Power BI 折线图
- ios - 如何通过 2 个视图控制器传递 textfield.text 数据
- python - 如何在 python 中运行 git bash 命令?
- javascript - 如何使用键名检索对象中的特定键?
- c++ - 在 C++ 中使用函数装饰器(使用闭包)时出现意外的分段错误
- c++ - 在命名空间中定义变量但在测试中获得空值
- mysql - 在 MySQL 中将行转换为列以获取自定义值
- bixby - 索引 Bixby 口语摘要