1 # take input object and write metric for psepa
   2 #   example:  get-process | write-epa -mname "processname" -mvalue "handles" -longname "Windows`|Processes`|" 
   3 #   Use any piped object as input, specify the metric name with -mname, specify the value with -mvalue,  specify a prefix name with -longname
   4 function write-epa {
   5 param( [string]$mname = "name", [string]$mvalue = "value",[string]$longName="Default`|") 
   6 begin { $x2 = 0; }
   7 process {
   8         foreach ($thing in $input) {     
   9                  $mn = $thing."$mname"
  10                  $mv = $thing."$mvalue"
  11                  $isNumber = [System.Int32]::TryParse($mv, [ref] ($x2))
  12                 if ($isNumber) { [Int]$mvv = $mv } else { [string]$mvv = $mv }
  13                 $smetric =  $longName + $mn + ":" +$mvalue.toString() + "=" + $mvv
  14                 write-host $smetric 
  15                 
  16 
  17         }
  18  }
  19  }