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?
LVL 8
brittonvAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

marek1712Commented:
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 ;)
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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.
0
marek1712Commented:
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.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

brittonvAuthor Commented:
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
0
marek1712Commented:
Strangely, even the registry doesn't contain a hint about MTU.
Your best bet is to execute NETSH INTERFACE IPV4 SHOW SUBINTERFACES with Invoke-Command. You'll get the output from the NETSH though.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brittonvAuthor Commented:
Thanks, it appears that 2k8 uses some kind of dynamic MTU thing now...

Thansk for the help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.