How to run a command in cmd.exe off of a trigger

  • Banned

    I have a trigger so that when one of my sites goes down in IIS it will automatically be sent an "iisreset" command in cmd.exe. However, I'm having problems getting it to execute. Could someone tell me what I need to put in the command line and script body? Thanks!

  • administrators

    Hey @Donnieclark , the link you posted looks like they're trying to run a powershell script from Manage Engine OpManager that runs iisreset on a remote computer using PowerShell remoting? I assume you want to try using TRIGGERcmd to run the remote command instead of PowerShell remoting.

    If so, you could do the following:

    • Install the agent on the IIS web server.
    • Create a triggercmd command with iisreset in the command field and Restart IIS in the trigger field.
    • Install curl on the OpManager server

    Have OpManager run this curl command:

    If OpManager is a Windows server you have to escape the quotes inside the quotes:

    curl -X POST -H "authorization: Bearer (insert token here)" -H "content-type: application/json" -d "{\"computer\":\"IISServer01\",\"trigger\":\"Restart IIS\"}"

    If OpManager is a Linux server you don't have to escape the inner quotes:

    curl -X POST -H 'authorization: Bearer (insert token here)' -H 'content-type: application/json' -d '{"computer":"IISServer01","trigger":"Restart IIS"}'

    This assumes your IIS server's name is IISServer01.

    Let me know if I'm off-base or if this is what you're looking for.

Log in to reply

Looks like your connection to TRIGGERcmd Forum was lost, please wait while we try to reconnect.