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 undefined
Last Comment
Avatar of 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
Flag of Germany image

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.
Avatar of marek1712
Flag of Poland image

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
Flag of United States of America image


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
Avatar of marek1712
Flag of Poland image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of brittonv
Flag of United States of America image


Thanks, it appears that 2k8 uses some kind of dynamic MTU thing now...

Thansk for the help!

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo