Here’s how to retrieve the current domain:
1 2 | [reflection.assembly] ::loadwithpartialname( "System.DirectoryServices" ) [System.DirectoryServices.ActiveDirectory.Domain] ::GetComputerDomain() |
The result is a System.DirectoryServices.ActiveDirectory.Domain object:
1 2 3 4 5 6 7 8 9 | Forest : i.activesolution.se DomainControllers : {ACTIVESERVER101.i.activesolution.se, ACTIVESERVER102.i.activesolution.se} Children : {} DomainMode : Windows2008R2Domain Parent : PdcRoleOwner : ACTIVESERVER102.i.activesolution.se RidRoleOwner : ACTIVESERVER102.i.activesolution.se InfrastructureRoleOwner : ACTIVESERVER102.i.activesolution.se Name : i.activesolution.se |
/Emil