Thursday, February 3, 2011

How to get Exchange 2007 database's White Space in PowerShell

Hi everyone,
the sun is shining in Buenos Aires and with the summer breeze my mood is better than yesterday :)..I would to share with you this simple script that search the Event 1221 in all mailbox servers  and get the DB's white space in MB...the result will be exported to a csv file, see the code below:

$ComputerName =Get-ExchangeServer |where {$_.IsMailboxServer -eq 'True'}
$dmtf = [System.Management.ManagementDateTimeconverter]
$Start = $dmtf::ToDmtfDateTime( (Get-Date).AddDays(-1).Date )

$db = @{Name="DB";Expression={$_.InsertionStrings[1]}}
$free = @{Name="WhiteSpace(MB)";Expression={[int]$_.InsertionStrings[0]}}

$filter = "LogFile='Application' AND EventCode=1221 AND TimeWritten>='$Start'"
Get-WMIObject Win32_NTLogEvent -ComputerName $ComputerName -Filter $filter | select ComputerName,$db,$free | export-csv salida.csv -Force -NoTypeInformation


Enjoy!

-Dario

3 comments:

  1. Hi Dario

    Super and Excellent power shell script.

    I need to touch with you dario

    Thanks

    Anandraj From INDIA

    ReplyDelete
  2. Hi, Anand...sure you can contact me at dario.may@gmail.com

    -Dario

    ReplyDelete
  3. Hi Dario

    Can you please check the your mailbox i sent one mail

    My mail id:anandraj9222@gmail.com

    Thanks

    Anandraj
    INDIA

    ReplyDelete

Note: Only a member of this blog may post a comment.