diff --git a/agent/winusers.ps1 b/agent/winusers.ps1
index fe0a44c..16bea04 100644
--- a/agent/winusers.ps1
+++ b/agent/winusers.ps1
@@ -1,12 +1,12 @@
function Get-AdminUser {
param([string] $username)
$admingroup = Get-LocalGroupMember -SID "S-1-5-32-544"
- $userType = "Local user"
+ $userType = "Local"
foreach ($admin in $admingroup) {
$name = $admin.name -split "\\"
if($name[1] -eq $username){
- $userType = "Admin user"
+ $userType = "Admin"
}
}
@@ -16,10 +16,13 @@ function Get-AdminUser {
function Get-Size
{
param([string]$pth)
- "{0:n2}" -f ((gci -path $pth -recurse | measure-object -property length -sum).sum /1mb)
+ try {
+ "{0:n2}" -f ((gci -path $pth -recurse -ErrorAction Ignore | measure-object -ErrorAction Stop -property length -sum).sum /1mb)
+ } catch {
+ "{0:n2}" -f 0
+ }
}
-
$users = Get-LocalUser | Select *
$pathUsers = "C:\Users"
$allUsers = @()
@@ -31,18 +34,19 @@ foreach ($user in $users) {
$path = "C:\Users\"+ $user.Name
$folderSize = Get-Size $path
if($user.Enabled -ne "False") { $userStatus = "Disabled" } else { $userStatus = "Enabled" }
-
- $xml += ""
- $xml += ""+ $user.Name +""
- $xml += ""+ $userType +""
- $xml += ""+ $folderSize +""
- $xml += ""+ $user.LastLogon +""
- $xml += ""+ $user.Description +""
- $xml += ""+ $userStatus +""
- $xml += ""+ $user.UserMayChangePassword +""
- $xml += ""+ $user.PasswordExpires +""
- $xml += ""+ $user.SID +""
- $xml += ""
+ if($userType -eq "Local") { $userType = $user.PrincipalSource }
+
+ $xml += "`n"
+ $xml += ""+ $user.Name +"`n"
+ $xml += ""+ $userType +"`n"
+ $xml += ""+ $folderSize +"`n"
+ $xml += ""+ $user.LastLogon +"`n"
+ $xml += ""+ $user.Description +"`n"
+ $xml += ""+ $userStatus +"`n"
+ $xml += ""+ $user.UserMayChangePassword +"`n"
+ $xml += ""+ $user.PasswordExpires +"`n"
+ $xml += ""+ $user.SID +"`n"
+ $xml += "`n"
$allUsers += $user.Name
}
@@ -61,11 +65,11 @@ foreach ($userAd in $usersAd) {
$path = "C:\Users\"+ $userAd
$folderSize = Get-Size $path
- $xml += ""
- $xml += ""+ $userAd +""
- $xml += "Domain user"
- $xml += ""+ $folderSize +""
- $xml += ""
+ $xml += "`n"
+ $xml += ""+ $userAd +"`n"
+ $xml += "Domain`n"
+ $xml += ""+ $folderSize +"`n"
+ $xml += "`n"
}
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
diff --git a/infos.json b/infos.json
index 8b9dc87..0f9e828 100644
--- a/infos.json
+++ b/infos.json
@@ -1,9 +1,9 @@
{
"displayName" : "Winusers",
"author" : ["J.C.BELLAMY"],
- "contributor" : ["Guillaume PRIOU", "Gilles DUBOIS", "Rudy LAURENT"],
+ "contributor" : ["Guillaume PRIOU", "Gilles DUBOIS", "Rudy LAURENT", "Charlene AUGER"],
"supportedAgent" : ["Windows"],
- "version" : "3.1",
+ "version" : "3.2",
"licence" : "GPLv2",
"description" : {
"fr" : "Remonte les utilisateurs Windows",