Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module ActiveDirectory
- #Set Name
- $Name = "Nick Young"
- # Create Password
- $password = "password" | ConvertTo-SecureString -asPlainText -Force
- # Set Username
- $username = "domainusername"
- # Create Credential
- $credential = New-Object System.Management.Automation.PSCredential($username,$password)
- $Server = "server.fqdn.com"
- $Domain1Account = @(Get-ADUser -Server $Server -Credential $credential -Filter {Name -eq $Name})
- # SHow Message
- Write-Host "Domain 1 Account" -forgroundcolor Yellow
- # Display Info
- if( $Domain1Account.count -lt 1 )
- {
- echo "No Account"
- }
- else
- {
- $Domain1Account | FT Name,UserPrincipalName
- $Domain1Account | Get-ADPrincipalGroupMembership -Server $Server | FT Name,distinguishedName
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement