Quantcast
Channel: Exchange Server 2010 forum
Viewing all articles
Browse latest Browse all 19214

Shell script to get certain mailbox information

$
0
0

I've been working on this for a while today, and can't get past this last stumbling block.

Here's my command:

Get-Mailbox -ResultSize Unlimited | Where-Object {($_.WhenMailboxCreated).Month -eq 12 -and ($_.WhenMailboxCreated).Year -eq 2012 | ft Name,WhenMailboxCreated,RetentionPolicy | Export-CSV c:\Dec_boxes.csv

Here's my issue:

1)  running the command as is, creates the desired csv, but with the following contents:

#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,

But with many more lines.

2)  If I run the command without the | Export-CSV c:\dec_boxes.csv:

The display on the screen is perfect.  Exactly what I want.

3)  If I run the command without the | ft Name,WhenMailboxCreated,RetentionPolicy:

The CSV is created, but it contains all possible information on the mailboxes, so I have waaay too much info at that point.

My question:

How do I get a csv with just the info that I'm asking for?

Thanks,

Joe Heaton


Viewing all articles
Browse latest Browse all 19214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>