Retrieving Organizational Units
Retrieving Organizational Units
Retrieves the specified Organizational Unit(s).
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
Retrieve the Organizational Unit "Chicago" from the container "Managed Users & Computers\solys.local":
Get-EmdbOrganizationalUnit "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago" |
Retrieve all Organizational Units from the container "Managed Users & Computers\solys.local" and its subcontainers:
Get-EmdbOrganizationalUnit "emdb:\rootDSE\Managed Users & Computers\solys.local\*" -Recurse |
Retrieve the Organizational Unit "Chicago" in the current context through its Item-ID (this ID will vary in different DSM environments):
Get-EmdbOrganizationalUnit -ItemID 10232 -Recurse |
Tip: the alias ID can be used instead of ItemID. |
Retrieve the Organizational Unit "Chicago" from the current context using the cmdlet Get-Item:
Cd "emdb:\rootDSE\Managed Users & Computers\solys.local" Get-Item "Chicago" |
Retrieve all Organizational Units from the container "Managed Users & Computers\solys.local" and its subcontainers using the cmdlet Get-ChildItem:
Get-ChildItem "emdb:\rootDSE\Managed Users & Computers\solys.local" -Filter "SchemaTag=OU" -Recurse |
Starting with PSX 3.1 there was a new option implemented when retrieving Organizational Unit objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is contained in the result. If the retrieval returns more than one object, an error is raised that can be caught and handled in scripts.