Add a new multi-string value to windows registry

This post has 6 Replies | 1 Follower

Not Ranked
Posts 4
Kit Posted: 07-15-2011 10:32 AM

Hi,

I currently work for a company of about 70 employees that are located throughout the USA. I need to add a multi-string value to each registry and we don't have a domain so I can't push this change out through GP.  

I am wanting to add a new multi-string value to the following location:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WebClient\Parameters

ValueName: AuthForwardServerList

Data:  https://server.company.com

Is there a way to create a windows powershell script to simply run on each user's desktop?

Thank you for any help!


Top 25 Contributor
Posts 296
Microsoft MVP
Top Contributor

try this

$HKLM = 2147483650 #HKEY_LOCAL_MACHINE

$computer = "."  #local machine
$reg = [wmiclass]"\\$computer\root\default:StdRegprov"

$key = "SYSTEM\CurrentControlSet\Services\Webclient\parameters"

$name = "AuthForwardServerList"
$value = "https://server.company1.com","https://server.company2.com","https://server1.company3.com"
$reg.SetMultiStringValue($HKLM, $key, $name, $value)

 

Not Ranked
Posts 4

Thank you for your help!  Although it runs, it doesn't add the new MultiStringValue to the key in the registry.  Here is the output:

 

__GENUS          : 2

__CLASS          : __PARAMETERS

__SUPERCLASS     : 

__DYNASTY        : __PARAMETERS

__RELPATH        : 

__PROPERTY_COUNT : 1

__DERIVATION     : {}

__SERVER         : 

__NAMESPACE      : 

__PATH           : 

ReturnValue      : 5

 

 

Not Ranked
Posts 4

I ran the net helpmsg 5 and received a Access Denied.  I ran this as an administrator from my Desktop.  

Top 25 Contributor
Posts 296
Microsoft MVP
Top Contributor

Return code 5 means Access Denied.

The usual causes are:

  1. Your account doesn't have sufficient privileges to modify the Registry - you're not an administrator
  2. PowerShell wasn't started with elevated privileges - "Run as administrator"

On Vista and above option 2 is the usual culprit

 

Not Ranked
Posts 4

I was able to figure this out.

 

I had to right-click on the Powershell CMD --> Run As Administrator

Next I ran the Set-ExecutionPolicy to Remotesigned

After this I was able to run the script from Powershell (./script.ps1)

 

Thank you for your help!

Top 10 Contributor
Posts 638
Microsoft MVP
Top Contributor

You can do that without WMI as well:

 

PS> $key = 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WebCl
ient\Parameters'
PS> test-path $key
True
PS> Get-itemProperty $key


PSPath                           : Microsoft.PowerShell.Core\Registry::HKEY_LOC
                                   AL_MACHINE\SYSTEM\CurrentControlSet\services
                                   \WebClient\Parameters
PSParentPath                     : Microsoft.PowerShell.Core\Registry::HKEY_LOC
                                   AL_MACHINE\SYSTEM\CurrentControlSet\services
                                   \WebClient
PSChildName                      : Parameters
PSProvider                       : Microsoft.PowerShell.Core\Registry
SupportLocking                   : 1
InternetServerTimeoutInSec       : 30
ServiceDllUnloadOnStop           : 1
ServerNotFoundCacheLifeTimeInSec : 60
ClientDebug                      : 0
FileSizeLimitInBytes             : 50000000
SendReceiveTimeoutInSec          : 60
LocalServerTimeoutInSec          : 15
FileAttributesLimitInBytes       : 1000000
AcceptOfficeAndTahoeServers      : 1
ServiceDebug                     : 0
BasicAuthLevel                   : 1
ServiceDll                       : C:\Windows\System32\webclnt.dll

 

PS> Set-itemProperty $key AuthForwardServerList -value "url1", "url2", "url3" -t
ype MultiString

Page 1 of 1 (7 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.