As you could see on the introduction screen the concept is simple. In below screen you can see offboarding procedure. Define Service, define trigger, use some condition (for now it's not working), ignore accounts that have EmailAddress empty or null and finally do 5 actions.
Clear-Host
Import-Module PSAutomator -Force #-Verbose
Import-Module PSSharedGoods -Force
Service -Name 'Active Directory Offboarding' -ConfigurationPath 'C:\Support\GitHub\PSAutomator\Examples\MyConfiguration.xml' {
Trigger -Name 'OU Offboarded Users' -User OrganizationalUnit -Value 'OU=Users-Offboarded,OU=Production,DC=ad,DC=evotec,DC=xyz' |
Condition -Name 'No conditions' |
Ignore -Name 'Ignore Windows Email Address if Empty or null' -Ignore MatchingEmptyOrNull -Value EmailAddress |
Action -Name 'Make User Snapshot' -ActiveDirectory AccountSnapshot -Value 'C:\Users\pklys\Desktop\MyExport' -Whatif |
Action -Name 'Disable AD Account' -ActiveDirectory AccountDisable -WhatIf |
Action -Name 'Hide account in GAL' -ActiveDirectory AccountHideInGAL -WhatIf |
Action -Name 'Remove all security groups' -ActiveDirectory AccountRemoveGroupsSecurity -WhatIf |
Action -Name 'Rename Account' -ActiveDirectory AccountRename -Value @{ Action = 'AddText'; Where = 'After'; Fields = 'DisplayName', 'Name'; Text = ' (offboarded)'; } -WhatIf
}
Similarly code below reverses this actions
Clear-Host
Import-Module PSAutomator -Force #-Verbose
Import-Module PSSharedGoods -Force
Service -Name 'Active Directory Enable Users in OU' {
Trigger -Name 'Find Offboarded Users' -User OrganizationalUnit -Value 'OU=Users-Offboarded,OU=Production,DC=ad,DC=evotec,DC=xyz' |
Ignore |
Action -Name 'Enable Offboarded Users' -ActiveDirectory AccountEnable -WhatIf |
Action -Name 'Add to group GDS-TestGroup5' -ActiveDirectory AccountAddGroupsSpecific -Value 'GDS-TestGroup5' -WhatIf |
Action -Name 'Add to group GDS-TestGroup4' -ActiveDirectory AccountAddGroupsSpecific -Value 'GDS-TestGroup4' -Whatif |
Action -Name 'Remove Offboarded Tag' -ActiveDirectory AccountRename -Value @{ Action = 'RemoveText'; Fields = 'DisplayName', 'Name' ; Text = ' (offboarded)'; } -WhatIf
}
As you could see in off-boarding process only 2 users were disabled and actions were taken. In reversing this process script found 6 users but still did actions only on those that were impacted by off-boarding process. If you will run script twice or more it will execute but it won't do anything.
Keep in mind that in perfect world for optimum speed one would define a process that would not end up with accounts being found by the script over and over. Also keep in mind this script is very early alpha and heavily work in progress. It's not yet production ready. It's meant to give you idea of what it will be able to do. However… it does work. Feel free to voice your needs, opinions on GitHub.