I want to use powershell to update a couple of registry settings for a security finding for ms15-124. I need to add a key, and dword to a bunch of machines.
I found a nice write up on in a powershell blog and it seemed to fit the bill, but I found it breaks if there is a space in the new key.
script:
$cred = Get-Credential domain\username
Invoke-Command -cn (gc servers.txt) -cred $cred {pushd;sl HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl; ni FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING; New-ItemProperty -name iexplore.exe -PropertyType Dword –path FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING -value “1” ; popd}
When I run this I get:
A positional parameter cannot be found that accepts argument
'Explorer\MAIN\FeatureControl'.
So the space after 'Internet' breaks it.
I tried containing the HKLM path with ( ) " " ' all of which changes the error to :
Cannot find path
'C:\Users\user\Documents\HKLM\SOFTWARE\Microsoft\Internet
Explorer\MAIN\FeatureControl' because it does not exist.
+ CategoryInfo : ObjectNotFound: (C:\Users\user..\FeatureContr
ol:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLo
cationCommand
+ PSComputerName : servername
I am hoping this is an easy fix!