gpt4 book ai didi

powershell - 如何在 powershell DSC 中正确写入参数

转载 作者:行者123 更新时间:2023-12-03 00:01:30 27 4
gpt4 key购买 nike

我创建了自定义 DSC 模块。我在 DSC 资源中只有两个值,其中一个是二维数组:

node ("localhost")
{
ChangeXML ChangeValue
{
NameFile=$PathToXml #Enter path to input xml
DownloadManagerCustomData =
@(
@{
Node = 'some path';
Value = 'some value'
}#end of hash array

@{
Node = 'some path';
Value = 'some value'
}#end of hash array

)#end of two dimensional array

}
}

我创建了 ChangeXML.schema.mof,它描述了变量。所以,我不知道如何写数组。你能帮助我吗?
[ClassVersion("1.0"), FriendlyName("ChangeXML")]
class ChangeXML : OMI_BaseResource
{
[Key] String NameFile;
[Write] *Array?* DownloadManagerCustomData;
};

最佳答案

[ClassVersion("1.0"), FriendlyName("ChangeXML")]
class ChangeXML : OMI_BaseResource
{
[Key] String NameFile;
[Write] EmbeddedInstance("MSFT_KeyValuePair")] String DownloadManagerCustomData[];
};

您也可以使用 New-MofFile PowerShell.org's DSC repo中的函数.它为您生成 MOF 并且运行良好(完全披露,我不隶属于它,但我为它贡献了一点代码)。

编辑

修复了上面的代码,才发现 New-MofFile (目前)不会处理这个问题,但可以这样做,当我有机会时,我可能会为此目的对其进行修补。

此外,我为您展示的内容(哈希表数组)而不是您所说的内容(数组数组)提供了 MOF 语法。

关于powershell - 如何在 powershell DSC 中正确写入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26762169/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com