Search This Blog

Thursday, March 9, 2017

Remove spam emails from your organization mailboxes

Remove spam emails from your organization mailboxes from all mailboxes or specific mailboxes. You must have member of Discovery Management and Mailbox Import Export role


This tool will perform the following functions.

  • Delete messages from the source mailbox. You have to be assigned the Mailbox Import Export management role to delete messages.
  • Copy messages from the source mailbox and delete them from the target mailbox.

Cross-forest Mailbox move Migration commands


$User = "test.loc\vijaya.reddy"
$PWord = ConvertTo-SecureString –String "SourcePWD" –AsPlainText -Force

$SourceCredential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord

$User = "targettest.local\vijaya.reddy"
$PWord = ConvertTo-SecureString –String "TargetPWD" –AsPlainText -Force


$TargetCredentials = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord

Import-csv "C:\temp\moveusers.csv" | Foreach-Object { Move-Mailbox -TargetDatabase "exchange\First Storage Group\Mailbox Database" -Identity $_.Identity -GlobalCatalog testdc03.test.local -SourceForestGlobalCatalog testdc02.test1.loc -NTAccountOU "OU=test Users,DC=test,DC=local" -SourceForestCredential $SourceCredential -TargetForestCredential $TargetCredential -IgnorePolicyMatch:$true -BadItemLimit 1000 -maxthreads 50 -verbose -Confirm: $false}


DAGMaintenace_Healthcheck

The DAGMaintenace_Healthcheck.exe will use PowerShell to Perform DAGMaintenace and HealthCheck against an Exchange Server 2010 or 2013 or 2016. This tool will detect target hubtransport server automatically to transfer the message queue.
********************** Functions ********************
1.Start DAG Maintenance ::  Place the current Exchange Server in to Maintenance Mode.
2.Stop DAG Maintenance ::  Place the current Exchange Server in to out of Maintenance Mode.
3.Rebalance Mailbox Databases ::  Balance the Mailbox Databases based on activation preference.
4.Check Exchange Server Health Check ::  Perform Exchange Server Health Checks.
5.Reboot Current Server ::  Reboot the current Exchange Server.
******************************************************
Download Link : https://gallery.technet.microsoft.com/office/DAG-Maintenance-Health-931b75

Useful commands for Migration

setexchange server
Set-ExchangeServer -identity targettestexchange.targettest.local -StaticExcludedDomainControllers:targettestdc01.targettest.local,targettestdc02.targettest.local,targettestdc03.targettest.local
Get-ExchangeServer -identity targettestexchange.targettest.local -status | fl Name, StaticExcludedDomainControllers
Set-ExchangeServer -identity targettestexchange.targettest.local -StaticExcludedDomainControllers:$null

Full access

Get-mailbox –OrganizationalUnit “test users”| Add-MailboxPermission –user “testtest005” –accessright Fullaccess

[PS] C:\Windows\system32>get-mailboxserver | where {$_.name -like "targettestexchange*"} |Get-mailboxStatistics | where {$_.DisconnectDate -notlike "" -and $_.Displayname -notlike "*test*"} | sort LastLogonTime | ft DisplayName, LastLogonTime, Database -wrap

[PS] C:\Windows\system32>Get-Mailbox -OrganizationalUnit "test users" | Set-Mailbox -HiddenFromAddressListsEnabled $true

Get-Group  | Where {$_.GroupType -eq "Global"} | Set-Group -Universal

Import-csv -path c:\temp\groups.csv | foreach { Enable-distributiongroup -identity $_.Identity}

Get-DistributionGroup -| Set-DistributionGroup -EmailAddressPolicyEnabled $False

[PS] C:\Windows\system32>Get-DistributionGroup -OrganizationalUnit "test groups" | Set-DistributionGroup -EmailAddressPolicyEnabled $False

Get-mailuser -OrganizationalUnit "test users" | Set-mailuser -EmailAddressPolicyEnabled $True

Get-mailbox -OrganizationalUnit "test users" | Set-mailbox -EmailAddressPolicyEnabled $True