What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Powershell, using exchange plugin

Votes:

0

Hi, I need to run a powershellscript in prtg but unfortunatly when i run the script i prtg it states that the command is not found (get-mailboxfolderstatistics). I understand that this is a command associated with exchange powershell. Is there any way to "add" these command to prtg powershell in order to monitor exchange with powershell?

exchange powershell script

Created on Oct 9, 2012 8:41:43 AM



3 Replies

Votes:

0

Hi,
do you have installed PRTG on a 64 bit OS? If you may take in account that PRTG is a 32 bit application and therefore uses the 32 bit powershell (where the mentioned commands may not be present or have to be set up first).
If you are dependent on the 64 bit powershell, you might have a look at this article which is outlining how to force the usage of 64 bit powershell with PRTG.
Best regards

Created on Oct 9, 2012 12:02:07 PM by  Konstantin Wolff [Paessler Support]



Votes:

0

In our setup we placed a probe on a seperate server (not the PRTG main server) We installed the Exchange Management Console (and the exchange cmdlets) In the PRTG Custom Sensors Folder on the probe we placed this VB Script and run it as a custome sensor in PRTG on the same schedule (5 minutes) as the batch file below

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objDictionary = CreateObject("Scripting.Dictionary") 
 
Const ForReading = 1 
 
Set objFile = objFSO.OpenTextFile ("c:\ExchangeQueues\Exchange_Queue.txt", ForReading) 
i = 0 
Do Until objFile.AtEndOfStream 
strNextLine = objFile.Readline 
If strNextLine <> "" Then 
objDictionary.Add i, strNextLine 
End If 
i = i + 1 
Loop 
objFile.Close 

For Each strLine in objDictionary.Items 
WScript.Echo strLine & ":OK" 
Next
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Then in C:\ExchangeQueues we put this batch file and have it run on a schedule (5 minutes)

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -Command ". 'C:\Program Files\Microsoft\Exchange Server\Scripts\GetQueue.ps1'"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"place the name of your exchange server here" | Get-ExchangeServer | Get-Queue | foreach -begin {$total=0} -process {$total+=$_.messageCount} -end {$total} | Out-File -FilePath c:\ExchangeQueues\Exchange_Queue.txt -Encoding ASCII
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

In short the Schedule runs the .bat file, which runs the .psc script, the script queries the exchange server and writes to a .txt file which is read by the .vbs and imported into PRTG.

Its a bit long winded but works with any exchange cmdlet

Hope this helps

Created on Nov 23, 2012 1:56:27 PM

Last change on Nov 23, 2012 1:59:34 PM by  Konstantin Wolff [Paessler Support]



Votes:

0

Hi Sebastian, You have multiple options to grab data from Exchange.

1. You can colelct the data witrh an independet script, send th eoutput to a file and read that from PRTG. but thats not a "real way"

2. You can install Exchange Commandlets on the PRTG machine and let PRTG run the Powershell and load the commandlets. Unfortunaly PRTG uses the 32bit powershell and the Exchange 2010 Commandlets are not availible for 32bit.

3. you can run "remote Powershell". this is a effective way to grab a powershell session remotely. This is my recomended way because you can use 32bit Powershell even on Win2000 to "run" Exchange 2010 Commandlets. the remote system runds them. But you should be careful with the pipeline etc. Here a sample

 $session = new-pssession `
                               -ConfigurationName "Microsoft.Exchange" `
                               -ConnectionUri "http://exchangeserver/Powershell",`
                               -Authentication Kerberos
import-pssession -Session $session -AllowClobber | out-null

# do here what you want

# dont forget that otherwise c:\windows\temp will fill up !!!!
remove-pssession -Session $session

Created on Nov 25, 2012 12:04:37 PM

Last change on Nov 26, 2012 7:07:28 AM by  Konstantin Wolff [Paessler Support]




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.