Wednesday, December 28, 2011

Exchange Shell Admin Tasks

1. Find all accounts with default storage quota.
get-mailbox | where-object {$_.UseDatabaseQuotaDefaults - eq 0}

To Enable storage quota:
set-mailbox foreach {set-mailbox -$_ -UseDatabaseQuotaDefaults $true}

2. Find all accounts hidden from exchange.
get-mailbox | where-object {$_.HiddenFromAddressListsEnabled eq $true}

3. Set exchange virtual directory web service.

Set-WebServicesVirtualDirectory -Identity "CAS-Server-Name\EWS (Default Web Site)" -InternalUrl https://webmail.gohar.net.pk/ews/exchange.asmx

verify:
Get-OwaVirtualDirectory "cas2\owa (Default Web Site)" | fl

4. Find exchange last logon time.
Get-MailboxStatistics | Select-Object DisplayName, LastLogonTime | Format-Table
Get-MailboxStatistics | Sort LastLogonTime -Descending > C:\Stats.txt

5. Trace Email with shell.
Tracking a sender's all emails:
Get-MessageTrackingLog -Server Hub01 -resultsize unlimited -EventID Receive -Sender geog44079@gmail.com | ConvertTo-Html Timestamp, EventID, Sender, {$_.Recipients}, MessageSubject | Set-Content C:\Temp\logs.html

6. Performance Monitoring.

Go to start -> run -> perfmon -> under “performance Logs and alerts” -> right click on counter logs -> new log settings -> put any name an click OK
Click on add objects -> select Memory, Process, Processor, Pagefile, Physical Disk, Logical Disk, Network Interface, Redirector,
Server, and Server Work Queues, Msexchange ADACCESS Domain controllers, Msexchange ADACCESS Global Counters, Msexchange ADACCESS processes, MsexchangeIS, Msexchangemailsubmission..
Go to log files -> Configure -> set limit of 500 MB -> ok.. (make sure that you have enough space on drive where the perflog will be save..)
Click on apply and OK.. make sure it started..