This was quick and dirty / probably needs some more work I'll add it to GitHub later.
PowerShell:
Import-Module ActiveDirectory
if ((Get-ADOptionalFeature -Identity 'Recycle Bin Feature').EnabledScopes)
{
Write-Host "AD Recycle Bin Enabled"
}
else
{
try
{
$domain = Get-WmiObject -Namespace Root\CIMV2 -Class Win32_ComputerSystem | select -ExpandProperty Domain
Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target $domain -Confirm:$false
Import-Module ActiveDirectory
Write-Host "Installed Recycle Bin"
}
catch
{
Write-Error -Message "Something went wrong!"
}
}
Last edited: