We’re launching free support for BYOD Android devices and looking for early feedback. Interested?
Fleet’s built-in queries for collecting and storing important device information.
Windows
Users
Retrieves information about user accounts.
WITH cached_groups AS (select * from groups)
SELECT uid, username, type, groupname, shell
FROM users LEFT JOIN cached_groups USING (gid)
WHERE type <> 'special' AND shell NOT LIKE '%/false' AND shell NOT LIKE '%/nologin' AND shell NOT LIKE '%/shutdown' AND shell NOT LIKE '%/halt' AND username NOT LIKE '%$' AND username NOT LIKE '\_%' ESCAPE '\' AND NOT (username = 'sync' AND shell ='/bin/sync' AND directory <> '')
$users = Get-LocalUser -ErrorAction SilentlyContinue if ($users) {
$filtered = $users | Where-Object {
($_.Name -notmatch '\$$') -and ($_.Name -notmatch '^_')
}
$filtered | ForEach-Object {
[PSCustomObject]@{
# 'uid': No direct uid; using SID instead.
uid = $_.SID.Value
# 'username': Direct mapping from Name.
username = $_.Name
# 'type': No 'type' property; using a fixed value 'Local' for local accounts.
type = 'Local'
# 'groupname': No equivalent primary group info; set as 'N/A'.
groupname = 'N/A'
# 'shell': Not applicable on Windows; set as 'N/A'.
shell = 'N/A'
}
} | Format-Table -AutoSize
} else {
Write-Output 'No local users found.'
}
awk -F: 'BEGIN{while((getline<"/etc/group")>0){g[$3]=$1}} {uid=$3+0; if(uid<1000) next; if($7 ~ /\/(false|nologin|shutdown|halt)$/) next; if($1 ~ /\$$/) next; if($1 ~ /^_/) next; if($1=="sync" && $7=="/bin/sync" && $6!="") next; print $3, $1, "user", ($4 in g ? g[$4] : ""), $7}' /etc/passwd
PowerShell commands are currently work in progress, contributions welcome.
Bash commands are currently work in progress, contributions welcome.
Vitals