Powershell 从DSC脚本资源写入变量
是否可以从DSC脚本资源写入外部变量?通过不同的脚本资源传递它? 例如:Powershell 从DSC脚本资源写入变量,powershell,dsc,Powershell,Dsc,是否可以从DSC脚本资源写入外部变量?通过不同的脚本资源传递它? 例如: 这是不可能的。在执行每个测试/设置函数之前,LCM重置运行空间的状态-即清除所有变量。因此,如果要传递信息,最好的方法是写入文件并从中读取 Configuration SomeConfiguration { $list = @() Script SomeScript { TestScript = { $using:list += "1" $using:
这是不可能的。在执行每个测试/设置函数之前,LCM重置运行空间的状态-即清除所有变量。因此,如果要传递信息,最好的方法是写入文件并从中读取
Configuration SomeConfiguration
{
$list = @()
Script SomeScript
{
TestScript = {
$using:list += "1"
$using:list += "2"
return $false
}
SetScript = {
$using:list | Foreach-Object {
...
}
}
GetScript = { }
}
}