Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkPass($username, $password){
- # Get current domain using logged-on user's credentials
- $CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
- $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
- if ($domain.name -eq $null)
- {
- write-host "---- $($username): Authentication failed - please verify your username and password."
- # exit #terminate the script.
- }
- else
- {
- write-host "+++++ $($username): Successfully authenticated with domain $($domain.name)"
- }
- }
- get-spmanagedaccount | % { $_.UserName } | % { checkPass $_ xxxx }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement