Friday, June 26, 2015

Quick Script - Test-PingRDP - Check if servers are pingable and have RDP enabled

I answered a question on a forum with a similar version of this script.  I made it a function instead of a lose script, which have some negatives comparatively.  Functions also are much easier to wrap up into a module for easy distribution.  PSGet/OneGet also requires everything in modules.

Example:
PS C:\> @"
Server1
Server2
Server3
Server4
NotAServer
"@ | Set-Content servers.txt

PS C:\>Test-IPRDP -ServerList servers.txt

PS C:\>Import-Csv .\ServerStatus.csv

ServerName TimeStamp           RDPPort Results
---------- ---------           ------- -------
server1    2015-06-26T09:35:51 3389    Up     
server2    2015-06-26T09:35:52 3389    Up     
server3    2015-06-26T09:35:53 3389    Up     
server4    2015-06-26T09:35:54 3389    Up     
NotAServer 2015-06-26T09:35:55 3389    Down     

PS C:\>


Code:

No comments: