Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Powershell server health script with winrm

Posted on 2011-10-04
6
Medium Priority
?
690 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:brittonv
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:marek1712
ID: 36913136
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
 
LVL 72

Expert Comment

by:Qlemo
ID: 36931015
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
 
LVL 11

Expert Comment

by:marek1712
ID: 36931555
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:brittonv
ID: 36933031
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
 
LVL 11

Accepted Solution

by:
marek1712 earned 2000 total points
ID: 36933592
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
 
LVL 8

Author Closing Comment

by:brittonv
ID: 36933622
Thanks, it appears that 2k8 uses some kind of dynamic MTU thing now...

Thansk for the help!
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question