DNS check for powershell

Saturday, October 11th, 2014

I had a need to do a quick DNS lookup for computers in a powershell script which going through a list of computers. There are two ways to a system will not have a DNS entry: 1) System retired. 2) System uses DHCP and is not on the network.

A quick way to perform a look would be to use:

[System.Net.Dns]::GetHostName()

It does give output directed to the console.  If you want to suppress it, use the [void] option.

[void][System.Net.Dns]::GetHostName()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: