I'm sure the script itself is fine but the parameters at the end for prtg I'm sure I'm getting wrong. What do you guys think?
$OU = "OU=test,OU=test,DC=test,DC=com"
- script to search active directory
$users = Foreach($OU in $OUs){ Get-ADUser -filter {enabled -eq $true} -SearchBase $OU -Properties lastlogondate | where-object {$_.lastlogondate -lt (get-date).AddDays(+60)} | Select-Object SamAccountName } #Count results $a = @($users.count) #Write to prtg Write-Host "<prtg>" Write-Host "<result>" "<channel>Users Count</channel>" "<value>"$a"</value>" "</result>" Write-Host "</prtg>"
Add comment