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


Powershell script works from Powershell prompt but not from PRTG

Votes:

0

Your Vote:

Up

Down

I have made a script that will give back the freespace on a quorumdisk for a cluster if the node you supplied as a parameter is active and if it is not active will return 0 with the text that it is not active.

This script is in the exe folder of main prtg server and it works fine if I run it from the powershell prompt but it wont give me back anything when it is executed from prtg itself. It does see the parameter but doesn't seem to be able to get anything from the get-wmiobject.

Any ideas?

This is the code :

param([string]$MACHINE)

if ($MACHINE -eq "")
{
 write-host "0:ERROR NO PARAMETER GIVEN"
 exit 2 
}
clear-host

# Define variables
# $MACHINE="zlm-webprd1"



# Get the currently active clusternode
[string]$CLUSTERNODE=Get-WmiObject -ComputerName $MACHINE -namespace "root/MSCluster" MSCluster_NodeToActiveGroup|%{$_.GroupComponent} 
[string]$CLUSTERNODE = [string]$CLUSTERNODE.Substring(20)

$CLUSTERNODE = $CLUSTERNODE -replace "`"",""

 

# Get the hostname from the currently connected system.
[string]$HOSTNAME=Get-Wmiobject -computername $MACHINE Win32_ComputerSYstem|%{$_.Name}

# Get the Quorum Disk
[string]$QUORUMDISK=Get-Wmiobject -computername $MACHINE -namespace "root/MSCLuster" MSCluster_ClusterToQuorumResource|%{$_.PartComponent}
[string]$QUORUMDISK = [string]$QUORUMDISK.Substring(30)
$QUORUMDISK = $QUORUMDISK -replace "`"",""


if ($CLUSTERNODE -eq $HOSTNAME)
 { 
  
  # Get the size and freespace of disk partitions and only select quorum disk
  $dsk= Get-WmiObject -computername $MACHINE Win32_LogicalDisk
  
  foreach ( $drive in $dsk ) 
  {
   if ($drive.name -eq $QUORUMDISK)
   { 
    [string]$TEMP1 = (($drive.Freespace)/($drive.size))*100
    [string]$TEMP1 = [string]$TEMP1 -replace " ",""
    write-host $TEMP1":ACTIVE"
   }
  }
  
 }
else
 {
  write-host "0:NOT ACTIVE"
  exit 1
 }

cluster powershell prtg quorum windows wmi

Created on Aug 13, 2010 11:17:08 AM by  Stefan Mansier (0) 1

Last change on Aug 13, 2010 11:28:30 AM by  Daniel Zobel [Paessler Support]



3 Replies

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Hello,

just to check the execution policy for powershell scripts is set to 'unrestricted'? Please bear in mind that there might be to powershell versions installed (32bit and 64bit) in case you use a 64bit Windows.

Best Regards.

Created on Aug 16, 2010 11:47:17 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Stefan, did you end up getting this issue resolved? We've got a similar issue (with the get-counter command rather than wmi) and are set to unrestricted so would love to hear if the solution was something else. Thanks. James.

Created on Oct 12, 2010 12:51:56 PM by  jhsubscribe (50) 1 1



Votes:

0

Your Vote:

Up

Down

Try running PowerShell 64bits and enabling the unrestricted permisions:

64bit version: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe

Run: set-executionpolicy unrestricted

Created on Jan 10, 2011 2:51:14 AM by  Oliver Schulze (0) 1



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.