0
有人可以告訴我Powershell ISE運行DSC腳本與標準控制檯(兩者都以管理員身份運行)之間有什麼區別?DSC(所需狀態配置)
當我通過PS ISE運行我的腳本時,一切正常,DSC適用於2臺服務器,加密。但是,當我通過我得到這樣的錯誤消息「使用PowerShell運行」運行完全相同的腳本:
System.Management.Automation.RuntimeException:你不能調用一個空值表達式的方法。在在 System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame 幀) System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,例外的例外)在 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction .Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)。
線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
的問題是與服務器2(我跑腳本在Server1上)。所有的路徑都是正確的,我可以在散列表中使用這樣的語法嗎?
問題出在標準的PowerShell控制檯,有誰知道爲什麼PS ISE不會返回任何錯誤?
如果你看到代碼的運行之間的不同的標準PowerShell控制檯VS PowerShell的ISE我會檢查你的PowerShell配置文件。有一個不同的profile可以在ISE和標準控制檯中運行。 [關於配置文件](https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/ise/how-to-use-profiles-in-windows-powershell-ise) –