Curated Examples
Preview OU-based account actions
Use PSAutomator to model an OU-triggered account workflow with WhatIf actions.
This pattern is useful when you want to review how a trigger and actions fit together before changing accounts.
It is adapted from Examples/RunBook.UsersOffboarding.1.ps1.
Example
Import-Module PSAutomator
Import-Module PSSharedGoods
Service -Name 'Active Directory Prepare Users' {
Trigger -Name 'Offboarded users OU' -User OrganizationalUnit -Value 'OU=Users-Offboarded,OU=Accounts,DC=corp,DC=example,DC=com' |
Condition |
Action -Name 'Disable users' -ActiveDirectory AccountDisable -WhatIf |
Action -Name 'Add to disabled users group' -ActiveDirectory AccountAddGroupsSpecific -Value 'Disabled Users' -WhatIf
}
What this demonstrates
- modeling an OU-based trigger
- chaining account actions
- keeping changes in preview mode with
-WhatIf