Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cred = Get-Credential -Message "Please enter your DBS login and password" -User $env:USERNAME@ad.dbs.fr
- $username = $cred.username
- $password = $cred.GetNetworkCredential().password
- $de = New-Object System.DirectoryServices.DirectoryEntry("LDAP://ad.dbs.fr", $username, $password)
- $login = $env:USERNAME
- $Rech = new-object System.DirectoryServices.DirectorySearcher($de)
- $rc = $Rech.filter = "((sAMAccountName=$login))"
- $rc = $Rech.SearchScope = "subtree"
- $rc = $Rech.PropertiesToLoad.Add("mail");
- $theUser = $Rech.FindOne()
- if ($theUser -ne $null)
- {
- Write-Host $theUser.Properties["mail"]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement