New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

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

Free PRTG
Download >>

 

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

 

Top Tags


View all Tags


Is it possible to use the 64bit version of Powershell with PRTG?

Votes:

1

Your Vote:

Up

Down

Can I use the 64bit version of Powershell in an EXE/Script Sensor in PRTG?

64bit custom-script-exe exe-script-sensor powershell prtg script

Created on Feb 10, 2012 3:13:36 PM by  Konstantin Wolff [Paessler Support]

Last change on Mar 19, 2015 3:41:08 PM by  Martina Wittmann [Paessler Support]



11 Replies

Accepted Answer

Votes:

1

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 9 or later, installed on a 64bit OS

How to Use 64bit Powershell with EXE/Script Sensors

The short answer is: Yes, you can do so. Please see the following description for details.

Background

Sometimes you may need to use the 64bit version of Powershell for some special queries. But as PRTG is a 32bit application it cannot create 64bit child processes.

Solution

You have to add an additional layer between the Powershell and PRTG to get this running. As PRTG can start 64bit applications and this application further can create a 64bit child process we just create this application.

To solve this issue, you can write a little C# program which does nothing else than starting the 64bit Powershell, passing arguments to it and then give back the results to PRTG.

This can be done with the following code:

using System.Diagnostics;
static class Program {
    static int Main(string[] args) {
        ProcessStartInfo i = new ProcessStartInfo("powershell", args[0]);
        i.UseShellExecute = false;
        using(Process p = Process.Start(i)) {
            p.WaitForExit();
            return p.ExitCode;
        }
    }
}

The code has to be compiled in Visual Studio using the "Any CPU" option. This setting will force the program running in 64bit and it will create 64bit child processes.

Now just place the .exe file in the "Custom Sensors" sub directory of your PRTG installation folder and add an EXE/Script Sensor or a EXE/Script Advanced Sensor with the .exe file as executable.

Important

Please note that the code shown above is only an example and will just give back the raw output of the Powershell command to PRTG. In most cases this output will not be formatted for usage in PRTG. Please extend the code to fit your needs.

Created on Feb 10, 2012 3:34:50 PM by  Konstantin Wolff [Paessler Support]

Last change on Feb 10, 2012 3:48:17 PM by  Daniel Zobel [Paessler Support]



Votes:

2

Your Vote:

Up

Down

PTF.PSx64

For everyone that does not have Visual Studio at hand, there is a Custom Sensor available at PRTGToolsFamily.com that does exactly what is described above.

PSx64 executes a PowerShell script in 64 bit mode and returns both the script result and exit code to PRTG.

Created on Feb 10, 2012 8:47:31 PM by  PRTG Tools Family [prtgtoolsfamily.com] (12,865) 3 4

Last change on Jul 3, 2013 5:34:17 PM by  Patrick Hutter [Paessler Support] (7,164) 3 3



Votes:

0

Your Vote:

Up

Down

Hello,

Understand this is an old topic but I am having the same issue and whilst I get close to a solution I am always stumble over a problem.

1. The PSx64 wrapper works. But I am nervous about placing a third party .exe on a production machine without knowing the full extent of the logic in the source code. Is there any chance I can get a copy of the source code for this and compile myself?

2. I took the sample C# code that was above the last post and did compile it for the x64 platform and deployed it to the EXE Custom Sensor folder. The PS1 script I have is using DFRS module which is x64 hence the issue. This works fine at the command prompt. However, when executing from within PRTG context the majority of the code works until it comes to a WRITE-HOST statement which I use to output the prtg formatted count:message result of the script. At that point in time I get a PS message indicating that "Write-Host" is not a known cmdlet.

Any Ideas would be appreciated. As mentioned the PSX64.exe works. Therefore, it must be doing something a lot more to handle the x32 vs x64 issue and evoking the correct instance of PS. But as I say, I would liek to have access to the source so that I can be comfortable with it running on a production platform.

Thanks in advance.

Created on Jan 19, 2017 6:34:28 AM by  tgm (90) 1 1



Votes:

0

Your Vote:

Up

Down

Hi tgm,

Please send an email to support@prtgtoolsfamily.com and we will be happy to supply you with the (vb.net) source code of the PSx64 wrapper.

Created on Jan 19, 2017 8:33:29 AM by  PRTG Tools Family [prtgtoolsfamily.com] (12,865) 3 4



Votes:

1

Your Vote:

Up

Down

Hi,

I was also searching for a solution to run code with a 64-bit module from a custum EXE/XML sensor in PRTG. Eventually I was able to solve my problem using a different approach (since I'm not really into programming in C#).

I created two scripts;

  • One is being ran as a scheduled task, which calls the script with the 64-bit powershell module. The script produces the output that I need for my sensor and outputs it to a file I specified on top of the script;
********** Snippet from first script **********

#Feeding the result to PRTG.
Write-Output "<prtg>
                 <result>
                 <channel>Some channel you need</channel>
                 <value>$value</value>
                 </result>
                 <result>
                 <channel>Another possible channel</channel>
                 <value>$value</value>
                 </result>
              </prtg>" | Out-File $outputDirAndName

********** Snippet from second script **********

#If the last written time was less then the warnings threshold, show the result from the inputfile, else trigger an alert.
if($lastWrittenTimeInMinutes -lt $warningThresholdInMinutes){
 
    Get-Content $inputFile

}
else{

    Write-Output " <prtg>
                       <error>1</error>
                       <text>Check Scheduled Task!</text>
                   </prtg>"

}
  • The second script is the one PRTG actually targets (and calls with the 32-bit Powershell) and simply uses the "Get-Content" cmdlet to retrieve the results that the 64-bit Powershell has generated. One catch here; we need to be able to tell the difference between the result of the script triggering an alert and the fact that the scheduled task might not have ran for a while. So the second script should also look at the modified time of the input file.

So, if the file has been modified in less minutes then the warning threshold I specified on top of the script (meaning the scheduled task has ran), the sensor retrieves the values with "Get-Content". If the file wasn't modified in the number of minutes I specified, the scheduled task must not have ran and the sensor will output an alert saying I need to check it.

Just setup the channels now with the desired thresholds and you're good to go.

This solution might seem a bit devious at first, but I know exactly what the code running here is doing.

Hope this helps someone.

Created on Apr 15, 2017 2:48:45 PM by  Sidney (10) 1

Last change on Apr 17, 2017 4:34:24 PM by  Felix Saure [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Is there any chance we might get to a 64 bit PRTG which can subsequently launch 64 bit powershell? As Microsoft moves into a 64-bit world, more and more of those PS modules are 64 bit only and this is becoming a real hassle to work around.

I just spend all day trying every workaround everyone else mentioned, launching powershell-64 bit exe from a powershell-32 exe, but that didn't work. Tried using a CMD and a BAT file to launch it but that didn't work. The powershell.exe that showed up in task manager was always the 32 bit no matter what.

I ended up using the suggestion posted above using a scheduled task to generate a text file, and then writing a sensor to read that text file. It's clumsy but it works.

It would be great if we could get a 64 bit PRTG on the roadmap though...it's going to be necessary.

Created on Dec 12, 2017 9:28:45 PM by  amikolajczyk (100) 1



Votes:

0

Your Vote:

Up

Down

Hi,

Creating an x64 version of the PRTG Probe Service might be part of future PRTG versions, I cannot tell you when this is going to happen at the moment. Thanks for your feedback!

Best regards, Felix

Created on Dec 13, 2017 1:56:41 PM by  Felix Saure [Paessler Support]



Votes:

1

Your Vote:

Up

Down

Hi, just a big up for this topic! We really need an x64 version of the PRTG probe service.

Please, may the gods hear us!! Nicolas

Created on Sep 12, 2018 2:42:49 PM by  Nicolas Jançon (10)



Votes:

0

Your Vote:

Up

Down

Created on Nov 28, 2018 8:25:15 AM by  olivier girard (0)

Last change on Nov 28, 2018 8:27:16 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

We're half way through 2019, where on the road map is refactoring PRTG to x64?

Created on Jun 13, 2019 10:46:52 AM by  BiggsSkeed (0) 1



Votes:

0

Your Vote:

Up

Down

Hi there,

The Core Server already runs under 64-Bit, however for the Probe there are no plans to make it 64-Bit compatible at the moment (which then allows you to run 64-bit based sensors).

best regards

Created on Jun 13, 2019 6:10:47 PM by  Dariusz Gorka [Paessler Support]

Last change on Jun 13, 2019 6:11:19 PM by  Dariusz Gorka [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.