Jaykul,
That code worked great. Thanks! It gave me the correct output and trimmed my code a bit at the same time.
One other question I had and forgot to mention before was that I'd like to display the "TotalItemSize" in KB instead of Byes. I've used a select statement with @{n="Size(KB)";e={$_.TotalItemSize.value.ToKB()}} to accomplish this before, but the script was much simpler than this one. I've tried several variations of this in my script here, but not really getting what I need. The following is close, but the column name doesn't match the new size units. Any suggestions?
Get-Mailbox -ResultSize Unlimited | Where { $_.EmailAddressPolicyEnabled -Ne 'True' } |
foreach-object {
$mbStats = get-mailboxstatistics $_.identity
$mbData = $_ | Select Name, Alias, DatabaseName, TotalItemSize, EmailAddressPolicyEnabled, EmailAddresses
$mbData.TotalItemSize = $mbStats.TotalItemSize.Value.ToKB()
$mbData.Databasename = [string]::join("`n", ($_.Database.ToString().split("\")))
$mbData.EmailAddresses = [string]::join("`n", ($mbData.EmailAddresses) )
$mbData
} | ConvertTo-Html | Out-File C:\noemailpolicy.html