Hello,
Can anybody tell me what is the difference between running DSC script by Powershell ISE vs standard console? When I run my script by PS ISE everything works fine, DSC applies to 2 servers incl. encryption. But when I run exactly the same script by “Run with Powershell” I’m getting such error messages:
System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception
exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame).
“line 1021 at , : line 1”
These errors point to the below line (in bold):
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]
}
)
}
The problem is with the Server2 (I’m running script on Server1). All paths are correct, can I use such syntax in the hashtable? the problem is with the standard powershell console, does anybody know why PS ISE does not return any errors?