Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How would I spread out the columns in this powershell report

Posted on 2009-07-08
4
Medium Priority
?
695 Views
Last Modified: 2012-06-22
Hello All,

Chris-Dent helped me make an HTML report.  The powershell code does exactly what I want it to.  However, the columns are a little too close to eachother.  Where would I put `t within the code to spread things out a bit?  The code is provided below.

$Body = Get-MailboxStatistics -Server mail01 | `
  Where-Object{ $_.storagelimitstatus -eq "issuewarning" } | `
  Sort-object TotalItemSize -descending | `
    Select-Object `
    @{n="User";expression={ $_.DisplayName }}, `
    @{n= "Mailbox Size (MB)";expression={ $_.TotalItemSize.Value.ToMB() }} | `
      ConvertTo-HTML -Title "Mailbox Statistics"
0
Comment
Question by:ndalmolin_13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 1000 total points
ID: 24804739

Hey Nick :)

You could have asked in the other question. Not to worry, it's different enough not to matter.

I think we should apply a Style to our generated HTML. This is a simple example, we add a style statement to the header, and have it set a width of 200px for the columns and align the header titles to the left (I didn't like them centred personally). Anything else you'd like in there? :)

I wondered if you wanted to sort the contents of the output as well. For example, you might add Sort-Object in like this...

$Body = Get-MailboxStatistics | `
  Where-Object{ $_.storagelimitstatus -eq "issuewarning" } | `
  Select-Object `
    @{n="User";e={ $_.DisplayName }}, `
    @{n="Mailbox Size (MB)";e={ $_.TotalItemSize.Value.ToMB() }} | `
  Sort-Object "Mailbox Size (MB)" -Descending | `
  ConvertTo-HTML -Title "Mailbox Statistics" -Head $Header
# The header for the message
 
$Header = "<style type='text/css'>`n" + `
  "td { width: 200px }`n" + `
  "th { text-align: left }`n" + `
  "</style>"
 
# Create an HTML representation of the original object
 
$Body = Get-MailboxStatistics | `
  Where-Object{ $_.storagelimitstatus -eq "issuewarning" } | `
  Select-Object `
    @{n="User";e={ $_.DisplayName }}, `
    @{n="Mailbox Size (MB)";e={ $_.TotalItemSize.Value.ToMB() }} | `
  ConvertTo-HTML -Title "Mailbox Statistics" -Head $Header

Open in new window

0
 
LVL 1

Author Comment

by:ndalmolin_13
ID: 24805718
Thats it.  I was able to figure out the sorting bit.  Can you tell me what the td in line 4 means and the th in line 5?
Thanks for your help.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 24806616

TD is Table Data, TH is Table Header, both refer to the HTML tags in the output. The Style is written in CSS, the kind of thing you have to hit places like w3schools.com for (nothing to do with PowerShell itself) :)

`n is just a line-break in case you didn't know and were curious. Pointless except for when people need to read the HTML source.

And you should be able to see the HTML it makes it you just run $Body in the shell on it's own, or if you do this and open the resulting file up in IE / Firefox / random browser.

$Body > "test.htm"

Either way, you should see that it adds the style into the Head portion of the generated HTML. You'd need view source to see that in the browser (or to open the htm file in notepad).

Chris
0
 
LVL 1

Author Closing Comment

by:ndalmolin_13
ID: 31601141
Thanks for the detailed explaination.  I appreciate it.

Nick
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastrā€¦

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question