Get-ADOU


posted by Richard Giles
10-06-2008

Downloads: 428
File size: 1.2kB
Views: 2,196

Embed
Get-ADOU
  1. ## ===================================================================== 
  2. ## Title       : Get-ADContainerChildren 
  3. ## Description : Get Active Directory Organizational Unit Children 
  4. ## Author      : Idera 
  5. ## Date        : 9/22/2008 
  6. ## Input       : -server  
  7. ##               -domain 
  8. ##               -OU 
  9. ##               -verbose  
  10. ##               -debug    
  11. ## Output      :  
  12. ## Usage       : PS> . Get-OU -server localhost:389 -domain Idera 
  13. ##                               -OU sales -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. [switch]$verbose
  24. [switch]$debug 
  25.  
  26. function main() 
  27.     if ($verbose) {$VerbosePreference = "Continue"
  28.     if ($debug) {$DebugPreference = "Continue"
  29.     Get-OU $server $domain $OU 
  30.  
  31. function Get-OU($server,$domain,$OU
  32.     trap [Exception]  
  33.         write-error $("TRAPPED: " + $_.Exception.Message); 
  34.         continue
  35.     
  36.  
  37.     $OrgUnit = [adsi]"LDAP://$server/ou=$OU,dc=$domain,dc=COM" 
  38.    $OrgUnit.PsBase.Children 
  39.  
  40. main 
Filed under: ,

Get properties of an Active Directory Organizational Unit

Copyright 2012 PowerShell.com. All rights reserved.