Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Import-Module ActiveDirectory
  2.  
  3. #Set Name
  4. $Name = "Nick Young"
  5.  
  6. # Create Password
  7. $password = "password" | ConvertTo-SecureString -asPlainText -Force
  8.  
  9. # Set Username
  10. $username = "domainusername"
  11.  
  12. # Create Credential
  13. $credential = New-Object System.Management.Automation.PSCredential($username,$password)
  14.  
  15. $Server = "server.fqdn.com"
  16.  
  17. $Domain1Account = @(Get-ADUser -Server $Server -Credential $credential -Filter {Name -eq $Name})
  18.  
  19. # SHow Message
  20. Write-Host "Domain 1 Account" -forgroundcolor Yellow
  21.  
  22. # Display Info
  23. if( $Domain1Account.count -lt 1 )
  24. {
  25. echo "No Account"
  26. }
  27. else
  28. {
  29. $Domain1Account | FT Name,UserPrincipalName
  30. $Domain1Account | Get-ADPrincipalGroupMembership -Server $Server | FT Name,distinguishedName
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement