Solved

Powershell script to run dcdiag against all DCs in domain

Posted on 2013-01-30
9
2,892 Views
Last Modified: 2013-01-31
Hello,

Hopefully this is a nice quick and easy answer, I am trying to wirte a script that will run a dcdiag against all DCs in my domain.

DCDiag /a only runs the dcdiag against all DCs in my site, but I have multiple sites

DCDiag /e runs dcdiag against all DCs in the Enterprise, the problem is that my domain is a child domain, and this test runs against every DC in the Entire Forest.

If I run a DCDiag /s:servername I can only pipe one server in per command.

Is there a way to run DCDiag against all DCs in my domain?
0
Comment
Question by:infradatel
9 Comments
 

Author Comment

by:infradatel
ID: 38834771
I tried this

Get-adDomainController -Filter * | ForEach-Object {DCDiag}

Open in new window


Which does return results, but only result for the local domain controller I am running the script from, its weird because it returns the same amount of time as there are DCs

EG -
 
Get-adDomainController -Filter *

Open in new window

Returns 12 Domain Controllers:

So what I run the script it gives me the results for the local domain controller 12 times, instead and runnign the DCDiag against each DC.
0
 
LVL 16

Expert Comment

by:kmslogic
ID: 38834818
I'm not familiar with the specifics of these cmdlets, but it seems to me that inside the {} of ForEach-Object you're going to need to specify the specific  information of the domain controller to it, for example

Get-adDomainController -Filter * | ForEach-Object {DCDiag /s:$_.Name}

I'm not sure Name is the right property
0
 

Author Comment

by:infradatel
ID: 38834851
Thanks for you reply

Hhhmm closer I think but I dont think powershell likes the $ straight after /s:

As I get this error

The host Microsoft.ActiveDirectory.Management.ADDomainController.HostName could not be resolved to an
IP address.  Check the DNS server, DHCP, server name, etc

Open in new window


It looks to me like it is trying to run a DCDiag against a erver called $_.Name
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 16

Expert Comment

by:kmslogic
ID: 38834871
Well you can see if it's expanding that correctly like

Get-adDomainController -Filter * | ForEach-Object {Write-Host $_.Name; DCDiag /s:$_.Name}

but again I don't have the cmdlets for active directory to know if name is the right property

If you do Get-adDomainController - Filter * | ft -Autosize

the column names should give you a clue
0
 

Author Comment

by:infradatel
ID: 38834905
Thanks again

Name will bring up the server name so I think that is correct what I dont think it likes is

/s:$

If I type that in the Powershell ISE it sees it as one long string rather than 2 seperate things.

Using your command above the host name is wrote to the screen but I get the same error

The host Microsoft.ActiveDirectory.Management.ADDomainController.Name could not be resolved to an
IP address.  Check the DNS server, DHCP, server name, etc

Open in new window


Because I think it still doesnt like /s:$_.Name
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 38835945
Try
Get-ADDomainController -Filter * | ForEach-Object {DCDiag /s:$($_.Name)}

Open in new window

0
 

Author Comment

by:infradatel
ID: 38836454
Thanks will give it a whirl tomorrow
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38838491
If you are interested, you can try this script from Script gallery..
Domain Controller Health script remotely
http://gallery.technet.microsoft.com/scriptcenter/Domain-Controller-Health-b6f0b0ec
0
 

Author Closing Comment

by:infradatel
ID: 38838758
That worked perfrectly thanks very much
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

A safe way to clean winsxs folder from your windows server 2008 R2 editions
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

740 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