Jump to content
Software FX Community

Dastari

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Dastari

  1. Hey guys, I'v just got the trial of PowerGadgets to see what I can do with it and have my first question.

     I am trying to monitor hard drive space on a remote server that is firewalled except for port 80. What I am doing is running a batch file on the server every minute that dumps the result of a "dir" into a text file on the web folder so I can read it remotly. As an example I wrote this quick function to give you an idea:

     function GetBytesFree(){  $Url = "http://www.somewebsite.com/dir.txt"    $WebClient = New-Object System.Net.WebClient

        $Random = New-Object system.random   $DirResult = $WebClient.DownloadString($Url+"?t="+$Random.nextdouble())  $BytesFree = $DirResult | find "bytes free"  $BytesFree = $BytesFree.split(" ")[17]  return [double]$BytesFree}

    PS C:\> GetBytesFree55153283072

    Running this from the powershell console returns a double with the bytes free. It is correct and works fine. Now if i do a:

    PS C:\>  GetBytesFree | out-gauge -type digital -floating

    I get a nice digital display with the number in it, this works fine. But what I want to be able to do is update this every minute. However when I try to do a:

    PS C:\>  GetBytesFree | out-gauge -type digital -floating -refresh 0:1:0

    I get the output the first time, but when 1 minute passes I get the following error from the gauge:

    Failed to connect to Data "The term 'GetBytesFree' is not recognised as a cmdlet, function, operable program, or script file. Verify the term and try again.' 

    I realise that this is probalby not a PowerGadgets problem, but can anyone suggest a solution? Is it possible to put the function somewhere so it is exposed to the PowerGadget?

    Edit:

    After hunting around a bit more on the forums I found a post that mentioned when the -refresh is triggered a new instance of the Gadget with it's own runspace is created.  I will have a play around and see what I can work out.

     

    Thanks in advance.

×
×
  • Create New...