Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script to run dcdiag against all DCs in domain

Posted on 2013-01-30
9
Medium Priority
?
3,441 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
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 …

688 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