PoshCode Archive  Artifact [560a906bd4]

Artifact 560a906bd48c400133412ad19d4757d69c1a7164a2a536c20f69d2cf3732b901:

  • File Remove-Disabled-AD-Users.ps1 — part of check-in [3c2367737c] at 2018-06-10 13:21:27 on branch trunk — This script is a simple one that is meant to be scheduled on a periodic basis (we do it weekly). It looks inthe OU where we put our disabled AD users and removes users that have not logged in (inactive) for 400 days. This allows us to keep terminated employees disabled users for over a year for auditing purposes, but automatically cleans them out once the annual scope has passed. (user: DrDrewl size: 863)

# encoding: ascii
# api: powershell
# title: Remove Disabled AD Users
# description: This script is a simple one that is meant to be scheduled on a periodic basis (we do it weekly). It looks inthe OU where we put our disabled AD users and removes users that have not logged in (inactive) for 400 days. This allows us to keep terminated employees disabled users for over a year for auditing purposes, but automatically cleans them out once the annual scope has passed.
# version: 400.00
# type: module
# author: DrDrewl
# license: CC0
# x-poshcode-id: 3163
# x-archived: 2016-08-12T10:38:21
# x-published: 2012-01-13T12:05:00
#
#
import-module ActiveDIrectory
search-adaccount -searchbase "ou=UserObjectsPendingDeletion,DC=mydomain,DC=com" -Accountinactive -Timespan 400.00:00:00 | where {$_.objectclass -eq 'user'} |  remove-aduser -confirm:$false