Tony Giangreco
asked on
Exchange 2007 Report from PowerShell Script problem
I have this script running on my Windows 2008 r2 Exchange 2007 server.
$exclude = GC C:\PS-Scripts\exclude.txt
$mailboxes = Get-Mailbox -ResultSize Unlimited | ?{$exclude -notcontains $_.samaccountname}
$exclude = GC C:\PS-Scripts\exclude.txt
$mailboxes = Get-Mailbox -ResultSize Unlimited | ?{$exclude -notcontains $_.samaccountname}
$report = @()
foreach ($mailbox in $mailboxes)
{
$inboxstats = Get-MailboxFolderStatistic s $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq "/Inbox"}
$mbObj = New-Object PSObject
$mbObj | Add-Member -MemberType NoteProperty -Name "Display Name" -Value $mailbox.DisplayName
$mbObj | Add-Member -MemberType NoteProperty -Name "Inbox Size (Mb)" -Value $inboxstats.FolderandSubFo lderSize.T oMB()
$mbObj | Add-Member -MemberType NoteProperty -Name "Inbox Items" -Value $inboxstats.ItemsinFolder
$report += $mbObj
}
I'm having these problems:
1. When i paste the script in powershell, do a select All, Copy & Paste into notepad, the report width is very wide and it wraps.
2. I need to capture the output in both CSV and as a regular text file that open in notepad.
3. The exclude option doesn't work. I have two text files I've tried (one with employees) and (One with email addresses) in the following format and nothing works.
joe@me.com
Pete@me,com
You@me.com
Joe Peterson
Mary Peterson
Al Peterson
Your suggestions are appreciated.
$exclude = GC C:\PS-Scripts\exclude.txt
$mailboxes = Get-Mailbox -ResultSize Unlimited | ?{$exclude -notcontains $_.samaccountname}
$exclude = GC C:\PS-Scripts\exclude.txt
$mailboxes = Get-Mailbox -ResultSize Unlimited | ?{$exclude -notcontains $_.samaccountname}
$report = @()
foreach ($mailbox in $mailboxes)
{
$inboxstats = Get-MailboxFolderStatistic
$mbObj = New-Object PSObject
$mbObj | Add-Member -MemberType NoteProperty -Name "Display Name" -Value $mailbox.DisplayName
$mbObj | Add-Member -MemberType NoteProperty -Name "Inbox Size (Mb)" -Value $inboxstats.FolderandSubFo
$mbObj | Add-Member -MemberType NoteProperty -Name "Inbox Items" -Value $inboxstats.ItemsinFolder
$report += $mbObj
}
I'm having these problems:
1. When i paste the script in powershell, do a select All, Copy & Paste into notepad, the report width is very wide and it wraps.
2. I need to capture the output in both CSV and as a regular text file that open in notepad.
3. The exclude option doesn't work. I have two text files I've tried (one with employees) and (One with email addresses) in the following format and nothing works.
joe@me.com
Pete@me,com
You@me.com
Joe Peterson
Mary Peterson
Al Peterson
Your suggestions are appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Any ideas on the exclude problem?
same way you did it for Inbox folder
Oh I fogot it... let me check it again
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, I'll try it later today. Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CSV file won't overwrite but yes txt file will but i also mentioned append after editing my comment in last... E-mail address also can be used to exclude users still whatever works. I wish either ur or mine whichever script work for user I am happy.. at least i got to learn smthing thanks anyways.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Amit, the CSV file will also get overwritten each time. Your last change makes the text file worse, as it appends the cummulated output (because of the -append). Both exports should just be moved out of the loop. And this does not make much sense:
$report = $report += $mbObj
you assign the the result of append data to $result to $result ;-). It should just be
$report += $mbObj
$report = $report += $mbObj
you assign the the result of append data to $result to $result ;-). It should just be
$report += $mbObj
May be but i made couple of scripts in my env and i got expected results.. Still i will try your suggestion tooo...
ASKER
Thanks for the help
ASKER
Is there anyway to add (count & folder size) Sent Items and Deleted Items to the report?