Last active
February 16, 2024 00:42
-
-
Save ScriptingPro/cd8faed797d53ace48242f0c4f4b08c4 to your computer and use it in GitHub Desktop.
Query Active Directory without ActiveDirectory Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get dnsroot | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name | |
#get domain distinguishedname | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry().Properties["distinguishedName"] | |
#list domain controllers | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().FindAllDomainControllers().Name | |
#get PDC | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().pdcroleowner.GetDirectoryEntry().CN | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().PdcRoleOwner.Name | |
(Get-ADDomain).PDCEmulator | |
#Get current user's domain id | |
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry().name.toupper() | |
#get dns domain name from network information | |
[System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment