Solved

Powershell script to run dcdiag against all DCs in domain

Posted on 2013-01-30
9
2,438 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 16

Expert Comment

by:kmslogic
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:infradatel
Comment Utility
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 39

Accepted Solution

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

Open in new window

0
 

Author Comment

by:infradatel
Comment Utility
Thanks will give it a whirl tomorrow
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
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
Comment Utility
That worked perfrectly thanks very much
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A procedure for exporting installed hotfix details of remote computers using powershell
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now