In PowerShell how do I load multiple values into a variable?
11:04 03 Oct 2019

I have a requirement at work to check several registry key values and I want to automate this process using PowerShell. One of the registry keys that I check has 3 values and I am not able to successfully check it using my PowerShell script.

I do not believe I am correctly loading the $value variable so that it can be compared to the value of $path.

$path = (Get-ItemProperty HKLM:\System\CurrentControlSet\Services\LanManServer).NullSessionPipe

$value = “netlogon samr lsarpc”

if ($path -ne $value) {
    Write-Host “Value is incorrect or missing.”
} else {
    Write–Host “Config is correct.”
}

I expect the output to be

Config is correct.

Instead I get

Value is incorrect or missing.

Using Regedit I can see that the key has the correct values.

string powershell variables