PowerShell/scripts/list-user-accounts.ps1

25 lines
440 B
PowerShell
Raw Normal View History

2024-10-01 15:11:03 +02:00
<#
2022-10-25 15:58:33 +02:00
.SYNOPSIS
Lists user accounts
.DESCRIPTION
This PowerShell script lists the user accounts on the local computer.
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./list-user-accounts.ps1
2022-10-25 15:58:33 +02:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
2024-10-14 17:28:32 +02:00
if ($IsLinux) {
& getent passwd
} else {
& net user
}
2022-10-25 15:58:33 +02:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2023-08-06 21:35:36 +02:00
}