Merge pull request #327 from silversword411/develop

Adding AD Recycle Bin script
This commit is contained in:
Dan 2021-03-16 09:50:20 -07:00 committed by GitHub
commit 8b87b2717e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -222,5 +222,12 @@
"name": "Chocolatey Update Installed Apps",
"description": "Update all apps that were installed using Chocolatey.",
"shell": "cmd"
},
{
"filename": "AD_Check_And_Enable_AD_Recycle_Bin.ps1",
"submittedBy": "https://github.com/silversword411",
"name": "AD - Check and Enable AD Recycle Bin",
"description": "Only run on Domain Controllers, checks for Active Directory Recycle Bin and enables if not already enabled",
"shell": "powershell"
}
]

View File

@ -0,0 +1,17 @@
#Please only run on a domain controller
#This script will first check if there are any AD Recycle Bin scopes set up - if there are no scopes it is assumed recycle bin feature is not enabled for the domain
#The script then pulls the domain that the machine running the script is on - queries the domain for the Infrastructure Master and then will attempt to enable the feature
$adRecycleBinScope = Get-ADOptionalFeature -Identity 'Recycle Bin Feature' | Select -ExpandProperty EnabledScopes
$ADDomain = Get-ADDomain | Select -ExpandProperty Forest
$ADInfraMaster = Get-ADDomain | Select-Object InfrastructureMaster
if ($adRecycleBinScope -eq $null){
Write-Host "Recycle Bin Disabled"
Write-Host "Attempting to enable AD Recycle Bin"
Enable-ADOptionalFeature -Identity 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target $ADDomain -Server $ADInfraMaster.InfrastructureMaster -Confirm:$false
Write-Host "AD Recycle Bin enabled for domain $($ADDomain)"
}
else{
Write-Host "Recycle Bin already Enabled For: $($ADDomain)`n Scope: $($adRecycleBinScope)"
}