Monday, 30 July 2012

Program for Helpdesk people to retrive the information of maiboxes

How to retrieve the Mailbox info from the particular mailbox server

Using the below program, we can extract the details of mailbox information from the specified exchange server. Even if you type the mailbox name instead of typing exchange server name, you will get the mailbox info output. This program is very useful to Helpdesk people to retrieve the info of mailbox information and mailbox server information.
 Please Click Here if you want to know about (if else) statement
If ($arg[0] –eq ‘server’)
Write-Host “Retrieving info from the server ” $arg[1]
Get-exchangeserver –server $arg[1] | select name, FQDN, ServerRole, Edition | FL
Write-host “ The mailboxes Hosted on : “ $arg[1]
Get-mailbox –server $arg[1] | select name, severname, database
Write-host “ Retrieving information of maibox “ $arg[0]
Get-mailbox $arg[0] |select name, servername, database
Copy the program in notepad and save it as mailboxinfo.ps1

C:\temp>.\mailboxinfo.ps1 –server exchageserver1
Retrieving info from the server  exchageserver1
Server Role:
The mailboxes Hosted on : exchageserver1

Sankar M 

Wednesday, 25 July 2012

Exchange Server Cmdlets

1. quick shortcut to get all the commands

Get-Command | Format-List Definition

2. How to move mailbox

Get-Mailbox -Server SRV1 | Move-Mailbox -TargetDatabase SRV2

3. To get a list of all users on an Exchange server who are not Unified Messaging-enabled type, 

Get-UmMailbox | ForEach { If($_.UmEnabled -Eq $False){$_.Name}} 

4. To display the user’s alias formatted in a table together with the user’s Exchange server name and telephone extension, type:

Get-UmMailbox | Format-Table ServerName,@{e={$_.SamAccountName};Label=”User Alias”},@{Expression=”Extensions”;Label=”Telephone numbers

5. If you want to test all IP Block List providers, you just have to pipe the Get-IpBlockListProvider cmdlet to the Test-IpBlockListProvider

Get-IpBlockListProvider | Test-IpBlockListProvider -IpAddress 192.168.0.

6. Before you remove an object by using the Remove verb, use the WhatIf parameter to verify the results are what you expect.

7. Get all Win32 WMI information, such as perfmon counters and local computer configurations. For example,

Get-WMIObject Win32_PerfRawData_PerfOS_Memory 

8. You can configure real-time block list (RBL) providers with the Exchange Management Shell by running the following two commands:

Set-IPBlockListProvidersConfig -Enabled $True -ExternalMailEnabled $True
And then

Add-IPBlockListProvider -Name -LookupDomain -AnyMatch $True 

9. Access the event log from the Exchange Management Shell. To retrieve the whole event log,

Get-EventLog Application | Format-List

To retrieve all Exchange-related events

Get-EventLog Application | Where { $_.Source -Ilike “*Exchange*” } 

10. you can use wildcard characters to retrieve all properties that matches the part of the name that you specify:

Get-Mailbox | Format-Table Name,*SMTP* 

11. Do you want to configure a group of objects that have similar identities? You can use a wildcard characters with the Identity parameter when you use a Get cmdlet and pipe the output to a Set cmdlet. Type:

Get-Mailbox *John* | Set-Mailbox -ProhibitSendQuota 100MB

This command matches all mailboxes with the name “John” in the mailbox’s identity and set the ProhibitSendQuota parameter to 100MB. 

Get-MailboxDatabase “Normal” | Get-Mailbox | Set-Mailbox -ProhibitSendQuota 100MB

This command retrieves all the mailboxes that reside in the “Normal” mailbox database and sets their ProhibitSendQuota value to 301MB

12. Use Test-MapiConnectivity to troubleshoot connectivity problems between your users and your servers. Combine Test-MapiConnectivity with a variety of cmdlets to target your specific issue without having to manually dig for the information:

Mailboxes: Get-Mailbox | Test-MapiConnectivity

Mailbox databases: Get-MailboxDatabase | Test-MapiConnectivity

Servers: Get-MailboxServer | Test-MapiConnectivity 

13. Do you want to record exactly what happens when you’re using the Exchange Management Shell? 

Use the Start-Transcript cmdlet.

 Anything that you do after you run this cmdlet will be recorded to a text file that you specify. To stop recording your session, 

use the Stop-Transcript cmdlet.

Notice that the Start-Transcript cmdlet overwrites the destination text file by default. If you want to append your session to an existing file, use the Append parameter:

Start-Transcript c:\MySession.txt -Append 

14. How to check the Exchage server version, server role, site?

Get-ExchangeServer | fl name, edition, serverrole, site

Tuesday, 24 July 2012

Script For Folder Item Count

I have been using the below exchange management command for the folders item count.

Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.ItemsInFolder -gt 5000} | Sort-Object -Property ItemsInFolder -Descending | fl Identity, ItemsInFolder

Since there are different folder item limits for each version of Exchange, I thought it might be beneficial to write a script that could analyze folders on all versions, and determine if they were over their limit. The limits are as follows:


Version                                      Folder Item Count

Exchange 2003                               5,000

Exchange 2007                               20,000

Exchange 2010                               100,000

Sankar M

Monday, 23 July 2012

Script For Folder Count


Using the below script we can dump the list of users and their folder size in exchange server 2010

# script to list the number of folders in each mailbox
$mbx|select Displayname,@{n="FolderIdCount";e={(get-mailboxfolderstatistics -id $_.Identity | select FolderId).count}} | Sort-Object -Property Displayname | export-csv c:\files\results.csv

If you want to know how many items are in every mailbox and if all items in mailbox is more than 500 you can use this below script:

$data = $((get-date).ToString('dd.MM.yyyy'))
Function New-Array {,$args}
$Report = New-Array
$count_max = 500
$mbxs = get-mailbox | select -first 100 -resultsize unlimited
foreach ($mbx in $mbxs){
$mbxstat = get-mailboxstatistics $mbx.SAMAccountName
if ($mbxstat.ItemCount -gt $count_max){
$report_tmp = New-Object System.Object
$report_tmp | Add-Member -type NoteProperty -name DisplayName -value $mbx.DisplayName
$report_tmp | Add-Member -type NoteProperty -name ItemCount -value $mbxstat.ItemCount
$Report += $report_tmp
$Report | ft -auto | Out-String -Width 4096 > d:\scripts\report_count_$data.txt
Send-MailMessage -To -From -Subject "Mailbox items count $data" -SmtpServer youremailserver -Attachments d:\scripts\report_count_$data.txt

Sankar M