header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Remote Registry Check
Last Post 11 May 2011 07:23 PM by Daniel Petcher. 3 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JonnyUser is Offline
New Member
New Member
Posts:1
Avatar

--
23 Oct 2009 02:07 AM

    Hi all,
    I hope I've posted this question in the correct section but apologies if I haven't. I'm new to powershell. I've successfully written some basic scripts that automate various tasks I have to perform on a daily basis. These scripts work just fine and I thought I was getting the hang of PS but it seems I've met my match! The script in question is supposed to check through a supplied list of machines [test.txt] and query a specfic registry key namely:
    SYSTEM\CurrentControlSet\Control\Class\{4D36e972-E325-11CE-BFC1-08002bE10318}\0001
    I am currently testing with two machines only but ultimately I want to run this against all workstations in my domain. I am looking for a value of 6 as that denotes that the NIC is set to 100Mb/Full which is what I want to see. A 0 denotes that the nic is set to auto and in our environment this causes an issue. What I have found is that if I manually set one of the machines to auto (creating an exception) and then run the script, the output states that both machines are set to 100Mb/full which is clearly not the case. This is my first attemot at using function and I've obviously got something wrong with my script but I can't figure out what.
    Any help is most appreciated.
    Regards Jonny Barker

    function Get-RequestedMediaType{
        param([string]$computer = ".")

     
        $regHive = [Microsoft.Win32.RegistryHive]"LocalMachine";
        $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($regHive,$computer);
        $subKey = $regKey.OpenSubKey("SYSTEM\CurrentControlSet\Control\Class\{4D36e972-E325-11CE-BFC1-08002bE10318}\0001");
          $subKey.GetValue("RequestedMediaType")
    }

    Clear-Host
    $Machines = Get-Content "test.txt"
    foreach ($MachineName in $Machines){
    $status = Get-RequestedMediaType -computer $MachineName
    if ($status -eq 6)
    {Write-Host $MachineName is forced to 100Mb/Full -ForegroundColor "Green"}
    else
    {Write-Host $MachineName is NOT forced to 100Mb/Full -ForegroundColor "Red"}}

    AythUser is Offline
    Basic Member
    Basic Member
    Posts:232
    Avatar

    --
    24 Oct 2009 04:21 PM
    Hey Johnnyoh,

    It might have been better to put this in the General Powershell forum instead of here. I started looking at this script, and it seems to run fine for me. I took two machines and threw them into a text file like you have. I ended up using a different key than RequestedMediaType, one I created just to test to be exact and it worked fine. Couple of questions:

    1. What version of Powershell are you running?
    2. I would confirm again that the exception is there, might be a good idea to add a Write-Host $status after you call the function, to confirm what value $status is set to.

    We should be able to get this working. Thanks.

    Cheers,

    Darrin aka Ayth
    My Blog about Powershell http://poweroftheshell.blogspot.com/ Follow me on twitter @darrinhenshaw
    jcjim998User is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    13 Dec 2010 06:53 PM
    I don’t know why. Everybody is talking about registry now. It seems that TuneUp360 could help you dealing with your problems. Beside, it is easy to use.
    Daniel PetcherUser is Offline
    New Member
    New Member
    Posts:7
    Avatar

    --
    11 May 2011 07:23 PM
    I'm not as comfy exploring the registry. I would probably use PowerGUI to explore the WMI Browser and find the equivalent information there. It might even be formatted as "100 Auto" vs "100 Full" for you already.
    My opinions are mine. My employers have other people to speak for them.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer