2017-02-20 49 views
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不会返回任何错误?

+0

如果你看到代码的运行之间的不同的标准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) –

回答