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