Help Creating PS Script....
Hi, I'm trying to make a script that will run the following cmdlet for 4 servers and output the results to a txt file. is there someone that can help? Get-ExchangeServer -identity "servername" | Get-MailboxDatabase | Get-MailboxStatistics | Group-Object -property:database | Sort-Object -property:name | ft name, count AutoSize
December 4th, 2009 4:12pm
Hi,Why you could not run aboce script 4 times and use > to a text file.Get-mailboxstaticse -server "MBX-server" | Group-Object -property:database | Sort-Object -property:name | ft name, count AutoSize > c:\test1.txtMight be if you are looking some more automation then some scripter can help you :)Anil
Free Windows Admin Tool Kit Click here and download it now
December 5th, 2009 12:25pm
On Fri, 4-Dec-09 13:12:40 GMT, riedling wrote:>Hi, I'm trying to make a script that will run the following cmdlet for 4 servers and output the results to a txt file. is there someone that can help? Get-ExchangeServer -identity "servername" | Get-MailboxDatabase | Get-MailboxStatistics | Group-Object -property:database | Sort-Object -property:name | ft name, count AutoSize Are you interested in a subset of all your servers? Is that why yousay "4 servers"?Is a CSV file okay?'server1','server2','server3','server4' | Get-ExchangeServer |MailboxStatistics | Group-Object-property:database | Sort-Object -property:name | export-csv -pathsomefile.csv -notypeinfo -encoding asciiThe results don't make sense, though. You're getting mailboxstatistics for individual mailboxes and then discarding the details.You should probably just get rid of the "Group-Object" and sort theoutput by the database and then the name.---Rich MatheisenMCSE+I, Exchange MVP---
Rich Matheisen
MCSE+I, Exchange MVP
December 5th, 2009 11:33pm
Not sure what information you are after. This script will loop through your four servers (server01 .. server04) and retrieve some statistic information and write it to four .CSV files in C:\temp. The file names are prefixed with your server names.
# Loop through the four servers
foreach ($mbxSrv in 'server01', 'server02', 'server03', 'server04') {
# Name .CSV file
$csvFile = 'c:\temp\' + $mbxSrv + '_statistics.csv'
# Retrieve statistics
Get-ExchangeServer -Identity $mbxSrv | Get-MailboxDatabase | Get-MailboxStatistics |
Select-Object DisplayName, ItemCount, @{Name = 'Size (MB)'; expression = {$_.TotalItemSize.Value.ToMB()}}, Database |
Export-Csv -noTypeInformation -Encoding Unicode -path $csvFile
}
You could use the Get-Date to add to the file name, with these parameters:
$year = Get-Date -Uformat "%Y"
$month = Get-Date -Uformat "%m"
MCTS: Messaging | MCSE: S+M | Small Business Specialist
Free Windows Admin Tool Kit Click here and download it now
December 6th, 2009 1:54am
I'm trying to get the mailbox count per store. I will try the above and see if that works. Thanks for the replies :)
December 7th, 2009 5:07pm
Take a look here. The script referred to will also outpout the mailbox count per store.Script to list database size in a cluster CCR environmenthttp://social.technet.microsoft.com/Forums/en-US/exchangesvradmin/thread/13dbc26d-a33a-4e18-a744-b6575592be02
Mbx DB Statsv2http://www.exchangeninjas.com/MbxDBStatsv2MCTS: Messaging | MCSE: S+M | Small Business Specialist
Free Windows Admin Tool Kit Click here and download it now
December 7th, 2009 5:16pm
That is helpful, but i lost the ability to return how many mailboxes are in each store. Can that be added to the loop?
December 7th, 2009 10:15pm
The Mbx DB Statsv2 script returns the number of mailboxes in each database:
http://www.exchangeninjas.com/MbxDBStatsv2
Server : ex-server
Name : SG04\MBXDB04
Type : Private
Size (MB) : 208962
Users : 137
Server : ex-server
Name : SG05\MBXDB05
Type : Private
Size (MB) : 206360
Users : 126
You should save the script as get-databasesize.ps1. The script takes piped input, in your case four servers. Run the script from the command line with for instance these parameters.
[PS] C:\> .\get-databasesize.ps1 servers MBX1,MBX2,MBX3,MBX4 | sort-object Users | format-table
MCTS: Messaging | MCSE: S+M | Small Business Specialist
Free Windows Admin Tool Kit Click here and download it now
December 8th, 2009 1:01am