jazzyjeff Posted June 3, 2010 Share Posted June 3, 2010 Hello, I am trying to use an array to get all the OUs in my AD domain using the function _AD_GetAllOUs. I can't get it to populate into a list view box. I am using the function _ArrayToString, which isn't working. If I use _ArraryDisplay it works fine, but I can't figure out how to get the "Copy Selected" button to just copy the Column 2 section, which contains the LDAP path of the OU. I was hoping I could do more with the _ArrayToString, but this isn't working for me. Here is what I have so far: #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $adOU = _AD_GetAllOUs() $adOU = _ArrayToString($adOU, '|', 1) #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 296, 349, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$adOU) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _AD_Close() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I know it's not much. I don't want to go any further until I can get this part resolved. Ultimately what I am trying to achieve is a script that uses the "DSMOVE" utility to move a PC that is joined to a domain to a specified OU. The OU can be selected from the list that contains all the OU's. Any help with this is much appreciated. Link to comment Share on other sites More sharing options...
water Posted June 3, 2010 Share Posted June 3, 2010 (edited) You need something like this: #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU Global $adOU = _AD_GetAllOUs() For $iCount = 1 To $adOU[0][0] If $iCount = 1 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 296, 349, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$sOU) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _AD_Close() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd _AD_GetAllOUs() returns a two-dimensional array. Therefore the loop to create the string for GUICtrlSetData. And instead of DSMOVE you can use the function _AD_MoveObject(). Edited June 3, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 4, 2010 Author Share Posted June 4, 2010 Hi Water, Thanks for your quick response. I have been trying to get this working since you got the List to populate the OU's for me. I have been trying ever since to get the next part working, where I select the OU of choice and then click continue and the script will move the computer to the OU. However, it's not quite working out for me. Here is what I have: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU Global $adOU = _AD_GetAllOUs() For $iCount = 1 To $adOU[0][0] If $iCount = 1 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 298, 344, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$sOU) $btnCont = GUICtrlCreateButton("Continue", 7, 294, 281, 41, $WS_GROUP) GUICtrlSetFont(-1, 20, 400, 0, "Impact") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $selOU = _GUICtrlListBox_GetSelItems($ListOU) For $iI = 1 To $selOU[0] If $iI > 1 Then $sItems = $selOU[$iI] EndIf Next While 1 $nMsg = GUIGetMsg() Global $OU Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnCont _AD_MoveObject($selOU,@ComputerName) EndSwitch WEnd _AD_Close() I have basically added the following code: $selOU = _GUICtrlListBox_GetSelItems($ListOU) For $iI = 1 To $selOU[0] If $iI > 1 Then $sItems = $selOU[$iI] EndIf Next While 1 $nMsg = GUIGetMsg() Global $OU Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnCont _AD_MoveObject($selOU,@ComputerName) EndSwitch WEnd _AD_Close() Any idea what's wrong? I am pretty sure I have made a complete mess of trying to get the selected OU from the ListBox into the script that moves the AD Object into the selected OU. Do I need to specify at any point where the object currently exists? I also tried doing this with the "dsmove" utility, but I had mixed results here. I - It would either extract all of the list box information (every OU). - Add the text "true" or "false", depending on how I modified the script. The LDAP path never appeared. If you could offer some more advice/help, that would be great. Thanks, Jeff Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 4, 2010 Author Share Posted June 4, 2010 I just tried adding the code from your example: Global $iValue = _AD_MoveObject($selOU,@ComputerName) If $iValue = 1 Then MsgBox(64, "Successful","Sucess") ElseIf @error = 1 Then MsgBox(64, "does not exist","fail") ElseIf @error = 2 Then MsgBox(64, "does not exist","fail") Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") EndIf I received the prompts fail to confirm that it didn't work. :-( Link to comment Share on other sites More sharing options...
water Posted June 4, 2010 Share Posted June 4, 2010 I'm a bit in a hurry so I couldn't check your code. Two things you have to make sure for _AD_MoveObject to work:Parameter 1 (the target OU) has to be specified as FQDN. Example: OU=User_Accounts, DC=microsoft,DC=comParameter 2 (the computer to move) has to be specified as FQDN or samaccountname. The samaccountname of a computer has a dollar sign at the end. Example: @Computername & "$"HTH My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 4, 2010 Author Share Posted June 4, 2010 I hate to sound defeated on this, but I am ... I just don't get how data from an array residing in a ListBox can be selected and then extracted to a variable. I have this code at present: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU Global $adOU = _AD_GetAllOUs() For $iCount = 20 To $adOU[0][0] If $iCount = 20 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 298, 344, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$sOU) $selOU = _GUICtrlListBox_GetSelItems($ListOU) $btnCont = GUICtrlCreateButton("Continue", 7, 294, 281, 41, $WS_GROUP) GUICtrlSetFont(-1, 20, 400, 0, "Impact") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 20 To UBound ($selOU[0]) If $i >= 20 Then $sItems = $selOU[$i] EndIf Next While 1 $nMsg = GUIGetMsg() Global $OU Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnCont Global $iValue = _AD_MoveObject($selOU,@ComputerName &"$") If $iValue = 1 Then MsgBox(64, "Successful","Sucess") ElseIf @error = 1 Then MsgBox(64, "does not exist","fail") ElseIf @error = 2 Then MsgBox(64, "does not exist","fail") Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") EndIf Exit EndSwitch WEnd _AD_Close() Can someone perhaps explain to me how array's work and what each bit does. I have done some reading on this, but i don't think the reading that I have done is applying to what I need to do in the real world. So I have this code that I know works, but I don't fully understand why or what it's doing and I'd really like to. Global $adOU = _AD_GetAllOUs() For $iCount = 20 To $adOU[0][0] If $iCount = 20 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next So the first like is saying that the variable, $adOU, will contain the values of everything discovered in the function, _AD_GetAllOUs(). This function itself is checking Active Directory for the OU's that have been created. This is where I start to lose the understanding... The second line is saying that the array will start at the 20th entry in the array that is $adOU. The variable $iCount stores that value of this array. The third line is saying that if the variable, $iCount, equals the value 20 of the array (kinda of seems obvious that will, so I don't understand why I have to state that) then the fourth line is executed. The fourth line is ... I don't even know what the fourth line is doing now... I'm totally confused. :-) If someone could give me an explanation I'd be extremely grateful and hopefully I can understand how to fix my problem. Thanks, Jeff Link to comment Share on other sites More sharing options...
water Posted June 7, 2010 Share Posted June 7, 2010 (edited) Hi Jeff,you have to change two things in your script:The array $adOU populated by _AD_GeAllOUs() contains the displayname (first column, accessed by $sadOU[0]) and the FQDN for the OU (second column, accessed by $sadOU[1])Function _GUICtrlListBox_GetSelItems returns an array of selected itemsWhy do you suppress the first 20 OU's?expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU Global $adOU = _AD_GetAllOUs() For $iCount = 20 To $adOU[0][0] If $iCount = 20 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 298, 344, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT, $LBS_STANDARD, $LBS_EXTENDEDSEL, $WS_VSCROLL, $WS_BORDER)) GUICtrlSetData($ListOU, $sOU) $btnCont = GUICtrlCreateButton("Continue", 7, 294, 281, 41, $WS_GROUP) GUICtrlSetFont(-1, 20, 400, 0, "Impact") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Global $OU Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnCont $selOU = _GUICtrlListBox_GetSelItems($ListOU) Global $selectedItem = $selOU[1]+20 Global $iValue = _AD_MoveObject($adOU[$selectedItem][1], @ComputerName & "$") If $iValue = 1 Then MsgBox(64, "Successful", "Sucess") ElseIf @error = 1 Then MsgBox(64, "Organizational Unit (OU) " & $adOU[$selectedItem][0] & " does not exist", "fail") ElseIf @error = 2 Then MsgBox(64, "Object " & @ComputerName & "$ does not exist", "fail") Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") EndIf Exit EndSwitch WEnd _AD_Close() Edited June 9, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 8, 2010 Author Share Posted June 8, 2010 Sorry for the delay in getting back to you on this. I've had other stuff at work that I've had to put priority on. I'm still working on this, and trying to figure it out. I'll keep trying different ways to get the data out of the Listbox that I select. Not quite sure it's this giving me a headache or my baby getting up at 1am. :-) I'll keep you posted on my results. I definitely don't want to give up! I surpressed the first 20 OU's because our AD structure is setup that the first OU's are just user or server based. Everything after this is what I need to view. Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 8, 2010 Author Share Posted June 8, 2010 Despite my head feeling like it's going to explode, I'm trying stuff. I have come up with this: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU,$aItems,$sItems Global $adOU = _AD_GetAllOUs() For $iCount = 20 To $adOU[0][0] If $iCount <= 20 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 298, 344, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$sOU) $btnCont = GUICtrlCreateButton("Continue", 7, 294, 281, 41, $WS_GROUP) GUICtrlSetFont(-1, 20, 400, 0, "Impact") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnCont $aItems = _GUICtrlListBox_GetSelItems($ListOU) For $iI = 1 To $aItems[0] If $iI > 1 Then $sItems &= ", " $sItems &= $aItems[$iI] Next MsgBox(4160, "Information", "Items Selected: " & $sItems) _AD_MoveObject($sItems,@ComputerName &"$") Exit EndSwitch WEnd _AD_Close() Basically the part I have added is this, which I got from an example of the _GUICtrlListBox_GetSelItems function. Case $btnCont $aItems = _GUICtrlListBox_GetSelItems($ListOU) For $iI = 1 To $aItems[0] If $iI > 1 Then $sItems &= ", " $sItems &= $aItems[$iI] Next MsgBox(4160, "Information", "Items Selected: " & $sItems) _AD_MoveObject($sItems,@ComputerName &"$") Exit EndSwitch WEnd _AD_Close() The output that it is retrieving from the array/listbox appears to be the row number. At least it is now picking up something from the array. Is there a way to say don't ouput column 1 from array, output column 2 or 3. I'm guessing this is how it works by having the data in columns. I know the _AD_MoveObject function needs a full LDAP path, so if someone can help me figure this bit out I'd really appreciate it. Link to comment Share on other sites More sharing options...
water Posted June 9, 2010 Share Posted June 9, 2010 Does the code I added in my last post work? In your code you take all selected items and feed it to _AD_MoveObject. But _AD_MoveObject only takes one FQDN. Please try my code and post if something is wrong with it. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jazzyjeff Posted June 9, 2010 Author Share Posted June 9, 2010 I'm embarrassed that I didn't read you're post correctly! An early night really was good last night :-) Thank you so much. The script worked great. Hopefully I can use what you've taught me to create some other great scripts to help out in our school. Thanks again. Link to comment Share on other sites More sharing options...
water Posted June 9, 2010 Share Posted June 9, 2010 Glad to be of service! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JoelE Posted November 2, 2010 Share Posted November 2, 2010 Sorry to bump this but I have a question... The above script lists all the OUs in the directory. What happens if I want to list all the OUs under a specific OU (call it Example) I've tried adding $sAD_root = "Example" to the array options of _AD_GetAllOUs: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=Enumerate.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> _AD_Open() Global $sOU Global $sAD_Root Global $sAD_Separator Global $adOU = _AD_GetAllOUs($sAD_Root = "Example") For $iCount = 1 To $adOU[0][0] If $iCount = 1 Then $sOU = $adOU[$iCount][0] Else $sOU = $sOU & "|" & $adOU[$iCount][0] EndIf Next #Region ### START Koda GUI section ### Form=C:\Users\carrollje\Desktop\AutoIT Script\AutoLogin\sourceOU2.kxf $main = GUICreate("Active Directory", 296, 349, 192, 124) $ListOU = GUICtrlCreateList("", 7, 8, 281, 279, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData($ListOU,$sOU) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _AD_Close() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd The above doesn't work - it still spits out the list of all the OUs. Can someone please help? Link to comment Share on other sites More sharing options...
water Posted November 2, 2010 Share Posted November 2, 2010 (edited) Wrong syntax. The parameter has to be specified as fully qualified domain name. Global $adOU = _AD_GetAllOUs("OU=System_Users,DC=microsoft,DC=com") Edited November 2, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JoelE Posted November 2, 2010 Share Posted November 2, 2010 Wrong syntax. The parameter has to be specified as fully qualified domain name. Global $adOU = _AD_GetAllOUs("OU=System_Users,DC=microsoft,DC=com") Thank you - I searched the forums and couldn't find an answer. If I might impose with just one more question related to this... lets say I have the following structure: dc=domain,dc=com -OU=Example --OU=CompanyA ---OU=Disabled Users ---OU=Enabled Users --OU=CompanyB ---OU=Disabled Users ---OU=Enabled Users Is there a way to modify the script so that it only shows me the second OU level - ie, output a list box to show me: Example\CompanyA Example\CompanyB Many thanks. Link to comment Share on other sites More sharing options...
water Posted November 2, 2010 Share Posted November 2, 2010 (edited) As every OU is separated by a backslash you can use something like this: Global $adOU = _AD_GetAllOUs("OU=System_Users,DC=microsoft,DC=com") For $iIndex = 1 To $adOU[0][0] $aOU = StringSplit($adOU[$iIndex][0], "\") If $aOU[0] = 2 Then Do whatever you like Next Edited November 2, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now