Editing Registry

Welcome Forums General PowerShell Q&A Editing Registry

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
3 years, 5 months ago.

  • Author
    Posts
  • #24751

    Participant
    Points: 0
    Rank: Member

    I thought the pipe was part of the problem. Thanks for confirming my suspicion.

    Since I am so new at this, the carriage return makes it much easier to read. However, the semicolons will come in handy eventually. Thanks for the tip!

    While I have your attention, I have moved on to my next obstacle… I need to modify an existing registry key value. Below is what I am using…

     New-Item -Path HKLM:\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order -Name ProviderOrder -Value "PnSson,RDPNP.LanmanWorkstation,webclient" -Force 

    the -Name argument keeps adding a new key under “Order” instead of updating the existing sub-key (see attached ‘Reg_ProviderOrder.jpg’). Based on what I have read, this isn’t what should happen. I want it to modify the existing sub-key that is highlighted in the second attachment (‘Reg_ProviderOrder_02.jpg’). I will keep digging however, if you have any ideas…

  • #24756

    Keymaster
    Points: 1
    Rank: Member

    You don’t have “sub-keys” in PowerShell.

    You have items, which have item properties. In RegEdit, an “item” is a folder; what appears on the right-hand pane are “Item Properties.”

    Get-Command -Noun ItemProp*

  • #24757

    Keymaster
    Points: 1
    Rank: Member

    You should also be able to run “Help Registry” to get help on the Registry PSProvider, which includes a lot of useful registry-specific examples.

  • #24910

    Participant
    Points: 0
    Rank: Member
    $computer = 'MyPC'
    $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey['LocalMachine',$computer]
    $key = $reg.OpenSubKey['SYSTEM\CurrentControlSet\Control\NetworkProvider\Order', $true]
    $key.SetValue['ProviderOrder', 'PnSson,RDPNP.LanmanWorkstation,webclient', 'String']
    $key.Close[]
    $key.Dispose[]
    $reg.Close[]
    $reg.Dispose[]
    

    Not sure how to stop it from adding [] when it should be ()

The topic ‘Editing Registry’ is closed to new replies.