This is Exchange specific task, but the part I need help with is not specific to Exchange, so hope I'm posting in the right place. Basically I want to get a report of all mailboxes created including their e-mail address over the past week and then run that once a week and save it to a network share.
If I use the line below, it works to output the data I want to the screen
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.WhenCreated -ge ((Get-Date).Adddays(-7))} | ft name, PrimarySMTPAddress, WhenCreated
Unfortunately if I try to export to CSV like the line below, it just gives me a bunch of hex numbers
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.WhenCreated -ge ((Get-Date).Adddays(-7))} | ft name, PrimarySMTPAddress, WhenCreated | Export-csv test.csv
Even if that worked, the other problem I will have is it will overwrite my file every week, what I'd like to do is create a new file each time including the date. So I tried changing it to a script as below.
$Today = Get-Date
$FileName = "c:\EmailAccountsCreated"
$FileType = ".csv"
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.WhenCreated -ge ((Get-Date).Adddays(-7))} | ft name, PrimarySMTPAddress, WhenCreated | Export-csv $Filename$Today$FileType
I get an error that says The given path's format is not supported.
Any help would be greatly appreciated!
Thanks!
Brian