Get Units in Folder
Description
Section titled “Description”Gets a list of units in either a folder or in the root of either a Business Unit or Global.
Syntax
Section titled “Syntax”GetUnitsInFolder(ByVal folderStructure As String, ByVal unitType As String, ByVal businessUnitName As String) as ArrayList
Parameters
Section titled “Parameters”FolderStructure (String)
The folder structure. Separate the folder levels with a backslash, for example Folder1\Folder2\Folder3.
If this parameter is left blank, units that are located in the root will be returned. If the folder doesn’t exist, the function returns an empty list.
UnitType (String)
Type of unit folder.
- “Computer”
- “User”
BusinessUnitName (String)
The name of the Business Unit, for example “Sales”.
If this parameter is left blank, units from Global are returned.
Return value
Section titled “Return value”The function returns an array of units. Each unit (unit) in the array is a joined line with the character defined with Set splitter.
- unit.Name
- unit.Created
- unit.LastExecuted
- unit.Status
- unit.Description
- unit.GUID
- unit.ID
- unit.Type.Name
- unit.UUID
- Unit.IsMobileDevice (“True” or “False”)
- unit.location
Example
Section titled “Example”Set oCMS = CreateObject("CapaInstaller.SDK")Wscript.echo oCMS.SetInstanceManagementPoint("1")
Set arrComputers1 = CreateObject("System.Collections.ArrayList")Set arrComputers2 = CreateObject("System.Collections.ArrayList")Set arrComputers3 = CreateObject("System.Collections.ArrayList")Set arrUsers1 = CreateObject("System.Collections.ArrayList")Set arrUsers2 = CreateObject("System.Collections.ArrayList")
Set arrComputers1 = oCMS.GetUnitsInFolder("Folder1\Folder2\Folder3", "Computer", "")Wscript.echo "Computers/devices in Global Folder1\Folder2\Folder3: " + Cstr(arrComputers1.Count)For Each item In arrComputers1 Wscript.echo itemNextWscript.echo "***************************"
Set arrComputers2 = oCMS.GetUnitsInFolder("", "Computer", "Skanderborg")Wscript.echo "Computers/devices in root of BU Skanderborg: " + Cstr(arrComputers2.Count)For Each item In arrComputers2 Wscript.echo itemNextWscript.echo "***************************"
Set arrComputers3 = oCMS.GetUnitsInFolder("", "Computer", "")Wscript.echo "Computers/devices in root of Global: " + Cstr(arrComputers3.Count)For Each item In arrComputers3 Wscript.echo itemNextWscript.echo "***************************"
Set arrUsers1 = oCMS.GetUnitsInFolder("UserFolder1\UserFolder2\", "User", "")Wscript.echo "Users in UserFolder1\UserFolder2: " + Cstr(arrUsers1.Count)For Each item In arrUsers1 Wscript.echo itemNextWscript.echo "***************************"
Set arrUsers2 = oCMS.GetUnitsInFolder("", "User", "")Wscript.echo "Users in Root of Global: " + Cstr(arrUsers2.Count)For Each item In arrUsers2 Wscript.echo itemNextWscript.echo "***************************"