Exchange Management Shell (EMS)
Exchange 2007 has intrdouced a new scripting technology utizling powershell. Exchange management shell or EMS provides Exchange Admins the ability to perform any Exchange task from a command line.
When I first starting working with EMS in early beta I faught it until I realized how easy it can be to perform tasks.
Since I have been collecting scripts that other have written I thought it would be a good idea to post them and help other. Also if you have good scipts let me know.
Below is a link to one of the Exchange powershell gurus that I had a privledge to meet.
http://www.viveksharma.com/techlog/category/powershell/
——————————————————————————————
How to get the size of your Exchange databases -
**provided by Naray Palaniappan**
param( [string] $server = $env:computername
)
foreach ($db in get-mailboxdatabase -server $server) {
$dbPath = $db.EdbFilePath -replace “//”,”//” # for use in the WMI filter $dbSize = (get-wmiobject cim_logicalfile -computer $server -filter “name=’$dbPath’” -property filesize).filesize
$retObj = new-object psobject $retObj add-member noteproperty -name “Server” -value $db.Server
$retObj add-member noteproperty -name “Name” -value $db.Identity
$retObj add-member noteproperty -name “Size (MB)” -value (“{0:n1}” -f ($dbSize/1MB))
$retObj
}
copy the text notepad and save to .ps1
Lets run this and see the outpout;
I have created a folder called scripts on my drive D:\scripts
Unlike VB scripts you cannot double click to launch the script.
1. Open EMS
2. Change directory to the ps1 files
*not we do not have to be in the directory to call the script*
3. Lets just try to launch the script by typing its name
notice we recieve an error, to call the script we must use “./”filename
4) ./databasesize.ps1
Lets view the output:
As we see this only call the local machine information we can use the -server switch to call any server
5) ./datbasesize.ps1 -server XXX





Leave a Reply