guitarrapc / GraniResource

PowerShell Desired State Configuration Resources for real production workload.
https://www.powershellgallery.com/packages/GraniResource
MIT License
44 stars 8 forks source link

You cannot call a method on a null-valued expression #88

Open Nomenator opened 4 years ago

Nomenator commented 4 years ago

Was trying to install .net 4.8 via DSC. This is my configuration:

configuration InstallNet48
{
    $uri48 = "http://download.windowsupdate.com/d/msdownload/update/software/ftpk/2020/01/windows10.0-kb4486153-x64_43ee33b302bfdba470542a128a9ee0b58faa5412.msu";
    $folder = "c:\Test";
    $path = Join-Path $folder "windows10.0-kb4486153-x64_43ee33b302bfdba470542a128a9ee0b58faa5412.msu";

    Import-DscResource -ModuleName GraniResource

    cDownload net48download
    {
        Uri = $uri48
        DestinationPath = $path
    }

    cDotNetFramework net48install
    {
        KB = "KB4486153"
        InstallerPath = $path
        Ensure = "Present"
        NoRestart = $true
        LogPath = "C:\Test\Present.log"
        DependsOn = "[cDownload]net48download"
    }    
}

I definitely see the download step work, and I was able to make sure that the installer path is being properly produced. I get an exception on cDotNetFramework

This exception message is produced: PowerShell DSC resource Grani_DotNetFramework failed to execute Set-TargetResource functionality with error message: You cannot call a method on a null-valued expression.

The inner exception is this:

"ErrorRecord":  "You cannot call a method on a null-valued expression.",
"WasThrownFromThrowStatement":  true,
"Message":  "You cannot call a method on a null-valued expression.",
"Data":  "System.Collections.ListDictionaryInternal",
"InnerException":  "System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.\r\n   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)\r\n   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)\r\n   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)\r\n   at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()\r\n   at System.Management.Automation.CommandProcessorBase.Complete()",
"TargetSite":  "System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)",
"StackTrace":  "   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)\r\n   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)\r\n   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)\r\n   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)\r\n   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)\r\n   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)\r\n   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.ResourceProviderAdapter.ExecuteCommand(PowerShell powerShell, ResourceModuleInfo resInfo, String operationCmd, List`1 acceptedProperties, CimInstance nonResourcePropeties, CimInstance resourceConfiguration, LCMDebugMode debugMode, PSInvocationSettings pSInvocationSettings, UInt32\u0026 resultStatusHandle, Collection`1\u0026 result, ErrorRecord\u0026 errorRecord, PSModuleInfo localRunSpaceModuleInfo)",
"HelpLink":  null,
"Source":  "System.Management.Automation",
"HResult":  -2146233087

All this is happening in an Azure Automation Account under the State Configuration category. The config compiles no problem, it's just the execution. The target OS is Windows Server 2019.