Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cred = Get-Credential #Read credentials
- $username = $cred.username
- $password = $cred.GetNetworkCredential().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 "Authentication failed - please verify your username and password."
- }
- else
- {
- write-host "Successfully authenticated with domain $($domain.name)"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement