none
Power Shell script to run a registry modification based on the Operating system

    Question

  • Microsoft Community,

              I have an immediate neccesity to modify a single registry key out of the registery. Before modifying this registry key I need to determine using powershell what operating system is running and then execute this registery modification on all of the windows 7 enterprise computers. We have a mixed environment of computer both XP professional and Windows 7 Enterprise.  Here is my logic.  Below is the article refering to the original problem on windows 7 and the justifying workaround to resolve this problem.

    1. Determine what version of windows you are running.

    2. Based off of the version either go to null and exit if Xp or or modify registry key if windows 7.

    Would someone please the basic powershell code to perform the above actions using powershell.

    *********************************************************************

    http://support.microsoft.com/kb/937624/en-gb


    Important This workaround may make your system unsafe. Microsoft does not support this workaround. Use this workaround at your own risk.

    To work around this problem, configure the EnableLinkedConnections registry value. This value enables Windows Vista or Windows 7 to share network connections between the filtered access token and the full administrator access token for a member of the Administrators group. After you configure this registry value, LSA checks whether there is another access token that is associated with the current user session if a network resource is mapped to an access token. If LSA determines that there is a linked access token, it adds the network share to the linked location.

    To configure the EnableLinkedConnections registry value, follow these steps:
    1.Click Start, type regedit in the Start Search box, and then press Enter.
    2.Locate and then right-click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System3.Point to New, and then click DWORD Value.
    4.Type EnableLinkedConnections, and then press Enter.
    5.Right-click EnableLinkedConnections, and then click Modify.
    6.In the Value data box, type 1, and then click OK.
    7.Exit Registry Editor, and then restart the computer.

    Thursday, June 28, 2012 9:11 PM

Answers

  • $scriptblock = {
    if((gwmi win32_operatingsystem).version -match '^6*'){
    New-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Value 1 -Type DWORD
    }
    }
    $computers = #list of computers
    $computers | Invoke-Command -Scriptblock $scriptblock

    didn't test it but should work

    Thursday, June 28, 2012 9:35 PM

All replies

  • $scriptblock = {
    if((gwmi win32_operatingsystem).version -match '^6*'){
    New-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Value 1 -Type DWORD
    }
    }
    $computers = #list of computers
    $computers | Invoke-Command -Scriptblock $scriptblock

    didn't test it but should work

    Thursday, June 28, 2012 9:35 PM
  • Dear Blindrood,

       Thank you very much. When I receive this sort of input it allows me the unique opportunity to become a better powershell programmer. So if command is the way to go then use gwmi which uses wmi with the win32)operating system version. What does the V6* syntax do.

      I will try this command out and see if it works against my windows 7 workstations and let you know.

    Thanks

    Microsoft Normal Guy

    Thursday, June 28, 2012 9:39 PM
  • I think now it should be '^6.1' (didn't have 7 available before)

    gwmi will return version which will be in a form 'X.X.XXX' where e.g in Windows 7 can be 6.1.7601, in XP it will be 5.2.XXXX

    -match '^6.1' tests if version property starts with 6.1

    This is one of many ways to determine OS Version.

    You can use Caption property instead of version and match it with 7

    For other ways, google|bing is Your answer

    Friday, June 29, 2012 5:53 AM