Hi all,
Been looking through the forums but have not found a way yet to achieve the following;
- I have a custom sensor which checks for blocked users with powershell, works great - I would like to send some kind of http(s) request to the prtg server which will run another powershell script to unlock the locked user, but only on demand, not automated.
The scripts are easy and already created and tested, see below. Thanks for any help in advance.
lockedusers.ps1:
Import-Module ActiveDirectory $server=Search-ADAccount -Lockedout -UsersOnly | select SamAccountName 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 | ConvertTo-Csv -NoTypeInformation | select -skip 1 ) -join ", ").replace("""","") + "</text>" Write-Host "</prtg>"
unlock.ps1:
Search-ADAccount -LockedOut | Unlock-ADAccount
Add comment