Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. $cred = Get-Credential #Read credentials
  2. $username = $cred.username
  3. $password = $cred.GetNetworkCredential().password
  4.  
  5. # Get current domain using logged-on user's credentials
  6. $CurrentDomain = "LDAP://hillsborough.k12.nj.us"
  7. $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
  8.  
  9. if ($domain.name -eq $null)
  10. {
  11. write-host "Authentication failed - please verify your username and password."
  12. exit #terminate the script.
  13. }
  14. else
  15. {
  16. write-host "Successfully authenticated with domain."
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement