Jump to content
Software FX Community

out-gauge: Using refresh with a multiline statement


Recommended Posts

Should the refresh work properly in a case like this where a declare a multiline statement directly in the shell?

new-timespan -start (get-date) -end (get-date -hour 13 -minute 00)| `out-gauge -value totalminutes -type digital -refresh 00:01:00 -floating `-topmost -titles_0_text "Minutes left" -titles_0_layout_target AnchorPoint `-titles_0_layout_anchorpoint 0.5,0.10

I found it did *not* work.  I needed to declare everything on one single line for the refresh to properly work.

Marco

Link to comment
Share on other sites

Unfortunately the mechanism we use to get the command being executed only returns information about the current line, so in your test, out-gauge sees no previous command. The problem can get worse if you do something like

get-date -uformat `"%S" | out-gauge -refresh 0:0:15

In this case out-gauge thinks the command needed to refresh is "%S" so that's what we will show when the refresh timer fires (or in a non-refresh chart if you right-click and select Refresh).

We are already doing some innecessary parsing because of limitations of the cmdlet invocation info exposed by PowerShell and we discussed that with the PowerShell team. This bug just highlights the hack we had to do in order to support refresh.

JuanC

Link to comment
Share on other sites

  • 1 month later...

I'm running into the same problem I believe but what really bites is that I'm not using refresh at all.  Here's what I have in my script that doesn't work:

gci . -rec | select @{n='LastWriteDate';e={$_.LastWriteTime.Date}} |   group LastWriteDate | sort Name |   out-chart

Also note that because of this, I also can't do the following:

$results = gci . -rec | select @{n='LastWriteDate';e={$_.LastWriteTime.Date}} |   group LastWriteDate | sort Name$results | Out-Chart

This is a bummer because I have a common query that I either display in text to the console or chart.  Now I have duplicate queries and that just isn't very maintainable.  It seems I'm paying the price for the -refresh functionality even though I'm not using it.

BTW I think I might have also found another bug perhaps related to parsing of PowerShell script.  This doesn't work:

107# $limit = (get-date).AddDays(-30).Date108# gci . -rec | where {$_.LastWriteTime.Date -ge $limit} | select @{n='LastWriteDate';e={$_.LastWriteTime.Date}} | group LastWriteDate | sort Name | out-chart

But this does:

109# gci . -rec | where {$_.LastWriteTime.Date -ge (get-date).AddDays(-30).Date} | select @{n='LastWriteDate';e={$_.LastWriteTime.Date}} | group LastWriteDate | sort Name | out-chart

The only difference is the use of $limit versus the low level get-date/AddDays calculation.  I pulled my hair out on that one for a while (cursing PowerShell for this unexpected behavior).

Link to comment
Share on other sites

The bug with $limit is not handling white space correctly for a datetime variable, we've fixed this in our internal build and future service packs will include the fix. You can workaround this by setting $limit = (get-date).AddDays(-30).ToShortDateString()

The reason why this fails even though you are not doing refresh is the use of grouping. You could also work around this by using -modal in your chart. This has an additional performance advantage when your command might take some time (gci . -rec) as you are not executing it twice. Obviously -modal has some drawbacks because of its modality.

Regards,

JuanC

ChartFXTest.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...