Sunday 20 October 2013

How to use Remote Exchange Management Shell

Exchange Server 2013 allows the option to access Exchange Management Shell from a computer that is not installed with Exchange Management Tools... below are the steps to connect to Exchange Management Shell 

$MyCredential = Get-Credential

$NewSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://ExchServerName/PowerShell/ -Credential $MyCredential

Import-PSSession $NewSession

Monday 1 July 2013

How to take Delegates Report in Exchange 2010 and Exchange 2013

Use the below scripts to take the delegates report in Exchange Server 2010 and Exchange Server 2013
###########################################################################
# NAME: Delegates Report for Exchange Server 2010/2013
# AUTHOR:  Rajkumar
# VERSION HISTORY:1.0 7/1/2013 - Initial release
###########################################################################

$ErrorActionPreference = "SilentlyContinue"
$WarningPreference = "SilentlyContinue"
$MailboxUsers = get-mailboxdatabase | get-mailbox  -resultsize Unlimited | sort displayname
$Output=@();
# Perform a set of actions against each mailbox - Loop
foreach ($user in $MailboxUsers)
{
$Name = $user.Alias
$OutputItem = New-Object Object;
$delegates = Get-MailboxCalendarsettings $name |where {$_.resourcedelegates -notlike “”}
$delegateNames = $delegates.ResourceDelegates | ForEach { $_.Name }
$delegateString = $delegateNames -Join ", "

# Get the desired Ouputs
$OutputItem | Add-Member NoteProperty Alias $user.alias;
$OutputItem | Add-Member NoteProperty "Display Name" $user.name;
$OutputItem | Add-Member NoteProperty "PrimarySMTPAddress" $user.PrimarySMTPAddress;
$OutputItem | Add-Member NoteProperty "Delegates" $DelegateString;
# Add the object to our array of output objects
    $Output += $OutputItem;
# Export the output as CSV File
$Output | Export-CSV -Path "C:\Mailboxreport.csv" -NoTypeInformation
$ToAddress = "Rajkumar.MCITP@Outlook.com"
$FromAddress = "ExchangeAdmin@DomainName.com"
$Body = "Please find the attached Delegates report for Company Name"
$attachments = "C:\Temp\DelegatesReport.csv"
send-mailmessage -to $ToAddress -from $FromAddress -subject "Delegates Reports" -smtpserver ServerName.Domain.local -attachments $attachments -body $body

How to Create a New Mailbox in Exchange 2013 using Shell Command

Below the shell command which can be used to create a Mailbox in Exchange Server 2010 and Exchange Server 2013
$password = Read-Host "Enter password" -AsSecureString
New-Mailbox -UserPrincipalName Name@DomainName.in -Alias AliasName -Database "Database Name" -Name 'Name' -OrganizationalUnit Users -Password $password -FirstName FirstName -LastName Last Name -DisplayName "Display Name" -ResetPasswordOnNextLogon $true

Sunday 30 June 2013

How to configure email forwarding using shell command

To configure the email forwarding on a Mailbox use the below shell command
Set-Mailbox -Identity "Mailbox Name" -ForwardingSMTPAddress "EmailAddress@DomainName.com"
Please note that, above shell command will forward all the emails to the Forwarding SMTP Address and no emails will deliver to concerned Mailbox To set the forwarding option to deliver the email to mailbox and to the forwarding SMTP address use the below shell command
Set-Mailbox -Identity "Mailbox Name" -ForwardingSMTPAddress "EmailAddress@DomainName.com" -DeliverToMailboxAndForward $True

How to restrict the Recipient Limits for a Mailbox using Shell Command

To restrict the recipient limits per mailbox use the below shell command
Set-Mailbox -Identity "Mailbox Name" -RecipientLimits 10
Before setting the limit, you can check the existing configuration using
Get-Mailbox -Identity "Mailbox Name" | FL Name, RecipientLimits