Today’s “Helpful Function of the Day” is my attempt to help you keep your server descriptions in sync.

You use it by placing it in your profile, or by dot-sourcing the script, or by adding the function to one of your own scripts. The syntax is:

Check-Description [-ServerName] <YourServer> [-SkipIdentical]

If you would like to check or update the description of one server, first connect to Virtual Center (Connect-VIServer), then run: Check-Description SERVERNAME. The script will return the description from the VI Client (if the server is a vm), from Active Directory (if it is found in AD) and from the registry of the server itself (the so-called Browse Comment). It then displays a menu which allows you to select one description as the correct description. It will then update the other descriptions (unless they are unavailable).

In case you would like to check a big list of servers to see if the descriptions are in sync, you use the command as follows:

Get-QADComputer -SearchRoot “OU=Servers,DC=mydomain,DC=com” -SizeLimit 0 | ForEach { Check-Description $_.Name -SkipIdentical }

This command will process all found servers. You can also process a list of servers from a textfile like so:

Get-Content D:\servers.txt | ForEach { Check-Description $_ -SkipIdentical }

The SkipIdentical switch will cause the script to output the servername and description if the descriptions are all in sync. This will speed up using the script, because it will not ask for your input for each and every server, only for those where the descriptions are not identical.

Check-Description (Rename to .ps1)

Questions and remarks are welcome in the comments!

Enjoy!

Tagged with:
 

Leave a Reply