none
registry change RRS feed

  • Question

  • Hi All i want to modify the below registry values from 0 to 1 using powershell on remote servers, i have servers list in the below format. experts guide me on this, i am trying the below but i am not getting it

    Server01.contoso.com
    Server02.contoso.com

    $ServersList = "c:\list.txt"
    $SS = get-Content -Path $ServersList
    foreach ($Servers in $SS ) {
    Set-itemproperty -name EnableSecuritySignature -path "HKLM\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "1";}

    Wednesday, July 1, 2020 2:06 PM

Answers

  • $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $MYServers
    foreach ($Servers in $QQ ) {
        Invoke-Command -ComputerName $Servers -ScriptBlock {
            Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
        }

    Friday, July 3, 2020 9:17 AM
  • $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $MYServers
    foreach ($Servers in $QQ ) {
        Invoke-Command -ComputerName $Servers -ScriptBlock {
            Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
        }

    you do not need to use loop in this case
    if data.txt contain computer names of your hosts you can directly provide whole list to invoke-command

    $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $QQ
    Invoke-Command -ComputerName $Servers -ScriptBlock {
         Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
     }
    
    in this case your script will work much quicker


    The opinion expressed by me is not an official position of Microsoft

    Friday, July 3, 2020 9:41 AM

All replies

  • You cannot remotely change the registry that way.

    Please take some time t learn basic PowerShell to learn how to set up and use remoting.

    Here is a place for beginners to get a basic understanding of PS.

    Please only post code in this forum according to the following link:


    \_(ツ)_/

    Wednesday, July 1, 2020 2:13 PM
    Moderator
  • What about using Group Policies to do that?

    If that's not your cup of tea, use Invoke-Command and a script block to accomplish the task.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)


    Wednesday, July 1, 2020 2:34 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Yang Yang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, July 3, 2020 3:03 AM
  • $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $MYServers
    foreach ($Servers in $QQ ) {
        Invoke-Command -ComputerName $Servers -ScriptBlock {
            Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
        }

    Friday, July 3, 2020 9:17 AM
  • $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $MYServers
    foreach ($Servers in $QQ ) {
        Invoke-Command -ComputerName $Servers -ScriptBlock {
            Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
        }

    you do not need to use loop in this case
    if data.txt contain computer names of your hosts you can directly provide whole list to invoke-command

    $MYServers = "C:\data.txt"
    $QQ = get-Content -Path $QQ
    Invoke-Command -ComputerName $Servers -ScriptBlock {
         Set-itemproperty -name EnableSecuritySignature -path "HKLM:\System\CurrentControlSet\Services\LanManWorkstation\Parameters" -value "0"
     }
    
    in this case your script will work much quicker


    The opinion expressed by me is not an official position of Microsoft

    Friday, July 3, 2020 9:41 AM