Solved

Powershell script to run dcdiag against all DCs in domain

Posted on 2013-01-30
9
2,643 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 39

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 brief introduction to what I consider to be the best editor for 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 configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

815 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

11 Experts available now in Live!

Get 1:1 Help Now