Windows Vista Forums

Info: I need to compare Registry Subkeys between a Model Server and a Server
  1. #1


    Brandon Shell Guest

    Info: I need to compare Registry Subkeys between a Model Server and a Server

    Goal:
    ===
    I need to compare a list of subkeys (including subkeys/values) from a model
    server. With the follow code I am able to get Subkeys and one layer of
    values, and I am sure I could probably keep looping and get all the info,
    but I am curious if there is away I just get an object and compare them?

    Code:
    ====
    function Check-RegKeys {
    Param([string]$Server,[string]$model)
    $hResult = $true
    $settings = [xml] (Get-Content c:\AppCheckSettings.xml)
    $regkeys = $settings.BBAScanSettings.RegSubkeys
    $regkeys = $regkeys.Split("`n")
    $i = 0
    foreach ($reg in $regkeys) {
    $reg = $reg.TrimStart()
    if($reg -match "[^H]") {
    $ServerKey =
    [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,
    $Server)
    $ModelKey =
    [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,
    $Model)
    $mKey = $ModelKey.OpenSubKey("$reg",$false)
    Write-Log ""
    $mKey.GetValueNames()
    Write-Log ""
    }
    }
    $hResult
    }





      My System SpecsSystem Spec

  2. #2


    Jeffrey Snover [MSFT] Guest

    Re: I need to compare Registry Subkeys between a Model Server and a Server

    I'm not really sure what you are trying to do but I think your answer lies
    somewhere along the following lines:



    I would try to leverage Compare-Object.



    Try writing a function which takes a machine name list of keys and returns
    the values and subvalues. Let's call that function GET-KEYS. You could
    then do something like:



    $keys = (whatever)

    Compare-Object (Get-Keys Machine1 $keys) (Get-Keys Machine2 $keys)


    --
    Jeffrey Snover [MSFT]
    Windows PowerShell/Aspen Architect
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, no confers rights.
    Visit the Windows PowerShell Team blog at:
    http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at:
    http://www.microsoft.com/technet/scr.../hubs/msh.mspx



      My System SpecsSystem Spec

  3. #3


    Brandon Shell Guest

    Re: I need to compare Registry Subkeys between a Model Server and a Server

    That is exactly what I did... I was just looking for a short-cut instead of
    having to loop through subkeys. If I could just get an object using a root
    subkey and then do a compare it would be only 10lines. As it is... it takes
    me 15line or so just to get the subkey and then all subkeys, and then all
    the subkeys of that and so on.

    "Jeffrey Snover [MSFT]" <jsnover@microsoft.com> wrote in message
    news:uES16fVyGHA.2036@TK2MSFTNGP05.phx.gbl...
    > I'm not really sure what you are trying to do but I think your answer lies
    > somewhere along the following lines:
    >
    >
    >
    > I would try to leverage Compare-Object.
    >
    >
    >
    > Try writing a function which takes a machine name list of keys and returns
    > the values and subvalues. Let's call that function GET-KEYS. You could
    > then do something like:
    >
    >
    >
    > $keys = (whatever)
    >
    > Compare-Object (Get-Keys Machine1 $keys) (Get-Keys Machine2 $keys)
    >
    >
    > --
    > Jeffrey Snover [MSFT]
    > Windows PowerShell/Aspen Architect
    > Microsoft Corporation
    > This posting is provided "AS IS" with no warranties, no confers rights.
    > Visit the Windows PowerShell Team blog at:
    > http://blogs.msdn.com/PowerShell
    > Visit the Windows PowerShell ScriptCenter at:
    > http://www.microsoft.com/technet/scr.../hubs/msh.mspx
    >
    >




      My System SpecsSystem Spec

  4. #4


    Jeffrey Snover [MSFT] Guest

    Re: I need to compare Registry Subkeys between a Model Server and a Server

    In a future release we want to allow you to mount a remote registry so that
    will make it easier then.

    --
    Jeffrey Snover [MSFT]
    Windows PowerShell/Aspen Architect
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, no confers rights.
    Visit the Windows PowerShell Team blog at:
    http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at:
    http://www.microsoft.com/technet/scr.../hubs/msh.mspx



      My System SpecsSystem Spec

Info: I need to compare Registry Subkeys between a Model Server and a Server problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can 2008 Storage Server standard be used as a FTP and printer server in additon to file server role ? Hubert Server General 0 21 Oct 2009
enumerate registry subkeys knothead VB Script 3 26 Aug 2008
Help with server info cmcelroy Vista mail 5 19 Mar 2008
Finding and removing values in registry subkeys Michael Pope PowerShell 3 15 Mar 2008
Cannot delete a registry key (or subkeys) --- ??? notaguru Vista General 10 29 Oct 2007