Showing posts with label Microsoft Exchange. Show all posts
Showing posts with label Microsoft Exchange. Show all posts

Tuesday, December 8, 2015

How to send mail to multiple user using powershell Script

How to send mail to multiple user using powershell Script 


For a project requirement I had to send mails to multiple users whose mailboxes had been moved to another database and whose mailbox Quota had been increased . I wrote a small Script for the same.

For the same, We need to populate a text files with users email id and run a bat file . Below is the code for the same . Save the below script in "sendmail.ps1" and create a bat file 
with below line "powershell.exe .\sendmail.ps1" . Double click the bat file and mails will be sent to users 

Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.E2010
$to1 = Get-Content .\abhishek.txt
$body += "Hello, `n `n"
$body += "Messaging team is pleased to report that your mailbox storage has been increased to 2 GB`n `n"
$body += "Thank you, `n "
$body += "Messaging Support Team"
foreach ($to2 in $to1)
{
Send-MailMessage -to $to2 -subject "Mailbox Storage has been increased" -Body $body -from abhishek.gupta3@mylab.com -smtpserver mapmail.mylab.com
}


Friday, December 4, 2015

Powershell Command to check Mailbox Database count, size and freemailboxspace

Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.E2010
$z = @()
$x = Get-MailboxDatabase | Where {$_.MasterType -eq "DatabaseAvailabilityGroup"}
ForEach ($d in $x)
{
$c = Get-mailbox -Database $d -ResultSize unlimited
$s = Get-MailboxDatabase $d -Status
$object = New-Object -TypeName PSObject
$object | Add-Member NoteProperty –Name Database –Value $d.Name
$object | Add-Member NoteProperty –Name Count –Value $c.count
$object | Add-Member NoteProperty –Name DatabaseSize –Value $s.DatabaseSize
$object | Add-Member NoteProperty –Name AvailableNewMailboxSpace –Value $s.AvailableNewMailboxSpace
#$object | Add-Member NoteProperty –Name Server –Value $d.Server
$z += $object
}
$z




Wednesday, October 21, 2015

Number of E-mails Sent and Received by one User

Number of E-mails Sent and Received by one User

Int] $intSent = $intRec = 0
Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start “10/01/2012” -End “11/01/2012” -Sender "user@domain.com" -EventID RECEIVE | ? {$_.Source -eq "STOREDRIVER"} | ForEach { $intSent++ }
Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start “10/01/2012” -End “11/01/2012” -Recipients "user@domain.com" -EventID DELIVER | ForEach { $intRec++ }
Write-Host "E-mails sent:    ", $intSent
Write-Host "E-mails received:", $intRec

Powershell command to check DAGHealth

Powershell command to check DAGHealth

(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Get-MailboxDatabaseCopyStatus -Server $_}}

(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Test-ReplicationHealth -Server $_}}


Friday, August 7, 2015

Create Transport Rule to set Spam Confidence Level

Create Transport Rule to set Spam Confidence Level

Issue: Some emails sent via any application goes to Junk Folder in Outlook.
Cause:  This happens when users send emails via applications and use senders who are not present in AD. Outlook fails to authenticate such sender or find the content of email/attachment as inappropriate.  In Exchange 2007 this was fixed by adding internal domain in Safe Senders in Outlook but in Exchange 2010 we cannot add internal domains in Safe Senders.
Resolution: This can be fixed by creating a transport Rule which sets the SCL to -1 (Outlook considers all the emails with SCL -1 as safe.)
Please follow the below mentioned steps to create a new transport rule for setting spam confidence level to -1 for emails which are sent any application

New-TransportRule -Name "Allow lab.com" -Comments "This rule will set SCL -1 for internal emails to prevent them from going to junk folder" -FromAddressContainsWords "lab.com" -SetSCL -1 -ExceptIfSCLOver 0


Restart Microsoft Exchange Transport Service on all the Hub Transport Servers

Wednesday, May 20, 2015

Active Sync Stats

Active Sync Stats

Get-CASMailbox -ResultSize unlimited | where {$_.ActiveSyncEnabled -eq “true”} | ForEach-Object {Get-
ActiveSyncDeviceStatistics -Mailbox:$_.identity} | select Devicetype, DeviceID,DeviceUserAgent, FirstSyncTime,
LastSuccessSync, Identity, DeviceModel, DeviceFriendlyName, DeviceOS | Export-Csv c:\activesync.csv

Powershell script to import size of mailbox in CSV file using Add-Member NoteProperty

Powershell script to import size of mailbox in CSV file using Add-Member NoteProperty


$date = get-date -format d
$date = $date.ToString().Replace(“/”, “-”)
$output = ".\" + "mailboxdata" + $date + "_.csv"
$z = @()
$g = @("guptaa10","rawata")
foreach ($f in $g)
{
$b = Get-Mailbox -Identity $f
$c = Get-MailboxStatistics $f
$object = New-Object -TypeName PSObject
$object | Add-Member NoteProperty –Name User –Value $b.Alias
$object | Add-Member NoteProperty –Name Quota –Value $b.ProhibitSendQuota
$object | Add-Member NoteProperty –Name Size –Value $c.TotalItemSize
$z += $object
}
$z | Export-Csv $output




















Tuesday, February 24, 2015

How to search and delete a mail from all mailbox

How to search and delete a mail from all mailbox

Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 'Subject:"Re-Please Update Your Password‏"' -DeleteContent


Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 'SafetyDataList' -TargetMailbox "guptaa10" -TargetFolder "Inbox" -LogLevel Full

Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 'Subject:"*Account Alert: Card Not Present Transaction*"' -DeleteContent | Where-Object {$_.ResultItemsCount}






Wednesday, February 18, 2015

PowerShell for Microsoft Exchange Server

PowerShell for Microsoft Exchange Server



Exchange Server Upgrades and Migrations

Exchange Server Upgrades and Migrations 



Retrieving the Move History for an Exchange Server 2010/2013 Mailbox

Retrieving the Move History for an Exchange Server 2010/2013 Mailbox





Installing Cumulative Updates and Service Packs for Exchange Server 2013

Installing Cumulative Updates and Service Packs for Exchange Server 2013




How to Install Updates on Exchange Server 2010 CAS Arrays

How to Install Updates on Exchange Server 2010 CAS Arrays


How to Install Updates on Exchange Server 2010 Database Availability Groups

How to Install Updates on Exchange Server 2010 Database Availability Groups



Block Outlook for iOS and Android

Script to Report on ActiveSync Devices

How to Fix a Failed Database Content Index for Exchange Server 2013

How to Fix a Failed Database Content Index for Exchange Server 2013




How to Reseed a Failed Database Copy in Exchange Server 2013

How to Reseed a Failed Database Copy in Exchange Server 2013



PowerShell Script to Generate a Report of Mailbox Audit Log Entries

PowerShell Script to Generate a Report of Mailbox Audit Log Entries