Posts RSS Comments RSS 249 Posts and 391 Comments till now

blog: Discovery options with R2 AD Cmdlets

Last week I talked about how to "discover" information using the built in .NET classes for ActiveDirectory. This week I would like to show how you can do similar things with the ActiveDirectory cmdlets that ship with Win7 and R2.

The first task we discussed was getting Forest information like Domains, Sites, ForestMode, RootDomain, and Forest masters.

With .NET we do this
  1. $Forest = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
With the cmdlets we do this
  1. $Forest = Get-ADForest

Next we discussed getting Domain information like Domain Controllers, DomainMode, Domain Masters, and Forest Root.
  1. $Domain = [DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
With the cmdlets we do this
  1. $Domain = Get-ADDomain

Now the object we get back is slightly different so lets take a look

First lets look at what $Forest has to offer
  1. PS C:UsersAdministrator> $Forest
  2.  
  3. ApplicationPartitions : {}
  4. CrossForestReferences : {}
  5. DomainNamingMaster : Win2K8R2DC1.R2.Dev.Lab
  6. Domains : {R2.Dev.Lab}
  7. ForestMode : Windows2008R2Forest
  8. GlobalCatalogs : {Win2K8R2DC1.R2.Dev.Lab}
  9. Name : R2.Dev.Lab
  10. PartitionsContainer : CN=Partitions,CN=Configuration,DC=R2,DC=Dev,DC=Lab
  11. PSShowComputerName : {}
  12. RootDomain : R2.Dev.Lab
  13. SchemaMaster : Win2K8R2DC1.R2.Dev.Lab
  14. Sites : {Default-First-Site-Name}
  15. SPNSuffixes : {}
  16. UPNSuffixes : {}
  17. WriteErrorStream : {}

Finally, Lets look at $Domain
  1. PS C:UsersAdministrator> $domain
  2.  
  3. AllowedDNSSuffixes : {}
  4. ChildDomains : {}
  5. ComputersContainer : CN=Computers,DC=R2,DC=Dev,DC=Lab
  6. DeletedObjectsContainer : CN=Deleted Objects,DC=R2,DC=Dev,DC=Lab
  7. DistinguishedName : DC=R2,DC=Dev,DC=Lab
  8. DNSRoot : R2.Dev.Lab
  9. DomainControllersContainer : OU=Domain Controllers,DC=R2,DC=Dev,DC=Lab
  10. DomainMode : Windows2008R2Domain
  11. DomainSID : S-1-5-21-4244231903-4101880959-1987002231
  12. ForeignSecurityPrincipalsContainer : CN=ForeignSecurityPrincipals,DC=R2,DC=Dev,DC=Lab
  13. Forest : R2.Dev.Lab
  14. InfrastructureMaster : Win2K8R2DC1.R2.Dev.Lab
  15. LastLogonReplicationInterval :
  16. LinkedGroupPolicyObjects : {CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=R2,DC=Dev,DC=Lab}
  17. LostAndFoundContainer : CN=LostAndFound,DC=R2,DC=Dev,DC=Lab
  18. ManagedBy :
  19. Name : R2
  20. NetBIOSName : R2
  21. ObjectClass : domainDNS
  22. ObjectGUID : c2d8e67d-2a49-4352-a795-de2b6508b1dc
  23. ParentDomain :
  24. PDCEmulator : Win2K8R2DC1.R2.Dev.Lab
  25. QuotasContainer : CN=NTDS Quotas,DC=R2,DC=Dev,DC=Lab
  26. ReadOnlyReplicaDirectoryServers : {}
  27. ReplicaDirectoryServers : {Win2K8R2DC1.R2.Dev.Lab}
  28. RIDMaster : Win2K8R2DC1.R2.Dev.Lab
  29. SubordinateReferences : {CN=Configuration,DC=R2,DC=Dev,DC=Lab}
  30. SystemsContainer : CN=System,DC=R2,DC=Dev,DC=Lab
  31. UsersContainer : CN=Users,DC=R2,DC=Dev,DC=Lab

Here are some more specific examples on how to use these variables:

To see the forest roles
  1. $forest | select SchemaMaster,DomainNamingMaster
To see the domain roles
  1. $domain | select PDCEmulator,RIDMaster,InfrastructureMaster
To see what application partitions your forest has
  1. $forest.ApplicationPartitions

NOTE: you can use this command to see all the AD Cmdlets have to offer
  1. get-command -Module ActiveDirectory

Trackback this post | Feed on Comments to this post

Leave a Reply