繁体   English   中英

DSC(所需状态配置)

[英]DSC (Desired State Configuration)

谁能告诉我Powershell ISE运行DSC脚本与标准控制台(均以管理员身份运行)有什么区别?

当我通过PS ISE运行脚本时,一切正常,DSC适用于2台服务器,包括。 加密。 但是,当我通过“使用Powershell运行”运行完全相同的脚本时,我得到了这样的错误消息:

System.Management.Automation.RuntimeException:您不能在空值表达式上调用方法。 在System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,Exception exception)在System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)在System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) ),位于System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame框架)。

ScriptBlock的第1021行,无文件:第1行

这些错误指向下面的行(粗体):

Configuration Config1
{
...
...
...
}
$configdata = @{
        AllNodes = @(
            @{
                NodeName = "Server1"
                PSDscAllowDomainUser = $true
                CertificateFile = "$((Get-ChildItem 'E:\' | ? {$_.Name -like 'MyFolderName'}).fullname)\Server1.cer"
                Thumbprint = ($Thumbs | ? {$_ -like "Server1*"}).Split("=")[1]
            }
            @{
                NodeName = "Server2"
                PSDscAllowDomainUser = $true
                CertificateFile = "$((Get-ChildItem 'E:\' | ? {$_.Name -like MyFolderName'}).fullname)\Server2.cer"
                Thumbprint = ($Thumbs | ? {$_ -like "Server2*"}).Split("=")[1]
             }
        )
    }

Config1 -ConfigurationData $configdata

问题出在Server2上(我正在Server1上运行脚本)。 所有路径都是正确的,我可以在哈希表中使用这种语法吗?

问题出在标准的Powershell控制台上,有人知道为什么PS ISE不返回任何错误吗?

使用直接的Powershell代码,您几乎可以完成DSC的所有工作。 将检查配置管理系统中描述您系统的代码,并定期针对您的系统运行该代码。

DSC和许多其他配置管理系统旨在使可重复使用的资源实际完成可以共享的工作。

这是常规脚本无法选择配置的原因之一。 在您的情况下,您遇到一个运行时异常,该异常清楚地描述了已传递给脚本中方法的某些值是NULL。

通过以下链接:

Powershell DSC

配置管理理论-幂等与不变

配置管理

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM