从 DSC 脚本资源写入变量

Write to a variable from DSC script resource

是否可以从 DSC "script" 资源写入外部变量?通过不同的脚本资源传递它? 示例:

Configuration SomeConfiguration 
{
   $list = @()

   Script SomeScript 
   {
      TestScript = {
         $using:list += "1"
         $using:list += "2"

         return $false
      }  
      SetScript = {
         $using:list | Foreach-Object {
            ...
         }
      }
      GetScript = { }
   }
}

这是不可能的。在执行每个 Test/Set 函数之前,LCM 会重置运行空间的状态 - 即所有变量都被清除。因此,如果你想传递信息,最好的方法是写入文件并从中读取