Organizing cmdlet operations in a sequence

There is no fixed sequence in which cmdlets must be called. There is, however, a logical sequence to follow to make information available from one to another. For example, to get all of the user UNIX profiles in a zone, you must first identify the zone object you want to work with before you call the Get-CdmUserProfile cmdlet, To accomplish this, you could organize the calls in the following sequence:

$zone = Get-CdmZone -Name "myZone"
Get-CdmUserProfile -Zone $zone

Similarly, to get all of the UNIX user profiles for a specific computer, you must first identify the computer object:

$computer = Get-CdmManagedComputer -Name "myComputer"
Get-CdmUserProfile -Computer $computer

In most cases, you can determine from the parameters of a cmdlet whether you need to call another cmdlet first. For example, if you want to add a right to a role, you must have created the role first so it can be specified as a parameter to the Add-CdmXxx cmdlet.

For most Set-CdmXxx or Remove-CdmXxx cmdlets, you must call the corresponding Get‑CdmXxx or Add-CdmXxx cmdlet to obtain the object first. For example, to delete "role1" from "zone1", you could call the cmdlets as follows:

Get-CdmRole -Zone "cn=zone1,cn=Zones,dc=acme,dc=com" -Name "role1" | Remove‑CdmRole

In this example, the Get-CdmRole cmdlet retrieves “role1” from the specified zone and passes it to the Remove-CdmRole cmdlet.