Jump to content
Software FX Community

Multi-Line issue


coesum
 Share

Recommended Posts

I am not certain if this is PowerGadgets related or PS, but when I attempt to create an out-chart using a multi-line PS command it locks the script until I close the chart and then continues but in unexpected ways.  For instance the line

Get-WmiObject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 `
 -ComputerName EMAIL | Select-Object MailboxDisplayName, Size, TotalItems `
 | sort Size -descending | select -first 20 | out-chart -Values Size, `
 TotalItems -Label MailboxDisplayName -template EmailReport | send-mail `
 -From PowerGadgets@domain.com -To user@domain.com -subject `
 "Top 20 Email Users" -Text "This is a test" -server email.domain.com

creates the Outchart correctly, but stops at that point and when I close the chart it emails the user but does not include the chart.  However if I put it all on one line like so

Get-WmiObject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName EMAIL | Select-Object MailboxDisplayName, Size, TotalItems | sort Size -descending | select -first 20 | out-chart -Values Size, TotalItems -Label MailboxDisplayName -template EmailReport | send-mail -From PowerGadgets@jdomain.com -To user@domain.com -subject "Top 20 Email Users" -Text "This is a test" -server email.domain.com

 The script runs and the user gets the chart in email as expected.  Should I be doing a different method for multilining for readability?

Link to comment
Share on other sites

You cannot split the lines in this case.  This is basically a PowerShell limitation currently:
http://community.softwarefx.com/forums/t/9104.aspx

You can, however, do different things to cut things down, but it will still require extra steps/scripting:
http://community.softwarefx.com/forums/t/9041.aspx

Other than that, you're left with possibly using the built-aliases like 'gwmi' instead of 'get-wmiobject'.  Most of the built-in cmdlets have aliases for their parameters.

PowerGadgets doesn't currently support shorter counterparts for the parameters, but it is something I've suggested before.

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.

 Share

×
×
  • Create New...