Skip to content

Lynna Jackson

Lab/Classroom Computer and Software Managment

  • Home
  • The 100 mile view

Windows 10 – Removing old AD user account and profiles

There is apparently a way to delete accounts on systems that haven’t been used in over 30 days with an AD Group Policy setting. I found that this GP setting did not work on the Windows 10 systems I manage. Also, even if it did work, there are a few accounts on these systems that I do not want deleted even if they haven’t been used in months. Therefore, I came up with a powershell script based on many other people’s work that deletes user accounts and profiles that haven’t been used in over 30 days.

Download powershell script to delete 30 day unused user accounts and user profiles

Before running this script on your systems, edit it with a script editor to review the details within the script!!!

To run this script, I also recommend you open an administrative command prompt and give the commands:

cd c:\users

dir /od /ta

This will give you a sorted list of the accounts and the last time the account profile was accessed. You can compare that list to the accounts that will be deleted when running the script. Note that if the list of users to delete is long, you may get quota violations when running the script. When this happens I reboot and run the script again.

To run the script open a powershell window with “run as administrator” and run the script from whatever directory you have saved it in. When running the script be sure to check the list of accounts about to be deleted for any accounts you don’t want to delete. If you see any, you can exit the script as instructed and then edit the script to add the accounts you don’t want deleted to the line indicated in the script.

——————————-

On the windows systems I manage I have already pre-loaded my private version of the script in a specific folder so the steps to run this are:

  • 1) Login with the lab administrator account
  • 2) Open a Powershell command window “Run as Administrator” (click on the magnifying glass in the bottom left, type Powershell, Right-click on the PowerShell App and select “Run as administrator” …)
  • 3) Give the following three commands:
  • set-executionpolicy unrestricted

    C:\williams\DeleteOldUsers.ps1

    set-executionpolicy undefined

This entry was posted in Labs and tagged User_Profile, Windows 10 on May 11, 2017 by Lynna Jackson.

Post navigation

← Windows 10 – Install to external USB drive Mac – NoMAD – AD functionality to macs without binding →

Tags

  • Active_Directory
  • Adobe
  • AFP
  • ARD
  • Background
  • Boot
  • Bootcamp
  • Chrome
  • Command
  • Default User
  • DEP
  • Deployment
  • Dual_Boot
  • El Capitan
  • External boot
  • GIS
  • Group_Policy
  • High Sierra
  • Image
  • Installer
  • JAMF
  • KACE
  • Keyserver
  • Kiosk
  • Lion
  • Login
  • Macintosh
  • Matlab
  • Mavericks
  • Mt Lion
  • Novell
  • Packaging
  • Reference
  • Security
  • Silent Installer
  • SIP
  • Sleep
  • Software
  • Spss
  • Startup
  • User_Profile
  • VectorWorks
  • Windows
  • Windows 10
  • Windows to Go

Contact Me

Contact me by email ... [email protected]
Proudly powered by WordPress