i need your help guys.

Import-Module ActiveDirectory


$server=Search-ADAccount -Server [IP] -LockedOut -UsersOnly | select SamAccountName, Name
if ($server.count -eq $null -and $server -eq $null){
    $a=0
}
Elseif ($server.count -eq $null -and $server -ne $null){
    $a=1
}
Else
{
    $a=@($server.count)
    
}
Write-Host "<prtg>"
Write-Host "<result>" 
"<channel>Locked Out Users</channel>" 
    
"<value>"+ $a +"</value>" 
"</result>"
"<text>" + (($server | select SamAccountName, Name | ConvertTo-Csv -NoTypeInformation | select -skip 1 ) -join ", ").replace("""","") + "</text>"
Write-Host "</prtg>"

i can see the UserName und Name in my E-Mail notification if a User locked out. But i can't see the Username if a User not more locked.


Article Comments