PS C:\src\Chocolatey> get-module PSDesiredStateConfiguration
PS C:\src\Chocolatey> ipmo PSDesiredStateConfiguration -RequiredVersion 2.0.6
PS C:\src\Chocolatey> get-module PSDesiredStateConfiguration
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.0.6 PSDesiredStateConfiguration {Configuration, Get-DscResource, Invoke-DscResource, New-Ds…
PS C:\src\Chocolatey> ChocoInstalled -OutputPath .\output\MOFs\
PSDesiredStateConfiguration\node: C:\src\Chocolatey\source\GCPackages\ChocoInstalled\ChocoInstalled.config.ps1:4:5
Line |
4 | node ChocoInstalled {
| ~~~~
| The term 'Chocolatey\ChocolateySoftware' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
InvalidOperation: You cannot call a method on a null-valued expression.
PS C:\src\Chocolatey> get-module PSDesiredStateConfiguration
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.0 beta1 PSDesiredStateConfiguration {Configuration, ConvertTo-DscJsonSchema, Get-DscResource, I…
Script 2.0.6 PSDesiredStateConfiguration {Configuration, Get-DscResource, Invoke-DscResource, New-Ds…
As you can see, the 3.0.0-beta1 version is automatically imported, and I suspect that's why compiling the configuration with a MOF-based resource doesn't work.
Compiling a Class based resource does work though.
PS C:\src\Chocolatey> ChocoInstalled -OutputPath .\output\MOFs\
PSDesiredStateConfiguration\node: C:\src\Chocolatey\source\GCPackages\ChocoInstalled\ChocoInstalled.config.ps1:4:5
Line |
4 | node ChocoInstalled {
| ~~~~
| The term 'Chocolatey\ChocolateySoftware' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
InvalidOperation: You cannot call a method on a null-valued expression.
PS C:\src\Chocolatey> get-module PSDesiredStateConfiguration
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.0 beta1 PSDesiredStateConfiguration {Configuration, ConvertTo-DscJsonSchema, Get-DscResource, I…
Script 2.0.6 PSDesiredStateConfiguration {Configuration, Get-DscResource, Invoke-DscResource, New-Ds…
Error details
PS C:\src\Chocolatey> get-error
Exception :
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : You cannot call a method on a null-valued expression.
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvokeMethodOnNull
InvocationInfo :
ScriptLineNumber : 2751
OffsetInLine : 20
HistoryId : -1
ScriptName :
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1
Line : if($nodeDoc.Contains("PsDscRunAsCredential"))
PositionMessage : At
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1:2751 char:20
+ if($nodeDoc.Contains("PsDscRunAsCredential"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0
PSCommandPath :
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1
CommandOrigin : Internal
ScriptStackTrace : at Write-NodeMOFFile,
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1: line 2751
at Configuration,
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1: line 2205
at <ScriptBlock>, C:\src\Chocolatey\source\GCPackages\ChocoInstalled\ChocoInstalled.config.ps1:
line 1
at <ScriptBlock>, <No file>: line 1
TargetSite :
Name : CheckActionPreference
DeclaringType : System.Management.Automation.ExceptionHandlingOps, System.Management.Automation, Version=7.3.2.500,
Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : You cannot call a method on a null-valued expression.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
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)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
InvocationInfo :
ScriptLineNumber : 2751
OffsetInLine : 20
HistoryId : -1
ScriptName :
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1
Line : if($nodeDoc.Contains("PsDscRunAsCredential"))
PositionMessage : At
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1:2751 char:20
+ if($nodeDoc.Contains("PsDscRunAsCredential"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0
PSCommandPath :
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1
CommandOrigin : Internal
ScriptStackTrace : at Write-NodeMOFFile,
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1: line 2751
at Configuration,
C:\Users\GaelColas\Documents\PowerShell\Modules\PSDesiredStateConfiguration\3.0.0\PSDesiredStateConfiguration.psm1: line 2205
at <ScriptBlock>, C:\src\Chocolatey\source\GCPackages\ChocoInstalled\ChocoInstalled.config.ps1: line 1
at <ScriptBlock>, <No file>: line 1
Environment data
Name Value
---- -----
PSVersion 7.3.2
PSEdition Core
GitCommitId 7.3.2
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
With ChocoInstalled.config.ps1 containing this:
Here's what I tried:
As you can see, the 3.0.0-beta1 version is automatically imported, and I suspect that's why compiling the configuration with a MOF-based resource doesn't work.
Compiling a Class based resource does work though.
Expected behavior
Actual behavior
Error details
Environment data
Version
notcrescendo
Visuals
N/A