What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Run a script (eg powershell) on demand

Votes:

0

Your Vote:

Up

Down

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
{
    [email protected]($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

http-request manual powershell unlock users

Created on Jun 16, 2015 8:40:50 AM by  mhelsdingen (0) 1

Last change on Jun 16, 2015 8:58:05 AM by  Torsten Lindner [Paessler Support]



9 Replies

Votes:

0

Your Vote:

Up

Down

Have a look at the HTTP Push Data (Advanced) sensor - configure the script to run as notification when the sensor receives a certain value and pass the data to the notification :)

Created on Jun 16, 2015 8:56:51 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Followed your suggestion. Log shows : Threshold Trigger sending Email,EXE (Sensor/Source/ID: 3500/3500/1).

But the locked account is still locked afterwards. Suggestions?

Created on Jun 16, 2015 10:10:46 AM by  mhelsdingen (0) 1



Votes:

0

Your Vote:

Up

Down

I configured it this way, I can see how it should work. I do see that my script is being called but the account is not unlocked. Where can i find the logging on the script?

HTTP Push Data Advanced BETA Unlock On Demand Notification Info Threshold Trigger sending Email,EXE (Sensor/Source/ID: 3500/3500/1)

Should testing the notification also run the exe? I think so right? But thats not working either. Running the script through powershell on the probe does work... Any clue for me?

Created on Jun 16, 2015 11:41:15 AM by  mhelsdingen (0) 1



Votes:

0

Your Vote:

Up

Down

Testing it should work as well, given that the parameters are correct and that the script works when executing on the command line - is that the case? Can you paste the parameters configured?

Created on Jun 16, 2015 12:45:08 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

The script on its own should simply unlock all locked users, i wouldnt know what parameter to pass;

Import-Module ActiveDirectory Search-ADAccount -LockedOut | Unlock-ADAccount

When executing powershell.exe -File "c:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\og-unlock_users.ps1" it works just fine...

Created on Jun 16, 2015 12:53:37 PM by  mhelsdingen (0) 1



Votes:

0

Your Vote:

Up

Down

Fair enough - is the PRTG service running as a different user without administrative permissions?

Created on Jun 16, 2015 1:31:18 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

PRTG runs as local system account... Any suggestions to try?

Created on Jun 16, 2015 1:34:22 PM by  mhelsdingen (0) 1



Votes:

0

Your Vote:

Up

Down

Supplying another account in the custom notification fixed the issue. Thanks for setting me on the correct path! It works like a charm now. Using iControl web I can now unlock user accounts from my Apple watch like any lazy admin should want :)

Created on Jun 16, 2015 2:20:57 PM by  mhelsdingen (0) 1



Votes:

0

Your Vote:

Up

Down

Hehe glad that it's solved :)

Created on Jun 17, 2015 5:16:13 AM by  Stephan Linke [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.