Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20490

Re: Re: Powershell Script Output Problem

$
0
0

Problem can be in dynamic number of outputs (Message & Statistic couples) of your script for which powershell component is not designed. If you want to get up to 10 outputs (which is limit) you can try following modification with placeholders:

 

$drivesNoLetter = gwmi -Query "Select * from Win32_Volume where DriveType=3 AND DriveLetter is NULL"
$counter = 0
foreach($drive in $drivesNoLetter)
{    if ($drive.Capacity -eq $null)    {        continue    }       $percentage = [Math]::Truncate(($drive.FreeSpace/$drive.Capacity)*100)                      $driveName = $drive.Name;    if ($percentage -le $args[0])    {        $counter +=1;        write-host "Message.$counter : Drive $driveName FreeSpace percentage $percentage"        write-host "Statistic.$counter : $percentage"    }       if ($counter -ge 10)    {        break;    }
}
while ($counter -le 9)
{    $counter +=1;    write-host "Message.$counter : placeholder"    write-host "Statistic.$counter : 0"
}

 

Then you will need to use "Get script output" from script editor on application edit page to prepare output fields for powershell component. Once fields for component are created, you can modify script removing final part that generates placeholders.


Viewing all articles
Browse latest Browse all 20490

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>