Quantcast
Channel: Microsoft – JeffOps
Viewing all articles
Browse latest Browse all 120

PowerShell oneliners to get information about your Active Directory infrastructure

$
0
0

Some time ago I was asked to write a script which does an inventory of an active directory, such as finding all domain controllers, all global catalog servers, all sites/subnets, etc…
I will not be posting the entire script, instead I’ve chosen to offer you some oneliners which accomplish parts of it.

The first one is to get the Active Directory forest mode:

Get-ADForest | Select-Object -ExpandProperty ForestMode

The second one is to get the Active Directory domain mode:

Get-ADDomain | Select-Object -ExpandProperty ForestMode

The third one is to find all Domain Controllers (specific: their names), which can be done with a single PowerShell cmdlet:

Get-ADDomainController

The next one is to find all Global Catalog servers. You can do this by using the Get-ADDomainController, added by a filter:

Get-ADDomainController -Filter {IsGlobalCatalog -eq $true}

And to find all Read-Only Domain Controllers (RODC) you can do this the same way but with a different property:

Get-ADDomainController -Filter {IsReadOnly -eq $true}

And last has to do with Active Directory replication. To find all automatic created connections:

Get-ADReplicationConnection -Filter {AutoGenerated -eq $true}

AD Replication is very smart, but still people want to try and be smarter by creating manual connections for the replication.
So, to find the connections that someone may have created manually:

Get-ADReplicationConnection -Filter {AutoGenerated -eq $false}

I hope that you find the above useful :-)

Post to Twitter


Viewing all articles
Browse latest Browse all 120

Trending Articles