Set-ADOUProperty


posted by Richard Giles
10-06-2008

Downloads: 327
File size: 1.4kB
Views: 1,058

Embed
Set-ADOUProperty
  1. ## ===================================================================== 
  2. ## Title       : Set-OUProperty 
  3. ## Description : Set Active Directory Organizational Unit Property 
  4. ## Author      : Idera 
  5. ## Date        : 9/22/2008 
  6. ## Input       : -server  
  7. ##               -domain 
  8. ##               -OU 
  9. ##                      -property 
  10. ##                      -value 
  11. ##               -verbose  
  12. ##               -debug    
  13. ## Output      :  
  14. ## Usage       : PS> . Set-OUProperty -server localhost:389 -domain Idera 
  15. ##                               -OU sales -property Description -value SalesHQ -v -d 
  16. ## Notes       : Adapted from Windows PowerShell Cookbook, Lee Holmes 
  17. ## Tag         : PowerShell, AD 
  18. ## Change log  : 
  19. ## ===================================================================== 
  20.  
  21. param 
  22.    [string]$server = "localhost:389"
  23.    [string]$domain = "Idera"
  24.    [string]$OU = "sales"
  25.    [string]$property="Description"
  26.    [string]$value="SalesHQ"
  27.    [switch]$verbose
  28.    [switch]$debug 
  29.  
  30. function main() 
  31.     if ($verbose) {$VerbosePreference = "Continue"
  32.     if ($debug) {$DebugPreference = "Continue"
  33.     Set-OUProperty $server $domain $OU $Property $Value 
  34.  
  35. function Set-OUProperty($server,$domain,$OU,$property,$value
  36.     trap [Exception]  
  37.         write-error $("TRAPPED: " + $_.Exception.Message); 
  38.         continue 
  39.     
  40.  
  41.     $OrgUnit = [adsi]"LDAP://$server/ou=$OU,dc=$domain,dc=COM" 
  42.    $OrgUnit.Put($property, $value
  43.     $OrgUnit.SetInfo() 
  44.  
  45. main 
Filed under: ,

Get properties of an Active Directory Organizational Unit

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