Link to home
Start Free TrialLog in
Avatar of brittonv
brittonvFlag for United States of America

asked on

Powershell server health script with winrm

I am looking for a script that I can run from a central server where I can create a report on server health on a list of servers.

The output of the script some thing pretty for managment and an spreadsheet of results for me.

I have WinRM configured, if it matters...

Things I am looking for
Verify a service is installed an running
check that the local Administrator account was renamed
Verify MTU Settings

The way I envision it is a bunch of functions, in a loop from get-content script.

Is this even possible?
Avatar of marek1712
marek1712
Flag of Poland image

Well, it'd be something like this:
$list = Get-Content C:\list_of_pcs.txt
foreach ($computer in $list)
{
    # Unfortunately, my OS doesn't feel like providing MTU size
    $a = Get-WmiObject $computer Win32_NetworkAdapterConfiguration -ComputerName $computer | Where-Object {$_.MACAddress -ne $null} | Format-Table -HideTableHeaders DNSHostName, Description, IPAddress, MTU

    # Service name - not the friendly one. The one you use with net start/stop, sc, etc
    $b = Get-WmiObject Win32_Service -ComputerName $computer | Where-Object {$_.Name -eq "AeLookupSvc"} | Format-Table -HideTableHeaders SystemName, DisplayName, Status

    # Per MS KB: http://support.microsoft.com/kb/243330
    $c = Get-WmiObject Win32_UserAccount -ComputerName $computer | Where-Object {$_.SID -like 'S-1-5-21-*-500'} | Format-Table -HideTableHeaders Name, SID
    $a +$b +$c + "`n`n`n`n" >> \\server\path_to_file.txt
}

Open in new window

I have some problems with hash arrays and such so someone else would have to clean this mess ;)
Avatar of Qlemo
If you tell us what you mean with such sloppy expressions like "verify MTU settings", we might be able to supply a precise solution. Else the above, when removing the first $computer from line 5, should give you an idea.
Oh, haven't noticed it...
I think the author would like to get the MTU size. PoSh doesn't display it for me either on my Win7 or Win2008 R2. Strange.
Avatar of brittonv

ASKER

Thank you, yes, I am trying to get the MTU Settting on a 2008R2 Server.

I can't find a way and the above script doesn't seem to give the requested information.

Additionally the Adminsitrator name portion was taking forever, apparently hanging.  Turns out it just needed a little Tweaking and now it runs in seconds:

    $c = Get-WmiObject Win32_UserAccount -ComputerName $computer -Filter "domain='$computer'" | Where-Object {$_.SID -like 'S-1-5-21-*-500'} | Format-Table -HideTableHeaders Name, SID
ASKER CERTIFIED SOLUTION
Avatar of marek1712
marek1712
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, it appears that 2k8 uses some kind of dynamic MTU thing now...

Thansk for the help!