Jump to content
Software FX Community

Out-Chart does not work when information contains a \ character


trevorpalmer

Recommended Posts

I am using PowerGadgets Out-Chart to monitor all the Exchange 2007 Queues in our Environment.

My PowerShell script

get-exchangeserver | where-object {$_.IsHubTransportServer -eq $True} | get-queue | ft Identity, MessageCount

Produces the following output

Identity MessageCount--------  ------------GIMLDNEXH01\1466 0GIMLDNEXH01\1467 0GIMLDNEXH01\Submission 0GIMLDNEXH02\Submission 0GIMLDNEXHUB01\1520   0GIMLDNEXHUB01\1521   0GIMLDNEXHUB01\Submission   0

But when I pipe this to Out-Chart my X Axis is just numbered as 

1  2  3  4  5  6  7

instead of the actual Queue names shown in the Identity column.

 Is this a known limitation, a bug, or have I done something wrong?

 Many thanks.

Link to comment
Share on other sites

Please note that by using format-table as the last element in your pipe, you are transforming the output into a table and although on the console it looks like the right data, properties are buried deep into the output, e.g.

In a folder with a couple of CSV files type the following command

dir *.csv | get-member

You will see many properties and methods supported by the System.IO.FileInfo object, this means that potentially any of the numerical properties could be charted and any string properties could be used as labels. Now type the following

dir *.csv | ft Length,Name | get-member

Now instead of the 2 properties you will see a bunch of Internal objects like FormatStartData, GroupStartData, etc. none of these objects will show Length or Name as properties.

You have 2 options to get the chart you want

1) Use select-object (select) instead of format-table (ft)

get-exchangeserver | where-object {$_.IsHubTransportServer -eq $True} | get-queue | select {$_.Identity.ToString()}, MessageCount | out-chart[edit]Note that because Identity is a complex object you want to use ToString() in the select cmdlet

This cmdlet selects a subset of properties so that in the console the output looks similar to that of format-table but under the covers this cmdlet is doing a very different job. It is creating a new object that supports only the properties you selected, You can confirm this by typing

dir *.csv | select Length,Name | get-member

2) use -values and -label in out-chart to specify the columns you want to use

get-exchangeserver | where-object {$_.IsHubTransportServer -eq $True} | get-queue | out-chart -values MessageCount -label {$_.Identity}[edit]Note that because Identity is a complex object you want to use a scriptblock in the label parameter. You can also use Identity.ToString as in option 1.

Regards,

JuanC

Link to comment
Share on other sites

Hi Juan

 Thanks for your reply, but I am still having trouble with this out-chart.

I am having to create these charts in PowerGadgets Creator. as when I use out-chart with these exchange cmdlets nothing happens. If I issue a get-process | out-chart it does display the chart correctly.

If I use your first option, again it looks ok in the powershell, but I still do not get the queue names in my chart, it continues to display the 1 2 3 4 5 6 7 etc instead of the names.

[PS] C:\Shellscripts>get-exchangeserver | where-object {$_.IsHubTransportServer-eq $True} | get-queue | select {$_.Identity.ToString()}, MessageCount

$_.Identity.ToString() MessageCount---------------------- ------------GIMLDNEXH01\2092   0GIMLDNEXH01\2093   0GIMLDNEXH01\Submission   0GIMLDNEXH02\Submission   0GIMLDNEXHUB01\1899   0GIMLDNEXHUB01\1902   0GIMLDNEXHUB01\1903   0GIMLDNEXHUB01\1904   0GIMLDNEXHUB01\Submission   0GIMLDNEXHUB02\Submission   0

In the creator, I select the Auto-Format option and my queue names display correctly until the auto-refresh runs and then they go back to being numbers.

I can't use your second option because the out-chart doesn't display at all.

Regards

Trevor

Link to comment
Share on other sites

What is the exact out-chart command you are using?

As JuanC indicates, you have to call it something like

"out-chart -values MessageCount -label {$_.Identity}"

to get it to properly display like I think you want it.

[Edit: I clearly missed that the Creator was being used, and out-chart wasn't being called directly from the PowerShell command-line.]

Link to comment
Share on other sites

At the moment I can't use the out-chart commands for Exchange as the chart never appears (if I run a non Exchange cmdlet with the out-chart it is fine. eg get-process | out-chart)

So I have been building my charts with the PowerGadgets Creator, so I can only use the cmdlet without the out-chart bit as the Creator won't run when using the out-chart as it is doing that bit automatically.

In PG Creator I have the cmdlet line

get-exchangeserver | where-object {$_.IsHubTransportServer -eq $True} | get-queue | select {$_.Identity.ToString()}, MessageCount

When you click the test button it produces the result

$_.Identity.ToString() MessageCount---------------------- ------------GIMLDNEXH01\2134   0GIMLDNEXH01\2135   0GIMLDNEXH01\Submission   0GIMLDNEXH02\Submission   0GIMLDNEXHUB01\1990   0GIMLDNEXHUB01\2000   0GIMLDNEXHUB01\2001   0GIMLDNEXHUB01\Submission   0GIMLDNEXHUB02\Submission   0

But when I click the Finish button the actual chart instead of showing the Identity of the Queues (shown by the test button) it shows 1 2 3 4 5 6 7 8 9

Regards

Link to comment
Share on other sites

The latest licensed version available is also 1.0.2588. If you have an older version you may want to re-download the latest version from the URL indicated in the email you received with your purchase. Please make sure you uninstall your previous version before installing the latest build.

IvanG

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...