在基于 class 的 DSC 资源中使用 [array]

Using [array] in a class based DSC resource

我一直在创建一些基于 class 的自定义 DSC 资源,我 运行 遇到了以下问题:

每当我尝试使用数组作为我的资源的输入时,我都会收到错误消息。

例如

DscProperty(Mandatory)]
[array]$Products

当我尝试使用我的资源创建 MOF 文件时会导致以下错误:

Write-NodeMOFFile : Invalid MOF definition for node 'nodename':
Exceptioncalling "ValidateInstanceText" with "1" argument(s):
"Convert property 'Products' value from type 'STRING[]' to type 'INSTANCE' failed.

$Products 的输入对象将是(例如):

$Products = @("Windows server 2012", "Windows SQL Server", "Windows 8.1")

老实说,我不知道为什么 Write-NodeMOFFile 函数会尝试转换数组(它不需要转换,对吧?),即使它需要转换 - 为什么它会转换数组STRING[]INSTANCE?

有人知道为什么会这样吗? 我让它工作的唯一方法是从我的字符串数组中创建一个长字符串,然后在资源中将它们分开。

像这样声明数组:

[string[]]$product="ddd","dq","dqq"