Powershell Module

You will need to Download the “MikroTik-PS-Module.zip”, located at the bottom of the OP (or simply Click the Link, I left below)

After extracting the ZIP Folder, you should see the resulting “MikroTik-PS-Module” Folder, which should contain the “MikroTik.dll” file, along with a “README.txt” File, containing Instructions, Examples, etc.

MikroTik-PS-Module.zip Download:
https://forum.mikrotik.com/download/file.php?id=24687

If for some reason, you don’t see the “MikroTik.dll” File, in the Extracted Folder, I would check your Anti-Virus, to ensure that it hasn’t Quarantined the File, for some reason or another.

I should also note that Windows 10/11 may block DLL Files that have been Downloaded from the Internet. As a result, you may have to Unblock the File.

To accomplish this task, simply Right-Click on the “MikroTik.dll” File and Select the “Properties” from the Drop-Down/Context Menu.

Once the “Properties” Panel Opens, Select the “General” Tab and if you can see an “Unblock” Checkbox toward the bottom of the Panel, you’ll want to Check the box and Click the “Apply” Button, in the Bottom-Right of the Panel, to Unblock it.

I hope this explanation is helpful.

I would try it with an Empty Password String, as follows.

$Login=Connect-Mikrotik -IPaddress 192.168.30.1 -UserName admin -Password ""

If the Script above doesn’t produce the expected results, you could try the following method.

$Password = ([string]::Empty)
$Login=Connect-Mikrotik -IPaddress 192.168.30.1 -UserName admin -Password $Password

Please, report back, to let us know whether one or the other (or both) worked, or not.
It would be greatly appreciated.

I experimented with the Script related Commands a bit and based on my findings, I am NOT able to find any evidence that the Author implemented the “/system/script/run” Command, into the MikroTik PowerShell Module.

I created a Script, named simply “test” (which was allocated the “id” of “*e”), which writes the word “Test” to the MikroTik Log, specifically for Testing.

From the MikroTik CLI, I had no problem running the following Commands, nor did I have any problems running their PowerShell equivalents.

MiktoTik CLI Command (Name):

:put [system script get test]

PowerShell Equivalent (Name):

Send-Mikrotik -Connection $C -Command "/system/script/getall" -Filters "name=test"

MiktoTik CLI Command (ID):

:put [system script get *e]

PowerShell Equivalent (ID):

Send-Mikrotik -Connection $C -Command "/system/script/getall" -Filters ".id=*E"

Output from MikroTik CLI & PowerShell Equivalent:

.id=*E=name=test=owner=admin11=policy=reboot,read,write,test,sniff,sensitive=last-started=jul/08/2023 13:50:36=run-count=2=source=log info test=invalid=false

When it came to Running the Script, I had No issues, when Running the following Commands from the MikroTik CLI.

MiktoTik CLI Command (Name):

system script run test

MiktoTik CLI Command (ID):

system script run *e

Unfortunately, the PowerShell Equivalents did Not work, at all.

PowerShell Equivalent (Name):

Send-Mikrotik -Connection $C -Command "/system/script/run" -Filters "name=test"

PowerShell Equivalent (ID):

Send-Mikrotik -Connection $C -Command "/system/script/run" -Filters ".id=*E"

Output from PowerShell Equivalent:
script not found

I tried several variations of the two PowerShell Scripts above, but each and every time, the “Script not found” message was returned.

On a positive note, I was able to find a couple Discussions, that do a decent job of explaining how calls are made to via MikroTik API, in relation to Running Scripts, etc.

Run scripts from API:
http://forum.mikrotik.com/t/run-scripts-from-api/47753/1

Running a script from API:
http://forum.mikrotik.com/t/running-a-script-from-api/36649/1

That being said, I plan on going through the Source Code for the MikroTik PowerShell Module, to determine whether the “/system/script/run” Command has been Implemented and if Not, I’ll do what I can, to implement it, myself.

Didn’t you realize that whoever you answer to hasn’t visited the forum for years and these are all old questions???

For example @tecnidom visited the forum only 3 years ago, the day he wrote the question, and then he disappears…


If you want to help others, answer the recently opened questions instead of the ones opened more than 3 years ago…