Community discussions

MikroTik App
 
User avatar
space007
just joined
Topic Author
Posts: 23
Joined: Tue Dec 07, 2010 12:30 pm

Execute on server - Windows/Powershell/Teams

Wed Sep 18, 2019 11:34 am

Hello ppl,

Version: 4.beta3,
Os: Windows Server 2016

Its a Notify topic. I am trying to execute a local powershell on the server:
"powershell.exe -ExecutionPolicy Bypass -RunType $true -Path C:\Tools\NotifyTeamsChannel.ps1 -text "Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])""
Is this going to work ? Does the Windows version of the old Dude able to run external commands like this ?

Thanks for your time!
 
User avatar
geoffsmith31
Member Candidate
Member Candidate
Posts: 155
Joined: Fri Nov 05, 2010 6:08 am
Location: Toowoomba, Australia

Re: Execute on server - Windows/Powershell/Teams

Sat Sep 21, 2019 11:43 pm

Yes "execute on server" is definitely a working function. This is the reason that we have not been able to upgrade beyond 4b3 as since that version there is no longer a Windows server option for Dude. The syntax for the command is extremely unforgiving and there is not much help available for it. I'm happy to share examples of the working functions that I have set up so you can use that as a guide if you want. Just not in a position to do this easily at the moment. I don't believe that I've used a powershell command for any of my functions, only batch scripts and VB scripts. I know there is some trickery necessary to get a powershell script to run as a Windows scheduled task so this is also likely to apply for a Dude function.
 
User avatar
geoffsmith31
Member Candidate
Member Candidate
Posts: 155
Joined: Fri Nov 05, 2010 6:08 am
Location: Toowoomba, Australia

Re: Execute on server - Windows/Powershell/Teams

Sun Sep 22, 2019 12:40 am

FYI - the following is the execute part of a probe that I wrote a few years ago:
execute("link-test.bat",concatenate(device_property("FirstAddress")," ", device_property("CustomField2")),"c:\\snmpget")
"link-test.bat" is the batch script to be run
concatenate(…..) puts together some parameters to be fed into the batch script
the batch script is in the C:\snmpget folder on the Dude server. Note the double back-slash in the command which I needed to put in to get Dude to correctly interpret the path.

I have some other examples but this was probably the simplest I can dig up at the moment.

Who is online

Users browsing this forum: No registered users and 6 guests