Good-to-know Powershell CMDLETS & Procedures
1. One particular message needs to be removed from Exchange 2007 mailboxes.
To find and delete items from a group of mailboxes, such as all mailboxes on a database, without exporting the items to another mailbox, run the following command:
Get-Mailbox -Database DB1 | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent
This example first gets all the mailboxes on database DB1, searches for items that contain the string "Virus message" in the subject, and deletes those items.
2. Hardcoding the DC/GC for Exchange 2007 server to use using GUI
We can achieve this using following cmdlet:
Set-ExchangeServer -Identity <ServerIdParameter> [-StaticConfigDomainController <String>] [-StaticDomainControllers <MultiValuedProperty>] [-StaticExcludedDomainControllers <MultiValuedProperty>] [-StaticGlobalCatalogs <MultiValuedProperty>]
3. In Exchange 2007, you can use the following powershell cmdlet to check the size on the mailboxes on a given server
Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount
4. Procedure to export all objects from the GAL into a .csv file
Below are the commands which can help exporting all mail enabled objects from the GAL
csvde -f c:\Exp.csv -d dc=domain,dc=com -l displayname,cn,showInAddressBook,objectclass,objectcategory -r mailnickname=*
This command will export all the objects having mail nickname
csvde -f c:\Exp1.csv -d dc=domain,dc=com -l displayname,cn,showInAddressBook,objectclass,objectcategory -r showinaddressbook="DN of the GAL"
This command will export objects from the specific address list based on the DN of the GAL specified
If any of you have any good CMDLETS .. Comment it for all our readers.![]()





Really good but, heading looks starnge
$_.TotalItemSize.Value.ToKB().
to change this is how it goes
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{ expression={$_.TotalItemSize.V
alue.ToKB()} ; label = "KB" ; width = 10 },ItemCount
Reply to this
Really good but, heading looks starnge
$_.TotalItemSize.Value.ToKB().
to change this is how it goes
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{ expression={$_.TotalItemSize.V
alue.ToKB()} ; label = "KB" ; width = 10 },ItemCount
Reply to this
To Know WMI directory i.e. Namespace:
gwmi -Namespace root __namespace | fw name
To Know classes within Namespace:
gwmi -namespace root\CIMV2 -List | where {$_.Name.StartsWith("Win32_")}
gwmi -Namespace root\MSAPPS12 -list | where { $_.Name.startswith("Win32_")}
Reply to this