Get-ADUserAccount


posted by Richard Giles
10-06-2008

Downloads: 471
File size: 1.3kB
Views: 1,734

Embed
Get-ADUserAccount
  1. ## ===================================================================== 
  2. ## Title       : Get-ADUserAccount 
  3. ## Description : Get and List Active Directory User Account Properties 
  4. ## Author      : Idera 
  5. ## Date        : 9/22/2008 
  6. ## Input       : -server  
  7. ##               -domain 
  8. ##               -ou 
  9. ##               -user 
  10. ##               -verbose  
  11. ##               -debug    
  12. ## Output      :  
  13. ## Usage       : PS> . Get-ADUserAccount -server localhost:389 -domain Idera -ou sales -user Joe Smith -v -d 
  14. ## Notes       : Adapted from Windows PowerShell Cookbook, Lee Holmes 
  15. ## Tag         : PowerShell, AD 
  16. ## Change log  : 
  17. ## ===================================================================== 
  18.  
  19. param 
  20.    [string]$server = "localhost:389"
  21.    [string]$domain = "Idera"
  22.    [string]$ou = "sales"
  23.    [string]$user = "Joe Smith"
  24.    [switch]$verbose
  25.    [switch]$debug 
  26.  
  27. function main() 
  28.     if ($verbose) {$VerbosePreference = "Continue"
  29.     if ($debug) {$DebugPreference = "Continue"
  30.     Get-ADUserAccount $server $domain $ou $user 
  31.  
  32. function Get-ADUserAccount($server,$domain,$ou,$user
  33.     trap [Exception]  
  34.         write-error $("TRAPPED: " + $_.Exception.Message); 
  35.         continue
  36.     
  37.  
  38.     $userObj = [adsi]"LDAP://$server/cn=$user,ou=$ou,dc=$domain,dc=COM" 
  39.    $userObj | Format-List * 
  40.  
  41. main 
Filed under: ,

Get properties of an Active Directory user account

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.