using this powershell
function Get-AdminUser {
param([string] $username)
$admingroup = Get-LocalGroupMember -Group "Administrateurs"
$userType = "Local user"
foreach ($admin in $admingroup) {
$name = $admin.name -split "\\"
if($name[1] -eq $username){
$userType = "Admin user"
}
}
return $userType
}
function Get-Size
{
param([string]$pth)
"{0:n2}" -f ((gci -path $pth -recurse | measure-object -property length -sum).sum /1mb)
}
$users = Get-LocalUser | Select *
foreach ($user in $users) {
if($user.Name -ne $null){
$userType = Get-AdminUser $user.Name
$path = "C:\Users\"+ $user.Name
$folderSize = Get-Size $path
if($user.Enabled -ne "False") { $userStatus = "Disabled" } else { $userStatus = "Enabled" }
$xml += "<WINUSERS>"
$xml += "<NAME>"+ $user.Name +"</NAME>"
$xml += "<TYPE>"+ $userType +"</TYPE>"
$xml += "<SIZE>"+ $folderSize +"</SIZE>"
$xml += "<LASTLOGON>"+ $user.LastLogon +"</LASTLOGON>"
$xml += "<DESCRIPTION>"+ $user.Description +"</DESCRIPTION>"
$xml += "<STATUS>"+ $userStatus +"</STATUS>"
$xml += "<USERMAYCHANGEPWD>"+ $user.UserMayChangePassword +"</USERMAYCHANGEPWD>"
$xml += "<PASSWORDEXPIRES>"+ $user.PasswordExpires +"</PASSWORDEXPIRES>"
$xml += "<SID>"+ $user.SID +"</SID>"
$xml += "</WINUSERS>"
}
}
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::WriteLine($xml)
get this in ocsinventory log
EXECUTABLE PLUGIN => Plugin <teamviewer.vbs> executed successfully
EXECUTABLE PLUGIN => Found executable plugin <uptime.vbs>
EXECUTABLE PLUGIN => Plugin <uptime.vbs> executed successfully
EXECUTABLE PLUGIN => Found executable plugin <winupdate.vbs>
EXECUTABLE PLUGIN => Plugin <winupdate.vbs> executed successfully
EXECUTABLE PLUGIN => Searching for PS1 script(s) in folder <C:\Program Files (x86)\OCS Inventory Agent\plugins>
EXECUTABLE PLUGIN => Found executable plugin <services.ps1>
EXECUTABLE PLUGIN => Plugin <services.ps1> executed successfully
EXECUTABLE PLUGIN => Found executable plugin <winusers.ps1>
WARNING *** EXECUTABLE PLUGIN => Executable plugin <C:\Program Files (x86)\OCS Inventory Agent\plugins\winusers.ps1> output is not UTF-8 encoded or an XML document, trying to UTF-8 encode
WARNING *** EXECUTABLE PLUGIN => Executable plugin <C:\Program Files (x86)\OCS Inventory Agent\plugins\winusers.ps1> output encoded to UTF-8, trying to reload XML document
ERROR *** EXECUTABLE PLUGIN => Executable plugin <C:\Program Files (x86)\OCS Inventory Agent\plugins\winusers.ps1> output is not a valid XML document
AGENT => Sending Inventory