Enable AD Recycle Bin
Summary
This document describes how to enable the Active Directory (AD) Recycle Bin on AD Infrastructure Masters.
Dependencies
Create Script
To implement this script, please create a new "PowerShell" style script in the system.
Name: Enable AD Recycle Bin
Description: This task enables AD recycle on Windows Infrastructure Masters
Category: Custom
Script
Row 1 Function: PowerShell Script
Paste in the following PowerShell script and set the expected time of script execution to 900 seconds.
Step 2 Logic: If/Then
- Add a new
If/Thenlogic from the Add Logic dropdown menu.
ROW 2a Condition: Output Contains
- Type
Outdatedin the Value box.
ROW 2b Function: Set Custom Field
Add a new row in the If Section by clicking the Add Row button.
- Search and select the
Set Custom Fieldfunction.
- Search and select the
AD Recycle BinCustom Field. - Type
Outdated PS versionin theValuebox and click the Save button.
ROW 2c Function: Script Exit
- Add a new row in the If Section by clicking the Add Row button.
- Search and select the
Script Exitfunction. - Input the following:
The AD Recycle Bin failed to be enabled on the DC server as the PowerShell version is outdated. Minimum version required is above 3.0 and the current version is %output%
ROW 3 Function: PowerShell Script
Paste in the following PowerShell script and set the expected time of script execution to 900 seconds.

ROW 4 Function: PowerShell Script
Paste in the following PowerShell script and set the expected time of script execution to 900 seconds.

Step 5 Logic: If/Then
- Add a new
If/Thenlogic from the Add Logic dropdown menu.
ROW 5a Condition: Output Contains
- Type
Minimum criteria for AD Recycle Bin enablein the Value box.
Row 5b Function: Set Custom Field
Add another row by selecting the ADD ROW button in the If section of the If/Then section.
- Search and select the
Set Custom Fieldfunction.
- Search and select the
AD Recycle BinCustom Field. - Type
Does not meet minimum criteriain theValuebox and click the Save button.
ROW 5c Function: Script Exit
- Add a new row in the If Section by clicking the Add Row button.
- Search and select the
Script Exitfunction. - Input the following:
The AD Recycle Bin failed to be enabled on the DC server. The DomainMode or ForestMode is not eligible for the AD Recycle Bin to be enabled.
Logs:
%output%
ROW 6 Function: PowerShell Script
Paste in the following PowerShell script and set the expected time of script execution to 900 seconds.

Step 7 Logic: If/Then/Else
- Add a new
If/Then/Elselogic from the Add Logic dropdown menu.
ROW 7a Condition: Output Contains
- Type
Failed to enablein the Value box.
Step 7b Logic: If/Then
Add a new If/Then logic from the Add Logic dropdown menu inside the IF section.
Row 7b(i) Condition: Custom Field Does Not Contain
- Select
Custom fieldfrom the dropdown. - Select
AD Recycle Bincustom field from the dropdown. - Select
Does Not Containfrom the dropdown. - Type
Does not meet minimum criteriainto the value.
Select ADD CONDITION in the Custom field section and add another condition.
- Select
Custom fieldfrom the dropdown. - Select
AD Recycle Bincustom field from the dropdown. - Select
Does Not Containfrom the dropdown. - Type
Outdated PS versioninto the value.

Select ADD CONDITION in the Custom field section and add another condition.
- Select
Custom fieldfrom the dropdown. - Select
AD Recycle Bincustom field from the dropdown. - Select
Does Not Containfrom the dropdown. - Type
Enabledinto the value.

Select ADD CONDITION in the Custom field section and add another condition.
- Select
Custom fieldfrom the dropdown. - Select
AD Recycle Bincustom field from the dropdown. - Select
Does Not Containfrom the dropdown. - Type
failed more than 3 timesinto the value.
The whole custom field should look like this.

Row 7b(ii) Condition: Set Pre-defined Variable
Add another row by selecting the ADD ROW button in the IF section of the internal If/Then section.
- Select
Set Pre-Defined Variablefunction.
- Select
Custom Field. - Input
AD_RecycleBin_Resultas the variable name. - Select
AD Recycle Bincustom field from the dropdown. - Click Save.
Row 7b(iii) Function: PowerShell Script
Add another row by selecting the ADD ROW button in the IF section of the internal If/Then section.
- Select PowerShell Script function.
Paste in the following PowerShell script and set the expected time of script execution to 900 seconds.

Row 7b(iv) Function: Set Custom Field
Add another row by selecting the ADD ROW button in the IF section of the internal If/Then section.
- Search and select the
Set Custom Fieldfunction.

- Search and select the
AD Recycle BinCustom Field. - Type
%Output%in theValuebox and click the Save button.
Row 7b(v) Function: Script Exit
Add another row by selecting the ADD ROW button in the Else section of the internal If/Then section.
- Search and select the
Script Exitfunction. - Input the following:
Script failed to enable AD Recycle Bin on the DC server.
Logs:
%output%
Row 7c Function: Set Custom Field
Add another row by selecting the ADD ROW button in the Else part of the If/Then/Else section.
- Search and select the
Set Custom Fieldfunction.
- Search and select the
AD Recycle BinCustom Field. - Type
Enabledin theValuebox and click the Save button.
The final task should look like the screenshot below.


Script Deployment
This task must be scheduled on the Infrastructure Master - Without Recycle Bin group for auto deployment. The script can also be run manually if required.
Go to Automations > Tasks.
Search for Enable AD Recycle Bin.
Then click on Schedule and provide the necessary parameters for script completion.

Output
- Script log
Changelog
2025-04-10
- Initial version of the document