List WIndows servers in Active Directory Domain and Check out the ping status of Listed Servers.

Posted on: November 9, 2012

To Much of Garbage , We need to Clean it up . This applies to your Active Directory As well.

This week , I was having some time to play around with PowerShell(Power) .

( I Always call it as power , Because It has a capacity to accomplish each and everything task in Windows :))

Since I have made up my mind to list out the servers which are not used anymore , I thought I will create a script for this.

Below is my script .

$a = Get-ADComputer -filter * -SearchBase “DN of the Domain” -properties` Operatingsystem
$list= @()
Foreach ($os in $a)

 If($os.Operatingsystem -match “windows server *”)
 $list += $os | Select-Object @{ L=’ComputerName’;E={$_.Name} }, @{L=’OperatingSystem’;E={$_.Operatingsystem}}

$list | Export-Csv -Path C:\file.csv -notype

$r = Import-Csv C:\file.csv | Select-Object -ExpandProperty Servername
foreach ($Server in $r)
 if(!(Test-Connection $Server -Quiet))
 Write-Host “$server not reachable”


Note – One need to put DN of the domain Eg – “DC=AD,DC=COM” , In Place of “DN of the Domain”

The script will produce a Csv File C:\File.csv which contains List of windows server in specified domain.


The servers which are not reachable will be listed out in the Powershell Console.

I hope this information helps.

There will be some more Powershell Scripts which I will be building , Looks Like I am in Love with Powershell’s POWER




4 Responses to "List WIndows servers in Active Directory Domain and Check out the ping status of Listed Servers."

As a blog owner. Do you believe like running a site or even internet site
is realistic? Also how would you get people to check out your
website or blog?

Running own website – It depends on your interest , If you are owning website , it will give me more control over design and define the content inside it.

But ,

What I feel , Being a system administrator/Consultant , One can host there blogs in sites like etc, It is more than enough to share your knowledge to outside world. 🙂

You can participate in forum discusssion , where you can give a reference to your articles , blogs etc ,

Moreover , Google will do a INDEX depending on the blogs articles you have written 🙂

-Prashant Girennavar.

I just hoped to just take a couple of moments and tell you that I enjoyed the blog post.
I really don’t believe most people know just how much hard work that gets put into making a blog. I realize this is sort of random nevertheless it bothers me sometimes. Anyhow very good blog site.

Leave a Reply

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

You are commenting using your 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: