Editing Registry

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of albvar01 albvar01 1 year, 5 months ago.

  • Author
  • #24751
    Profile photo of Sonny Zuliani
    Sonny Zuliani

    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
    Profile photo of Don Jones
    Don Jones

    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
    Profile photo of Don Jones
    Don Jones

    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
    Profile photo of albvar01
    $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']

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

You must be logged in to reply to this topic.