none
Powershell Script to add new Registry Key Value

    Question

  • 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!


    Kit
    Friday, July 15, 2011 4:30 PM

Answers

  • ReturnValue      : 5 - Access Denied
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 3:49 PM
  • Ensure that you are running the script with administrative privileges. In case of windows 7/2008, you need to run the script in elevated mode.

    C:\Users\localuser>net helpmsg 5

    Access is denied.


    C:\Users\localuser>


    Thanks, Sitaram http://techibee.com
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 3:53 PM
  • 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!


    Kit
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 5:36 PM

All replies

  • The registry can be navigated like a directory structure. i got the following code from the web. http://powershell.com/cs/media/p/145.aspx  It should point you in the right direction. 

    1. Md "HKCU:\Software\Testing\" 
    2. New-ItemProperty "HKCU:\Software\Testing\" -Name "MyValue" -Value 12 -PropertyType "DWord"

    Friday, July 15, 2011 4:37 PM
  • Hi Michael,

     

    Thank you for your help.  Unfortunately this isn't quite the direction I am looking for.  So far I have the following:

     

    $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.company.com"

    $reg.SetMultiStringValue($HKLM, $key, $name, $value)

     

    Although this runs, it doesn't add a new value to this key.  Here is the output:

     

    __GENUS          : 2

    __CLASS          : __PARAMETERS

    __SUPERCLASS     : 

    __DYNASTY        : __PARAMETERS

    __RELPATH        : 

    __PROPERTY_COUNT : 1

    __DERIVATION     : {}

    __SERVER         : 

    __NAMESPACE      : 

    __PATH           : 

    ReturnValue      : 5


    Kit
    Monday, July 18, 2011 3:03 PM
  • its wmi so try a put
     
    $reg.put()

    Justin Rich
    http://jrich523.wordpress.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, July 18, 2011 3:48 PM
  • ReturnValue      : 5 - Access Denied
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 3:49 PM
  • Ensure that you are running the script with administrative privileges. In case of windows 7/2008, you need to run the script in elevated mode.

    C:\Users\localuser>net helpmsg 5

    Access is denied.


    C:\Users\localuser>


    Thanks, Sitaram http://techibee.com
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 3:53 PM
  • 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!


    Kit
    • Marked as answer by onearmedman Monday, July 18, 2011 5:36 PM
    Monday, July 18, 2011 5:36 PM