My department wants a script to be run in Windows Powershell on our server that will remove users if their account is locked or hasn't been logged into for a long time. We started with using a C# script to pull from an excel sheet that shows when the last logins were, locked or unlocked, and users' names. How can I go about removing users from our server using a script?
You want to delete it with powershell, not C#, right? If that's the case, The thing you're looking is the Remove-LocalUser
command.
Remove-LocalUser -Name "NAME OF USER"
EDIT
If you have AD(Active Directory) users, it is almost the same:
Remove-ADUser -Identity NAMEOFUSER
I don't know how to delete any other kinds of users. Sorry!