簡體   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