troubleshooting Question

Add a value to a multi_sz key with powershell

Avatar of HPatzen
HPatzenFlag for Switzerland asked on
Scripting LanguagesPowershell
11 Comments1 Solution8006 ViewsLast Modified:
Hi everyone,

I'm trying to make a powershell script which adds a value to a multi_sz key in the registry but I can't get it to work correctly.

Here's the code:
$windowsversion = (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue("ProductName")
$value1 = "Security Packages"
$value2 = "SecurityProviders"
$NLAPath = "HKLM:\SYSTEM\CurrentControlSet\Control"

if ($windowsversion -like "Windows XP*") {
$SecurityPackagesNoNLA1 = (Get-ItemProperty $NLAPath\Lsa $value1).$value1
Set-ItemProperty $NLAPath\Lsa $value ($SecurityPackagesNoNLA1,"tspkg")
$SecurityPackagesNoNLA2 = (Get-ItemProperty $NLAPath\SecurityProviders $value2).$value2
Set-ItemProperty $NLAPath\SecurityProviders $value2 ($SecurityPackagesNoNLA2,"credssp.dll")
}

Problem is that $SecurityPackagesNoNLA1 is an array but when I do "Set-ItemProperty" it get's converted to a string, which is no good.

Would be great if someone could help me out here. :)

Cheers
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros