OU Selector

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
Jcholder
Posts: 7
Last visit: Sun Mar 18, 2018 7:09 pm

OU Selector

Post by Jcholder »

I am using the following code to create an AD tree structure so the user is able to select an OU within that tree and populate a text box (list of computer names). It works, however in an organization with a large AD structure it times out because it takes too long to load everything. I'm not sure if it is trying to pre-populate every object in the tree or not.

What I ultimately want is to build only the tree first, not query any objects in the OU until the user selects a particular OU, then query only that OU for all the objects (computers) contained within it. But I am unsure how to go about doing that, any help is appreciated.
  1. $OU = Choose-ADOrganizationalUnit
  2.     Try
  3.     {
  4.         $AdComputers = Get-ADComputer -LDAPFilter "(name=*)" -SearchBase $ou | Select-Object name, enabled, DNSHostName
  5.         $AD_computers = New-Object System.Collections.ArrayList
  6.         Foreach ($item in $AdComputers)
  7.         {
  8.             If (($item.enabled) -and ($item.DNSHostName -ne $null))
  9.             {
  10.                 $WSUS_Computers.AppendText("$($item.DNSHostName)`n")
  11.                
  12.             }
  13.         }
  14.     }
  15.     catch
  16.     {
  17.         Write-Debug ($_ | Out-String)
  18.         $WSUS_Computers.Text = "No computers found in OU"
  19.     }
  1. function Choose-ADOrganizationalUnit
  2. {
  3.     #========================================================================
  4.     # Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.24
  5.     # Generated On: 29-10-2013 13:45
  6.     # Generated By: Michaja van der Zouwen
  7.     # Organization: -
  8.     #========================================================================
  9.     #----------------------------------------------
  10.     #region Application Functions
  11.     #----------------------------------------------
  12.    
  13.     function OnApplicationLoad
  14.     {
  15.         #Note: This function is not called in Projects
  16.         #Note: This function runs before the form is created
  17.         #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
  18.         #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
  19.         #Important: Form controls cannot be accessed in this function
  20.         #TODO: Add snapins and custom code to validate the application load
  21.        
  22.         return $true #return true for success or false for failure
  23.     }
  24.    
  25.     function OnApplicationExit
  26.     {
  27.         #Note: This function is not called in Projects
  28.         #Note: This function runs after the form is closed
  29.         #TODO: Add custom code to clean up and unload snapins when the application exits
  30.        
  31.         $script:ExitCode = 0 #Set the exit code for the Packager
  32.     }
  33.    
  34.     #endregion Application Functions
  35.    
  36.     #----------------------------------------------
  37.     # Generated Form Function
  38.     #----------------------------------------------
  39.     function Call-AD_OU_select_pff
  40.     {
  41.        
  42.         #----------------------------------------------
  43.         #region Import the Assemblies
  44.         #----------------------------------------------
  45.         [void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  46.         [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  47.         [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  48.         [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  49.         [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  50.         [void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  51.         [void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  52.         [void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
  53.         [void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  54.         #endregion Import Assemblies
  55.        
  56.         #----------------------------------------------
  57.         #region Generated Form Objects
  58.         #----------------------------------------------
  59.         [System.Windows.Forms.Application]::EnableVisualStyles()
  60.         $formChooseOU = New-Object 'System.Windows.Forms.Form'
  61.         $treeview1 = New-Object 'System.Windows.Forms.TreeView'
  62.         $buttonOK = New-Object 'System.Windows.Forms.Button'
  63.         $ButtonCancel = New-Object 'System.Windows.Forms.Button'
  64.         $imagelist1 = New-Object 'System.Windows.Forms.ImageList'
  65.         $ErrorProviderOU = New-Object 'System.Windows.Forms.ErrorProvider'
  66.         $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
  67.         #endregion Generated Form Objects
  68.        
  69.         #----------------------------------------------
  70.         # User Generated Script
  71.         #----------------------------------------------
  72.        
  73.         function Add-Node
  74.         {
  75.             param (
  76.                 $selectedNode,
  77.                 $dname,
  78.                 $name,
  79.                 $ou
  80.             )
  81.             $newNode = new-object System.Windows.Forms.TreeNode
  82.             $newNode.Name = $dname
  83.             $newNode.Text = $name
  84.             IF ($ou -eq $false)
  85.             {
  86.                 $newnode.ImageIndex = 1
  87.                 $newNode.SelectedImageIndex = 1
  88.             }
  89.             $selectedNode.Nodes.Add($newNode) | Out-Null
  90.             If ($dname -eq $strDomainDN)
  91.             {
  92.                 $newNode.ImageIndex = 2
  93.                 $newNode.SelectedImageIndex = 2
  94.             }
  95.             return $newNode
  96.         }
  97.        
  98.         function Get-NextLevel
  99.         {
  100.             param (
  101.                 $selectedNode,
  102.                 $dn,
  103.                 $name,
  104.                 $OU
  105.             )
  106.            
  107.             $OUs = Get-ADObject -Filter 'ObjectClass -eq "organizationalUnit" -or ObjectClass -eq "container"' -SearchScope OneLevel -SearchBase $dn
  108.            
  109.             If ($OUs -eq $null)
  110.             {
  111.                 $node = Add-Node $selectedNode $dn $name $OU
  112.             }
  113.             Else
  114.             {
  115.                 $node = Add-Node $selectedNode $dn $name $OU
  116.                
  117.                 $OUs | ForEach-Object {
  118.                     If ($_.ObjectClass -eq "organizationalUnit")
  119.                     {
  120.                         $OU = $true
  121.                     }
  122.                     else
  123.                     {
  124.                         $OU = $false
  125.                     }
  126.                     Get-NextLevel $node $_.distinguishedName $_.name $OU
  127.                 }
  128.             }
  129.         }
  130.        
  131.         function Build-TreeView
  132.         {
  133.             if ($treeNodes)
  134.             {
  135.                 $treeview1.Nodes.remove($treeNodes)
  136.                 $formChooseOU.Refresh()
  137.             }
  138.            
  139.             $treeNodes = $treeview1.Nodes[0]
  140.            
  141.             #Generate Module nodes
  142.             Get-NextLevel $treeNodes $strDomainDN $strDNSDomain
  143.            
  144.             $treeNodes.Expand()
  145.             $treeNodes.FirstNode.Expand()
  146.         }
  147.        
  148.         $treeView1.add_AfterSelect({
  149.                 $script:SelectedOU = $this.SelectedNode
  150.             })
  151.        
  152.         $FormEvent_Load = {
  153.             Import-Module ActiveDirectory
  154.             $objIPProperties = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
  155.             $strDNSDomain = $objIPProperties.DomainName.toLower()
  156.             $strDomainDN = $strDNSDomain.toString().split('.'); foreach ($strVal in $strDomainDN) { $strTemp += "dc=$strVal," }; $strDomainDN = $strTemp.TrimEnd(",").toLower()
  157.             Build-TreeView
  158.         }
  159.        
  160.        
  161.        
  162.         $buttonOK_Click = {
  163.             $script:objSelectedOU = Get-ADObject -Identity $SelectedOU.name
  164.            
  165.         }
  166.         $ButtonCancel_Click = {
  167.             $script:SelectedOU = $null
  168.             $FormOU.close()
  169.         }
  170.        
  171.         # --End User Generated Script--
  172.         #----------------------------------------------
  173.         #region Generated Events
  174.         #----------------------------------------------
  175.        
  176.         $Form_StateCorrection_Load =
  177.         {
  178.             #Correct the initial state of the form to prevent the .Net maximized form issue
  179.             $formChooseOU.WindowState = $InitialFormWindowState
  180.         }
  181.        
  182.         $Form_Cleanup_FormClosed =
  183.         {
  184.             #Remove all event handlers from the controls
  185.             try
  186.             {
  187.                 $treeview1.remove_AfterLabelEdit($CreateOU)
  188.                 $buttonOK.remove_Click($buttonOK_Click)
  189.                 $formChooseOU.remove_Load($FormEvent_Load)
  190.                 $formChooseOU.remove_Load($Form_StateCorrection_Load)
  191.                 $formChooseOU.remove_FormClosed($Form_Cleanup_FormClosed)
  192.             }
  193.             catch [Exception]
  194.             { }
  195.         }
  196.         #endregion Generated Events
  197.        
  198.         #----------------------------------------------
  199.         #region Generated Form Code
  200.         #----------------------------------------------
  201.         #
  202.         # formChooseOU
  203.         #
  204.         $formChooseOU.Controls.Add($treeview1)
  205.         $formChooseOU.Controls.Add($buttonOK)
  206.         $formChooseOU.AcceptButton = $buttonOK
  207.         $formChooseOU.ClientSize = '342, 502'
  208.         $formChooseOU.FormBorderStyle = 'FixedDialog'
  209.         #region Binary Data
  210.         $formChooseOU.Icon = [System.Convert]::FromBase64String('
  211.    AAABAAkAICAQAAEABADoAgAAlgAAABgYEAABAAQA6AEAAH4DAAAQEBAAAQAEACgBAABmBQAAICAA
  212.    AAEACACoCAAAjgYAABgYAAABAAgAyAYAADYPAAAQEAAAAQAIAGgFAAD+FQAAICAAAAEAIACoEAAA
  213.    ZhsAABgYAAABACAAiAkAAA4sAAAQEAAAAQAgAGgEAACWNQAAKAAAACAAAABAAAAAAQAEAAAAAAAA
  214.    AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICAAACAgIAAwMDAAAAA
  215.    /wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  216.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  217.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  218.    AAAAAAAAiIAAAAAAAAAAAAAAAACIiIiHMAAAAAAAAAAAAAiI//iIiHcAAAAAAAAAAIiP//+IiIiH
  219.    dwAAAAAAiI//////iIiIiHhwAAAAAIj///////iIiIiHeHAAAACIj////4iIiIiIiIiHgAAAiIj/
  220.    iIiIiIj/iIiHeIcAAIiIiIiIiIiIiP+IiIeIcACIiHd3d3d3eIeI+IiHeIhwczMRMzd3czeIeI/4
  221.    iIiIcAczN3iIiIczeId4j4iHiHAACIiP///4i7OIh4iPiHiAAAAIiI//iIu7M4h3iP+HcAAAAAiI
  222.    iIi7u7u3iHiIiHAAAAAACIeP///4i7iHeIgAAAAAAAAAiI+IiLu7t3AAAAAAAAAAAACDMzMzMzM3
  223.    AAAAAAAAAAAAAAAAAAAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  224.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////////////////////////
  225.    ///////8f///wB///gAP//AAA/8AAAH/AAAAfwAAAB8AAAAPAAAABwAAAAEAAAABgAAAAeAAAAH4
  226.    AAAB/gAAAf+AAAP/8AAf//wAD////+f/////////////////////KAAAABgAAAAwAAAAAQAEAAAA
  227.    AAAgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICAAACAgIAAwMDA
  228.    AAAA/wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  229.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIiIAAAAAAAA
  230.    AAAIiIiIcAAAAAAAAIiI/4iIhwAAAAAIiP//+IiIh3gAAACI/////4iHiHeAAACIj//4iIiIeIiI
  231.    AACIiIiIiIiPiIh4iACIiId4iIiI+IiHiHCHczMzd3eIiPiHeIeDAzd4h3M3iI+Id4gAiIj//4iz
  232.    eIiPh4gAAIiIiIu7M3iIiHcAAACIiIiIizeIiIcAAAAAiI//iLt3gAAAAAAAAIhzMzMzMAAAAAAA
  233.    AAAAAAAAdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD/
  234.    w/8A/gH/APAA/wCAAD8AAAAfAAAADwAAAAMAAAABAAAAAAAAAAAAwAAAAPAAAAD8AAAA/wAHAP/A
  235.    BwD///MA////AP///wAoAAAAEAAAACAAAAABAAQAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  236.    AAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA
  237.    ////AAAzMzMzMzMAAHd3d3MzMwAAd3d3czMzAACPiIiIiIMAAI+IiIiIgwAAj4iIiIiDAACPiIiI
  238.    iIMAAI+IiIiIgwAAj4iIh3eDAACPj///94MAAI+P///3gwAAj4////eDAACPiIiId4MAAHd3d3Mz
  239.    MwAAd3d3d3d3AAAAAAAAAAAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMA
  240.    AMADAADAAwAAwAMAAMADAADAAwAA//8AACgAAAAgAAAAQAAAAAEACAAAAAAAAAQAAAAAAAAAAAAA
  241.    AAEAAAABAAAAAAAAEj1BABlFSgAZSlIAIUpNAC5dXgAwV1kAMWRtAD9jaQA8aXoAVWttAFhpaQBK
  242.    bnQATH5/AF16ewAAaZMACmuTAAl0mgA/eIIAHXqgACp+owBNd4EAS32LAGF9gAAShJgALouZADyG
  243.    mQAKh6kAE4ujACWNqAA/jaMAMourAC6SrgAumbIAOJayAEmDjABEgpMAS4eQAFCHkABSiZIAVZOd
  244.    AFmUngBhh4kAaIeMAGmMjQBnlZsAaZmbAHWUkwB7lJMAcJyfAHWdnwBQkKQAX5ujAEKfugBqnaEA
  245.    UKK7AF2puwBpoaUAYqSqAGmlqQBvqq4AfaOsAHWprQB4q68Aaqm4AGqtvQB0rrIAea6xAHKxtgB5
  246.    s7cAdbS4AHy1uQBzu74Adbm+AH64vAAXo8kAAKbUABSy1QAdtdkAHrvbACGjyQA4uM4ALL3eABi7
  247.    4ABdssEATLbQAGOqwABmqsAAZq/AAGGtxQBqrcIAbrDBAHW8wQB5u8EAf73CAHy0yAB4v8oAZLfQ
  248.    ADrB3wAp0t8APNDaAD7N5wA23OQAQsPfAEvO2AB5wcYAf8DEAHzCygBuw9YAdsTUAGPQ2QB92NwA
  249.    RsTgAE3J4QBH3OsAUtDqAF7b7QBh1ecAWPz/AH3k8QB7//8AgKmqAImtsQCCsrQAhLa9AI67uwCR
  250.    ubwAmMC+AIe+xgCLvMQAgrjKAJy/xgCQv8oAgL7SAIi90ACCwcYAi8PHAITFzACNxMgAi8PNAIjH
  251.    zACEys8AiMnOAJTAwQCXxsgAm8bIAJvIzACGzdIAhs3UAI7J0ACIzNAAjs3SAJjD0QCTyNQAh9DU
  252.    AIvQ0wCI0tYAjdHVAIvS2ACP1NoAjNnfAJHS1gCd09QAk9XZAJvV2gCT2NoAlNjaAJHY3ACU2NwA
  253.    os3ZALLO0gCk09YArNHTAK7W2QCs298AstPWALHV2wCO2uAAk9vgAJXb4ACV3OEAl9/kAJzd5ACq
  254.    0eAAq9XgAKLZ4wCg3+YAqN7hAKjY5ACu2uUAqdznALDT4QC11eMAs9nlAJng5ACd4ucAneTnAJ3h
  255.    6gCe5uoAn+fsAI/s8wCd8vsAm///AKrg5ACi5+wAquToAKzl6wCl6e4AtOPpALrk6wC26+4At+zu
  256.    ALzq7QCk6/AAquvwAKjt8QCx7fEAuO3wAKrw8gCq8PYArPL3AK319gCm8fgArvP4ALXw8wC28/YA
  257.    vfHzALvy9gC09foAs/r+ALz//wDI19wAw9zoAMHq7QDF6e8AwuzuAN7u7wDD7fAAxu3wAMju8ADC
  258.    8fMAx/HzAMjx8gDJ8vUAzPP2AM329gDP+PcAxff6AMP8/wDK/PwA2PD0ANH//wDY//8A6P//APL/
  259.    /wD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  260.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  261.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  262.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  263.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  264.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC3uW0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6MC3ztfa
  265.    pS0JAAAAAAAAAAAAAAAAAAAAAAAAAADAwdHu8u/Z19eTjHlBAAAAAAAAAAAAAAAAAAAAAMC96fL2
  266.    8vLu6dLX15OaoC8rWQAAAAAAAAAAAADAvb3u8vLy8vLy8u7p2Nfak5OcXjJ9WwAAAAAAAAAAAMXa
  267.    4fDy8vLy8vLy8uLXw7NIaZOeoBcwlVkAAAAAAAAAw9fX4fDw8vLy8tTLpZyew8WTXImeh0V7j0GG
  268.    AAAAAADD2tfa5OLS0L2koaXD19rf5eXFa1ycsQ4sooFZAAAAALna18WzpZyJaYeJiYeHh4eVz+Xk
  269.    pVxrlUdDjI9BAAAAw7OTazolIyYnJygpNDtCSkVCw9/l14lpjQs+nH98WgBBEgcDAQEEBggMFRYk
  270.    Gh44rZA5ic/l5bNpRkpHjo8/AAAnAwIFDS57kaytq4lUIRs1qa8+PKXa5dqcSApHnkQAAAAAgWCN
  271.    zvn7+/n45Ml3c05LYbB+NofM3+XFXkSHSAAAAAAAANBrgK739+TeyHd0ZVNMUIWqMjyl1+Xlnio7
  272.    AAAAAAAAAADQjHyk13d1cXBnYlJPTVWYejaHw9fapToAAAAAAAAAAAAA6YlZmfr+/v385sp4dnJs
  273.    g3lCiJKsAAAAAAAAAAAAAAAAAACJhOfs1MNvbmhkZmNRNz0AAAAAAAAAAAAAAAAAAAAAAAAAYBkY
  274.    HB0gIh8UExEPEDMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAX4IAAAAAAAAAAAAAAAAA
  275.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  276.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  277.    AAAAAP/////////////////////////////////////////////////8f///wB///gAP//AAA/8A
  278.    AAH/AAAAfwAAAB8AAAAPAAAABwAAAAEAAAABgAAAAeAAAAH4AAAB/gAAAf+AAAP/8AAf//wAD///
  279.    /+f/////////////////////KAAAABgAAAAwAAAAAQAIAAAAAABAAgAAAAAAAAAAAAAAAQAAAAEA
  280.    AAAAAAAKNjwAH0tOACFQVgAsWV8AIFdhAClcZAA4ZGwAQGxuAEBtdQARaIMAMnePAEJ0gQBFf4YA
  281.    QnuJAAuBnwAcgp0AH5CuADOMpAA5i6EAKJSvAC2arAAsmbEAIZu7ADuuvgBEgo8AXoqMAFCQmwBV
  282.    k5wAX5CfAF+WnABjhIUAYYeKAG2XmQBmmJsAeZaVAHaZmgBIl6cARp+rAEafrABYkKEAWZWlAGOZ
  283.    pwBgnqoAaKGnAGyqrwB/oKEAeqKlAHSnqwB7o6wAe6WvAHCorQB3q68Abq61AHajswBxqrIAdKyy
  284.    AHevtQByrrgAd6+8AG+yuQB9srYAcLO5AHO0ugB5tLkAeLu/AH64vQACmsUAErjdACi52gBur8AA
  285.    d7fDAHe9wgB3vsQAe7rAAHm9wwB8uMQAfL/GAHq5zAB6vtEAM8XOADzM5gA80uYAfsHFAH7DyAB8
  286.    wcwAf8TOAF/a6wBj2u4AaNnqAHra7QBV9PUAfebwAIyvsQCArr0AgLK2AIqxsgCJsrcAkLW6AJO4
  287.    vwCMvsAAlr7CAI7CwgCBxcoAh8fJAIPHzACKx8wAg8rOAIvKzwCMys0AmMLFAJ7GxQCRxMkAnsLM
  288.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AA
  301.    AAAAkXGBoK6kQh0AAAAAAAAAAAAAAAAAkI2UttHRtbuLQmYqAAAAAAAAAAAAjY2izNHW0dHLvMCL
  302.    QGsjOXYAAAAAAACewM/R0dHR0dHPqptCM1SEJC5PAAAAAAClwMXP0dHMs5NtaXybaTx5aT1gTAAA
  303.    AACqwLuvqIhzanybrrvDyZ4/SHkfZHBOAACqu5tMPzU1P0xTaX6LpcnDUz9rIV91RgBHHA0GAwQH
  304.    CQwOGRxfc4vAyYtIIjNtbzqSBQECCBouXWA5JRATMW98pMm4aS0ggkIAAHFUh7XR2dbGpllFFyli
  305.    cIe7yYssQEwAAAAAtpqhsL3CXFdRREMSMWVtnru4MB0AAAAAAACziISWmZiYWlhSGCtjhXx8bTkA
  306.    AAAAAAAAALB9ytrb2cCnW1AmOoEAAAAAAAAAAAAAAAAArFQmFRYWFBEPCgsAAAAAAAAAAAAAAAAA
  307.    AAAAAAAAAAAAADYpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  308.    AAAAAAD///8A////AP///wD///8A////AP///wD/w/8A/gH/APAA/wCAAD8AAAAfAAAADwAAAAMA
  309.    AAABAAAAAAAAAAAAwAAAAPAAAAD8AAAA/wAHAP/ABwD///MA////AP///wAoAAAAEAAAACAAAAAB
  310.    AAgAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAABfggAljaMALZClADaTpgA/l6gAQouhAEma
  311.    qgBTnqsAXKKtAGalrwBvqbEAeKyyADOixQBBrMsAQ63MAEWvzQBGsM4ASbLPAFC10QBZudMAW7zV
  312.    AGe/1wBowtkAdsXbAHfI3QBo0OYAcNPoAHnW6QCGzN8Ahc7kAIjP4QCC2usAjN3tAJnT4wCb1uUA
  313.    n9XlAKTY5wCq2+gAr93qAJbh7gCf5fAAqejyALLs9AC77/UAvP//AMX//wDP//8A2f//AOL//wDs
  314.    //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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Xam7/67W2/+Xxsj/aaGl/4XDyP+k6u7/sfj9/7L5
  379.    /v+V3OH/ecLH/3W0uP9/uLz/fLa7/4jJzv+SwML/d6uv/QAAACqCy9NpPHiA3hhKUf8ZRUr/Ll1e
  380.    /0x+f/9pmZv/g7K0/5vGyP+r0NL/rtbY/6TT1v+Hxs3/XbLB/y6Zsv8Kh6n/Qp+6/6LN2f+y09b/
  381.    dais/2+prv+U2Nz/qvD1/7X7//+r8vf/iNLW/3S6vv9Va23/fLW4/4/V2/9ur7X2AAAAKAAAAACm
  382.    7fMEh8zVZGeqtsJ5v8n/hsjP/6rk6P/J+vr/0P///9L////M/v//w/z//7T3/v+d8vv/f+bz/1LQ
  383.    6v8dtdn/F6PJ/2S30P+x1dv/kbm8/2icof+AwMT/oufs/671+P+1+///nufr/3m7wf9xsbb/hcLH
  384.    /3O3vPZNTU0qAAAAAAAAAAAAAAAAktbfAqLq9UyQ1d6tf8DL/4e+xv+s29//x/f5/8P3+/+38/n/
  385.    pvH4/4/s8/955fD/Xtvt/z7N5/8Yu+D/AKbU/yGjyf+AvtL/ss7S/3Ccn/9vq67/k9fa/6br8P+0
  386.    +f7/svz//4/U2P9hh4n/ZqSp+MHBwUEAAAAAAAAAAAAAAAAAAAAAAAAAAKvt8wKw8PUuktPeqIK+
  387.    yeuCtr3/ntXc/6Do8f9/4vD/YdXn/03J4f9GxOD/QsPf/zrB3/8svd7/Hrvb/xSy1f9MttD/mMPR
  388.    /4mtsf9snqH/gMLG/5rg5P+m7PH/rPX3/5PU2P9kpqv/x8fHHAAAAAAAAAAAAAAAAAAAAAAAAAAA
  389.    AAAAAAAAAAAAAAAAn+LtKI7U4YF4v8voZq/A/5PI1P/Y8PT/8v////P////o////2P///7z///+b
  390.    ////e////1j8//9H3Ov/bsPW/5y/xv9/p6r8b6qv83O3vNJorLKoY6mvhF+lq3MAAAAAAAAAAAAA
  391.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJLi7B6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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  405.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  406.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////
  407.    ////////////////////4B///4AP//AAA//AAAH/AAAAfwAAAD8AAAAPAAAABwAAAAEAAAAAAAAA
  408.    AAAAAACAAAAA4AAAAPgAAAD/AAAB/8AAB//4AAf//AAD/////////////////////ygAAAAYAAAA
  409.    MAAAAAEAIAAAAAAAYAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  410.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  411.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  412.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  413.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  414.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  415.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  416.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  417.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  418.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCcHgCQnB4BQAA
  419.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  420.    AAAAAAAAAAAAgbLNAYCyzRFzpLpLfLC/g4e+zNOBytXyIXGMkQBFbBMAAAAAAAAAAAAAAAAAAAAA
  421.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGuesySBr7xSe6m7mIe0wc6d
  422.    yND4pNzg/6ft7/+c4uX/fri9/ydpfbwUmMMxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  423.    AAAAAAAAQnB4CF+QozJmma1of628pY68ydCq1dz+v+nr/8zy8//K8PH/t+zv/6ru8/+R2N3/fri9
  424.    /47Cwv9Rjp3kE4OvYgB2rgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABso7R7erHAq5PBztey3OL0
  425.    xOzw/8/29//O+Pj/zPX1/8jw8v/E6+7/s+zw/6zy9v+U2t3/erS5/4PKzf95lpX/da60+jeavJ8A
  426.    dqoaAAAAAAAAAAAAAAAAAAAAAAAAAACZ2+X4rvDz/8T09f/O9/b/y/P2/8ry9f/J8vX/yvL1/8rw
  427.    8v/B8PL/p+fr/5fb4P94u7//cKit/37DyP+M193/dpma/3+gof9csMfPB4GwRAAAAAAAAAAAAAAA
  428.    AAAAAACf5Or+q/H0/7Lw9P/C8/T/yPP1/8zz9//G7/L/ueXo/6bW2/+Mys7/g8fM/4vO1P+W3OH/
  429.    gcXL/2+yuf+CytH/g8TJ/32ytv+KsbL/c7PA7iqUuH4gj7QJAAAAAAAAAACf4un6rfL1/6nv9P+q
  430.    7O//p+Hl/53U2P+Syc3/isfM/4zN0f+X3eD/pOrv/6nt8v+u8/n/tfz//5nf4/9ztLr/d73C/4TL
  431.    0P9jhIX/jL7A/5LEyf88mbWtAYCxKgAAAACl5uz6qO/z/5bd4/98v8b/cLO5/2+vtv9trrX/c7S7
  432.    /3m9w/9+wMT/h8fJ/5HP0f+U2dv/neTp/7X6/f+v9Pj/f8LH/3Czuv+Dy8//bZeZ/4Gztv+dycj/
  433.    WaS33hOIslF3t8P/VZOc/0V/hv8pXGT/IVBW/yxZX/84ZGz/QG11/0J0gf9Ce4n/RIKP/1CQm/+A
  434.    sbb/ls3O/5HY3P+s8fX/s/r+/5TZ3v93vsT/Zpib/3err/+Lys//nsbF/2qptPButL+fH1Zg/Qo2
  435.    PP8fS07/QGxu/16KjP96oqX/jK+x/4myt/9xqrL/SJen/xyCnf85i6H/e6Os/5jCxf+LzdL/m+Pn
  436.    /7L4/f+m6/H/gMbL/2yqr/9hh4r/jtDV/324vf2L1NsGkNXcOGWnsqd7ws32lNfd/7bq6//I9vb/
  437.    0////8r9//+49/z/mO73/2jZ6v8oudr/IZu7/1mVpf+Qtbr/kMXJ/5HV2v+o7/P/s/r+/5LY3P9o
  438.    oaf/eLS5/3a4vvUAAAAAAAAAAAAAAACj6vU+l97nppPT3u2q3eP/tubq/7nv9P+j8Pj/febw/1/a
  439.    6/88zOb/Erjd/wKaxf8zjKT/e6Wv/5a+wv+My8z/mN/k/6vv9P+k7PD/dKer/1+WnP8AAAAAAAAA
  440.    AAAAAAAAAAAAAAAAAKLk7EKQ0+GjltPc6Y/T3/+F1eL/itzq/4Ta6/+B2ev/etrt/2Pa7v880ub/
  441.    O66+/2Ceqv+TuL//ntDQ/o7O0f+MztP8g8XK6WCgp94AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  442.    AAAAj9jlPXzR4ZmFy9nvyuDm/+7x8v/3+/v/0/36/6339f+B8/P/VfT1/zPFzv9Gn6v/dq+8/WCq
  443.    uaNtr7NVZairOF6lqigAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+z98zcM3c
  444.    l3G8yOpGn6z/LZqs/x6Squ0SjqriDoem4wyHqOsHf576EWiD/xVkgN81i6RnAAAAAAAAAAAAAAAA
  445.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWc/fBUPD0zEgj6pmG4GkUxyBqTgm
  446.    kLYsIouzKxx5pzUTdaNGB2eRYBplgZgZZn65GXOUViWFpgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  447.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  448.    AB1DSAQdQ0gaHUNIGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  449.    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/
  450.    //8A////AP///wD///8A////AP/z/wD+Af8A+AD/AIAAPwAAAB8AAAAPAAAAAwAAAAEAAAAAAAAA
  451.    AAAAAAAAAAAAAOAAAAD4AAAA/gAAAP+AAwD/wAAA///xAP///wAoAAAAEAAAACAAAAABACAAAAAA
  452.    AEAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAX4L/AF+C/wBfgv8AX4L/AF+C/wBfgv8AX4L/
  453.    AF+C/wBfgv8AX4L/AF+C/wBfgv8AAAAAAAAAAAAAAAAAAAAAQouh/3issv9vqbH/ZqWv/1yirf9T
  454.    nqv/SZqq/z+XqP82k6b/LZCl/yWNo/8AX4L/AAAAAAAAAAAAAAAAAAAAAEKLof94rLL/b6mx/2al
  455.    r/9coq3/U56r/0maqv8/l6j/NpOm/y2Qpf8ljaP/AF+C/wAAAAAAAAAAAAAAAAAAAACFzuT/u+/1
  456.    /7Ls9P+p6PL/n+Xw/5bh7v+M3e3/gtrr/3nW6f9w0+j/aNDm/zOixf8AAAAAAAAAAAAAAAAAAAAA
  457.    hc7k/7vv9f+y7PT/qejy/5/l8P+W4e7/jN3t/4La6/951un/cNPo/2jQ5v8zosX/AAAAAAAAAAAA
  458.    AAAAAAAAAIXO5P+77/X/suz0/6no8v+f5fD/luHu/4zd7f+C2uv/edbp/3DT6P9o0Ob/M6LF/wAA
  459.    AAAAAAAAAAAAAAAAAACFzuT/u+/1/7Ls9P+p6PL/n+Xw/5bh7v+M3e3/gtrr/3nW6f9w0+j/aNDm
  460.    /zOixf8AAAAAAAAAAAAAAAAAAAAAhc7k/7vv9f+y7PT/qejy/5/l8P+W4e7/jN3t/4La6/951un/
  461.    cNPo/2jQ5v8zosX/AAAAAAAAAAAAAAAAAAAAAIXO5P+77/X/mdPj/4bM3/92xdv/Z7/X/1m50/9Q
  462.    tNH/R7DO/0Gsy/9o0Ob/M6LF/wAAAAAAAAAAAAAAAAAAAACFzuT/u+/1/5/V5f/s////4v///9n/
  463.    ///P////xf///7z///9Drcz/aNDm/zOixf8AAAAAAAAAAAAAAAAAAAAAhc7k/7vv9f+k2Of/7P//
  464.    /+L////Z////z////8X///+8////Ra/N/2jQ5v8zosX/AAAAAAAAAAAAAAAAAAAAAIXO5P+77/X/
  465.    qtvo/+z////i////2f///8/////F////vP///0awzv9o0Ob/M6LF/wAAAAAAAAAAAAAAAAAAAACF
  466.    zuT/u+/1/6/d6v+b1uX/iM/h/3fI3f9owtn/W7zV/1G20v9Jss//aNDm/zOixf8AAAAAAAAAAAAA
  467.    AAAAAAAAQouh/3issv9vqbH/ZqWv/1yirf9Tnqv/SZqq/z+XqP82k6b/LZCl/yWNo/8AX4L/AAAA
  468.    AAAAAAAAAAAAAAAAAEKLof9Ci6H/Qouh/0KLof9Ci6H/Qouh/0KLof9Ci6H/Qouh/0KLof9Ci6H/
  469.    Qouh/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  470.    AAAAAAAAAAAAAAAAAAAAAAAAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMADAADAAwAAwAMAAMAD
  471.    AADAAwAAwAMAAMADAADAAwAAwAMAAP//AAA=')
  472.         #endregion
  473.         $formChooseOU.MaximizeBox = $False
  474.         $formChooseOU.MinimizeBox = $False
  475.         $formChooseOU.Name = "formChooseOU"
  476.         $formChooseOU.StartPosition = 'CenterScreen'
  477.         $formChooseOU.Text = "Choose Active Directory OU"
  478.         $formChooseOU.add_Load($FormEvent_Load)
  479.         #
  480.         # buttonCancel
  481.         #
  482.         $ButtonCancel.text = "&Cancel"
  483.         $ButtonCancel.Location = '19,467'
  484.         $ButtonCancel.TabIndex = 2
  485.         $ButtonCancel.size = '75,23'
  486.         $ButtonCancel.Anchor = 'Bottom, Left'
  487.         $ButtonCancel.add_Click($ButtonCancel_Click)
  488.         #
  489.         # treeview1
  490.         #
  491.         $treeview1.ImageIndex = 0
  492.         $treeview1.ImageList = $imagelist1
  493.         $treeview1.Location = '19, 21'
  494.         $treeview1.Name = "treeview1"
  495.         $System_Windows_Forms_TreeNode_1 = New-Object 'System.Windows.Forms.TreeNode' ("Active Directory Hierarchy", 3, 3)
  496.         $System_Windows_Forms_TreeNode_1.ImageIndex = 3
  497.         $System_Windows_Forms_TreeNode_1.Name = "Active Directory Hierarchy"
  498.         $System_Windows_Forms_TreeNode_1.SelectedImageIndex = 3
  499.         $System_Windows_Forms_TreeNode_1.Tag = "root"
  500.         $System_Windows_Forms_TreeNode_1.Text = "Active Directory Hierarchy"
  501.         [void]$treeview1.Nodes.Add($System_Windows_Forms_TreeNode_1)
  502.         $treeview1.SelectedImageIndex = 0
  503.         $treeview1.Size = '301, 425'
  504.         $treeview1.TabIndex = 1
  505.         $treeview1.add_AfterLabelEdit($CreateOU)
  506.         #
  507.         # buttonOK
  508.         #
  509.         $buttonOK.Anchor = 'Bottom, Right'
  510.         $buttonOK.DialogResult = 'OK'
  511.         $buttonOK.Location = '245, 467'
  512.         $buttonOK.Name = "buttonOK"
  513.         $buttonOK.Size = '75, 23'
  514.         $buttonOK.TabIndex = 0
  515.         $buttonOK.Text = "OK"
  516.         $buttonOK.UseVisualStyleBackColor = $True
  517.         $buttonOK.add_Click($buttonOK_Click)
  518.         #
  519.         # imagelist1
  520.         #
  521.         $Formatter_binaryFomatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
  522.         #region Binary Data
  523.         $System_IO_MemoryStream = New-Object System.IO.MemoryStream ( , [byte[]][System.Convert]::FromBase64String('
  524.    AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAu
  525.    MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAA
  526.    ACZTeXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkD
  527.    AAAADwMAAABwCgAAAk1TRnQBSQFMAgEBBAEAAUABAAFAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2
  528.    AQQGAAE2AQQCAAEoAwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYAB
  529.    AAKAAgADwAEAAcAB3AHAAQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEA
  530.    AykBAANVAQADTQEAA0IBAAM5AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8B
  531.    AAHWAucBAAGQAakBrQIAAf8BMwMAAWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHM
  532.    AgABMwH/AgABZgMAAWYBMwIAAmYCAAFmAZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgAC
  533.    mQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHMAWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZ
  534.    AgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEAATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8B
  535.    MwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEzAWYCAAEzAWYBMwEAATMCZgEAATMBZgGZ
  536.    AQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZAWYBAAEzApkBAAEzAZkBzAEAATMB
  537.    mQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLMAQABMwHMAf8BAAEzAf8BMwEA
  538.    ATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEAAWYBAAFmAQABZgEAAZkB
  539.    AAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEAAWYBMwHMAQABZgEz
  540.    Af8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZAWYBAAFmApkB
  541.    AAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/AQABZgH/
  542.    AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEAAZkB
  543.    AAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
  544.    ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwB
  545.    AAKZAf8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIA
  546.    AZkB/wEzAQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYB
  547.    AAHMAQABmQEAAcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATM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E+BwABPgMAASgDAAFAAwABIAMAAQEBAAEBBgABARYA
  574.    A///AAIACw=='))
  575.         #endregion
  576.         $imagelist1.ImageStream = $Formatter_binaryFomatter.Deserialize($System_IO_MemoryStream)
  577.         $Formatter_binaryFomatter = $null
  578.         $System_IO_MemoryStream = $null
  579.         $imagelist1.TransparentColor = 'Transparent'
  580.         #
  581.         # ErrorProviderOU
  582.         #
  583.         $ErrorProviderOU.ContainerControl = $formChooseOU
  584.         #endregion Generated Form Code
  585.        
  586.         #----------------------------------------------
  587.        
  588.         #Save the initial state of the form
  589.         $InitialFormWindowState = $formChooseOU.WindowState
  590.         #Init the OnLoad event to correct the initial state of the form
  591.         $formChooseOU.add_Load($Form_StateCorrection_Load)
  592.         #Clean up the control events
  593.         $formChooseOU.add_FormClosed($Form_Cleanup_FormClosed)
  594.         #Show the Form
  595.         return $formChooseOU.ShowDialog()
  596.        
  597.     } #End Function
  598.    
  599.     #Call OnApplicationLoad to initialize
  600.     if ((OnApplicationLoad) -eq $true)
  601.     {
  602.         #Call the form
  603.         Call-AD_OU_select_pff | Out-Null
  604.        
  605.         #Perform cleanup
  606.         OnApplicationExit
  607.        
  608.         #Output
  609.         $objSelectedOU
  610.     }
  611. }

User avatar
Jcholder
Posts: 7
Last visit: Sun Mar 18, 2018 7:09 pm

Re: OU Selector

Post by Jcholder »

Nevermind, I think I found the solution here https://itmicah.wordpress.com/2016/03/2 ... revisited/

jvierra
Posts: 14884
Last visit: Sat Jul 31, 2021 3:56 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: OU Selector

Post by jvierra »

Here is the fastest OU picker method available. It is a demo of how easy it is to load an OU tree and its objects and how to build it so no Active Directory module is needed. It is pure ADSI and uses almost no code to obtain the tree. It can be enhanced very easily with little effort.

Here is the total amount of functional code required to dynamically load a tree.
  1. $FormEvent_Load={
  2.  
  3.     $rootCN=[adsi]''
  4.     $nodeName=$rootCN.Name
  5.     $key="LDAP://$($rootCN.DistinguishedName)"
  6.     $treeview1.Nodes.Add($key,$nodeName)   
  7. }
  8.  
  9.  
  10. $treeview1_NodeMouseClick=[System.Windows.Forms.TreeNodeMouseClickEventHandler]{
  11.     if (-not $_.Node.IsExpanded) {
  12.         $thisOU = [adsi]$_.Node.Name
  13.         $nodename.Text = $thisOU.Name
  14.         $listbox1.DataSource = [collections.arraylist]@($thisOU.Children)
  15.         if (-not $_.Node.Nodes) {
  16.             $nodepath.Text = $thisOU.DistinguishedName
  17.             $searcher = [adsisearcher]'objectClass=organizationalunit'
  18.             $searcher.SearchRoot = $_.Node.Name
  19.             $searcher.SearchScope = 'OneLevel'
  20.             $searcher.PropertiesToLoad.Add('name')
  21.             $OUs = $searcher.Findall()
  22.             foreach ($ou in $OUs) {
  23.                 $_.Node.Nodes.Add($ou.Path, $ou.Properties['name'])
  24.             }
  25.         }
  26.         $_.Node.Expand()
  27.     } else {
  28.         $_.Node.Collapse()
  29.     }
  30. }
Notice no AD module. This can be run on any workstation that has PS 3 or later installed.

This was originally created to demonstrate how to dynamically load a Treeview as it is navigated. With a few lines of code the first level could just use the forest as the root and have all domains available.
Attachments
Demo-ADSITreeView.psf
(24.02 KiB) Downloaded 333 times

User avatar
Jcholder
Posts: 7
Last visit: Sun Mar 18, 2018 7:09 pm

Re: OU Selector

Post by Jcholder »

Awesome! Thank you very much

jvierra
Posts: 14884
Last visit: Sat Jul 31, 2021 3:56 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: OU Selector

Post by jvierra »

You are welcome. It is a starting point that demonstrates how to easily load a TreeView. It has some deficiencies that are easily remedied. The next steps all depend on what your particular requirement is. Icons and other bells and whistles are very easy to add and take very small amounts of code.

User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: OU Selector

Post by dan.potter »

Jcholder wrote:Nevermind, I think I found the solution here https://itmicah.wordpress.com/2016/03/2 ... revisited/
That one had a couple issues Micah overlooked. I fixed them and posted on github. Jvierra's code is better but you can use the images in the attached.
adtree.psf
(28.16 KiB) Downloaded 354 times

Locked