Last active
February 16, 2024 00:40
-
-
Save ScriptingPro/f8adffbbeef35347c6e5a5644d503633 to your computer and use it in GitHub Desktop.
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
# directoryentry (connect to specific dc:port) | |
$de = ([ADSI]"LDAP://$($ADDomainController.HostName):$($ADDomainController.LdapPort)") | |
# directorysearcher | |
$ds = New-Object System.DirectoryServices.DirectorySearcher($de,"(objectclass=user)") | |
$ds.PageSize=1000 | |
# invoke | |
$ds.FindAll() | %{"do stuff with $_"} | |
$thisuser = $ds.FindOne() | |
$thisuserde = $thisuser.GetDirectoryEntry() | |
# Invoke get property | |
($([ADSI]"LDAP://$($adsiref.distinguishedName)").Invoke("get","name")) | |
# example get pwdlastset from user directoryentry | |
[datetime]::FromFileTime($thisuserde.ConvertLargeIntegerToInt64($thisuserde.pwdLastSet[0])) | |
# example get pwdlastset from user searchresult | |
[datetime]::FromFileTime($($thisuser.Properties["pwdlastset"])) | |
# List RootDSE DirectoryEntry properties | |
[ADSI]"LDAP://RootDSE" | fl * | |
# Get configurationNamingContext | |
([ADSI]"LDAP://RootDSE").configurationNamingContext | |
([ADSI]"LDAP://RootDSE").get("configurationNamingContext") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment