Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell script to run dcdiag against all DCs in domain

Posted on 2013-01-30
9
Medium Priority
?
3,626 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
New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

 
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 41

Accepted Solution

by:
footech earned 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
Screencast - Getting to Know the Pipeline

886 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