Remove-FileUser
Removes an user account
param([string]$username = "")
try {
if ($username -eq "") { $username = Read-Host "Enter the user name to remove" }
$stopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) {
& sudo deluser --remove-home $username
} else {
throw "Not supported yet"
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"? Removed user '$username' including home directory in $($elapsed)s."
exit 0 # success
} catch {
"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}