r/scripting • u/HotInspection • Sep 18 '18
Removing user files from all servers through AD sync
Hey guys,
I got another difficult one, I need to make something with powershell to erase all the files from deleted users on the servers in our network. It needs to sync with our AD, to see if the user is still there or is deleted. Has to know the difference between deleted and disabled.
Anyone that can help me???
Thanks in advance!!!!
3
Upvotes
2
u/HotInspection Sep 18 '18
Does no one know a script for this? I can't really seem to find it.
2
u/Lee_Dailey Sep 18 '18
howdy HotInspection,
i've seen a few such scripts, but never paid much attention since i have no need for it. [grin]
try doing things in steps.
either by lastaccesstime on the user profile dir, or by comparing with a recent AD user list.
Use PowerShell to remove local profiles | Learn Powershell | Achieve More
— https://learn-powershell.net/2011/01/27/use-powershell-to-remove-local-profiles/
.. to remove the profiles.
another option would be to use a GPO to remove the old profiles after 30/60/90 days of inactivity.
take care,
lee
2
u/Reo_Strong Sep 19 '18
How about a mild change to your thinking:
This maintains your unique identifiers for the accounts and allows you to generate a list of past employees as well as disabled accounts soley by OU.
You can then use that to filter for any owned files as this is unique ID (GUID?) is how NTFS tracks them.