Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

PsDscRunAsCredential with empty password throws error "Object reference not set to an instance of an object." #189

Open
mh185277 opened this issue May 27, 2020 · 0 comments

Comments

@mh185277
Copy link

mh185277 commented May 27, 2020

I tried this script:

$cd = @{
    AllNodes = @(    
        @{  
            NodeName = "localhost"
            PsDscAllowPlainTextPassword = $true
        }
    ) 
}

$UserCredential = $(New-Object System.Management.Automation.PSCredential ("Administrator", (New-Object System.Security.SecureString)))

Configuration ConfigLocahost
{

    Import-DscResource -ModuleName PSDscResources

    Node localhost
    {
        Registry FeShowMenus 
        {
            Ensure = "Present"
            Key =  "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
            ValueName = "AlwaysShowMenus"
            ValueData = "1"
            ValueType = "Dword"
            Force = $true
            PsDscRunAsCredential = $UserCredential
        }
    }
}

ConfigLocahost -ConfigurationData $cd -Force
Start-DscConfiguration -Path .\ConfigLocahost -Wait -Verbose -Force

And result is:
PowerShell DSC resource MSFT_RegistryResource failed to execute Test-TargetResource functionality with error message:
Object reference not set to an instance of an object.

Versions:

PSVersion                      5.1.17763.1007
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1007
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant