Powershell AD Account Expiry

We can automate the AD user and computer account expiry for when employee's leave the company.

$off $user = Read-Host -Prompt "Enter User Name" $computer = Read-Host -Prompt "Enter Computer Name" $date = Read-Host -Prompt "Enter Employee's Resignation Date ex. 5/18/2018" $datetime = [DateTime] "$date 17:00:00" Set-ADAccountExpiration -Identity $user -DateTime "$datetime" Set-ADComputer -Identity $computer -AccountExpirationDate "$datetime" Write-Host Waiting 10 seconds Start-Sleep -Seconds 10 Get-ADComputer -Identity $computer -Properties * | ft -Property Name, AccountExpirationDate Get-ADUser -Identity $user -Properties * | ft -Property SamAccountName, AccountExpirationDate