Category Archives: Exchange

Export mailboxes to pst Exchange 2010

This little script if for export mailboxes to a pst files form an Exchange 2010 SP1 or SP2  or SP3

to change:

  • e:\exchange –>path to export pst files (\\server2k\e$\Exchange)
  • F:\Exchange\bin ->path to exe of Exchange
  • F:\backup –>path to ps script

first, assing role to users administrator

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User Administrator

 the script:

</p>
'F:\Exchange\bin\RemoteExchange.ps1';
Connect-ExchangeServer -auto;
Remove-Item <a href="file:///\\murano\F\Exchange\*.pst">\\murano\F\Exchange\*.pst</a> -recurse;
Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest -confirm:$false;
Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest -confirm:$false;
foreach ($i in (Get-Mailbox))
	{ New-MailboxExportRequest -Mailbox $i -FilePath "<a href="file:///\\murano\F\Exchange\$($i.Alias).pst">\\murano\F\Exchange\$($i.Alias).pst</a>"  -baditemlimit 200 -AcceptLargeDataLoss }

then, create one new scheduled task:

 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

with this parameters:

 

-version 2.0  -command “. ‘F:\Exchange\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto;. ‘F:\backup\exportmailboxes.ps1′”

{jcomments on}

Facebooktwitterredditpinterestlinkedinmail

Read More ...

Stop Exchange 2007 or 2003 and make a backup for files

An easy way to make a backup exchange 2007 or 2003 is to stop services:

<p>There are various systems to stop the services and copy the Exchange database, this method of copying is widely used, since natively Exchange 2010 and 2007 support only copies of the units through snapshots or need third-party applications.</p>
<p>The first would be a file. Bat for Exchange 2003 in this case the databases are in<strong> X:\dades exchange </strong>and copied to the location:&nbsp;<strong>x:\copia exchange\ExchangeOfflineBackup</strong>, you can adapt it to your convenience:</p>

net stop MSExchangeES
net stop IMAP4Svc
net stop POP3Svc
net stop RESvc
net stop MSExchangeIMC
net stop MSExchangeSRS
net stop MSExchangeMGMT
net stop MSExchangeMTA
net stop MSExchangeIS /Y
net stop MSExchangeSA /Y
xcopy "X:\dades exchange\*" "x:\copia exchange\ExchangeOfflineBackup" /E /D /V /C /I /F /H /R /K /O /Y
net start MSExchangeSA /Y
net start MSExchangeIS /Y
net start MSExchangeMTA
net start MSExchangeMGMT
net start MSExchangeSRS
net start MSExchangeIMC
net start RESvc
net start POP3Svc
net start IMAP4Svc
net start MSExchangeES

<p>&nbsp;</p>
<p>this one. bat, it would be for Exchange 2007 2010 is that I think works best, in this case the databases are in<strong> X:\dades exchange </strong>and copied to the location:&nbsp;<strong>x:\copia exchange\ExchangeOfflineBackup</strong>,you can adapt it to your convenience:</p>

Echo 'Stopping Microsoft Exchange Services'
net stop MSExchangeAB /Y
net stop MSExchangeADTopology /Y
net stop MSExchangeAntispamUpdate
net stop MSExchangeEdgeSync
net stop MSExchangeFBA
net stop MSExchangeFDS
net stop MSExchangeIS
net stop MSExchangeMailboxAssistants
net stop MSExchangeMailboxReplication
net stop MSExchangeMailSubmission
net stop MSExchangeProtectedServiceHost
net stop MSExchangeRepl
net stop MSExchangeRPC
net stop MSExchangeSA
net stop MSExchangeSearch
net stop MSExchangeServiceHost
net stop MSExchangeThrottling
net stop MSExchangeTransport
net stop MSExchangeTransportLogSearch
xcopy "X:\dades exchange\*" "x:\copia exchange\ExchangeOfflineBackup" /E /D /V /C /I /F /H /R /K /O /Y
<div>Echo 'Starting Microsoft Exchange Services'</div>
net start MSExchangeAB
net start MSExchangeADTopology
net start MSExchangeAntispamUpdate
net start MSExchangeEdgeSync
net start MSExchangeFBA
net start MSExchangeFDS
net start MSExchangeIS
net start MSExchangeMailboxAssistants
net start MSExchangeMailboxReplication
net start MSExchangeMailSubmission
net start MSExchangeProtectedServiceHost
net start MSExchangeRepl
net start MSExchangeRPC
net start MSExchangeSA
net start MSExchangeSearch
net start MSExchangeServiceHost
net start MSExchangeThrottling
net start MSExchangeTransport
net start MSExchangeTransportLogSearch
Facebooktwitterredditpinterestlinkedinmail

Read More ...

Extract Exchange 2010 information

>An interesting script to extract exchange 2010 information from databases and mailboxes (mailbox sorted by descending size) produces a html file like this:

Report Exchange

the image in original format: Imagen

The code:

#####################################################################################
# Exchange 2010 Mailbox Database HTML Email Report
# Author: Thiyagu14
# Date Jan 28th 2010
# Modified by Jordi Colomé
# Script gathers below information
# 1. Server currently hosting the Database.
# 2. Database Size
# 3. Database file path
# 4. Number of users in the Database.
# 5. Amount of Whitespace
# 6. Top Mailbox in the Database and the size of it.
# 7. Last Backup time and days since last backup.
# ###################################################################################
# It then generates HTML Files for this.
# You can setup Threshold in the script,below are the items which can have threshold
# 1. Number of Mailboxes
# 2. Database Size
# 3. How old a Backup can be
# 4. Top Mailbox Size
# If any one of the above threshold is reached the configured threshold.
# It will be marked as red in the HTML.
#####################################################################################
Remove-Item DBReport.htm
New-Item -ItemType file  -Name dbreport.htm
$mailboxCountThreshold =  60
$dbSizeThreshold = 30GB
$backupThreshold = 1
$mbxSizeThreshold = 3000MB
$fileName = "DBReport.htm"
Function writeHtmlHeader
{
param($fileName)
$date = ( Get-Date ).ToString('yyyy/MM/dd')
Add-Content $fileName "<html>"
Add-Content $fileName "<head>"
Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
Add-Content $fileName '<title>myExchangeWorld.COM Database Report</title>'
Add-Content $fileName '<STYLE TYPE="text/css">'
Add-Content $fileName  "<!--"
Add-Content $fileName  "td {"
Add-Content $fileName  "font-family: Tahoma;"
Add-Content $fileName  "font-size: 11px;"
Add-Content $fileName  "border-top: 1px solid #999999;"
Add-Content $fileName  "border-right: 1px solid #999999;"
Add-Content $fileName  "border-bottom: 1px solid #999999;"
Add-Content $fileName  "border-left: 1px solid #999999;"
Add-Content $fileName  "padding-top: 0px;"
Add-Content $fileName  "padding-right: 0px;"
Add-Content $fileName  "padding-bottom: 0px;"
Add-Content $fileName  "padding-left: 0px;"
Add-Content $fileName  "}"
Add-Content $fileName  "body {"
Add-Content $fileName  "margin-left: 5px;"
Add-Content $fileName  "margin-top: 5px;"
Add-Content $fileName  "margin-right: 0px;"
Add-Content $fileName  "margin-bottom: 10px;"
Add-Content $fileName  ""
Add-Content $fileName  "table {"
Add-Content $fileName  "border: thin solid #000000;"
Add-Content $fileName  "}"
Add-Content $fileName  "-->"
Add-Content $fileName  "</style>"
Add-Content $fileName "</head>"
Add-Content $fileName "<body>"
Add-Content $fileName  "<table width='100%'>"
Add-Content $fileName  "<tr bgcolor='#CCCCCC'>"
Add-Content $fileName  "<td colspan='7' height='25' align='center'>"
Add-Content $fileName  "<font face='tahoma' color='#003399' size='4'><strong>-www.colome.org- Database Report - $date</strong></font>"
Add-Content $fileName  "</td>"
Add-Content $fileName  "</tr>"
Add-Content $fileName  "</table>"
}
# Function to write the HTML Header to the file
Function writeTableHeader
{
param($fileName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='10%' align='center'>Database Name</td>"
Add-Content $fileName "<td width='10%' align='center'>Server</td>"
Add-Content $fileName "<td width='15%' align='center'>Database File</td>"
Add-Content $fileName "<td width='10%' align='center'>Database Size(MB)</td>"
Add-Content $fileName "<td width='7%' align='center'># of Mailboxes</td>"
Add-Content $fileName "<td width='10%' align='center'>WhiteSpace(MB)</td>"
Add-Content $fileName "<td width='10%' align='center'>Top Mailbox</td>"
Add-Content $fileName "<td width='10%' align='center'>Top Mailbox Size</td>"
Add-Content $fileName "<td width='10%' align='center'>Last Full Backup</td>"
Add-Content $fileName "<td width='15%' align='center'>No Backup Since?</td>"
Add-Content $fileName "</tr>"
} 

Function writeTableHeader2
{
param($fileName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='10%' align='center'>DisplayName</td>"
Add-Content $fileName "<td width='10%' align='center'>ItemCount</td>"
Add-Content $fileName "<td width='10%' align='center'>TotalItemSize</td>"
Add-Content $fileName "<td width='10%' align='center'>LastLogonTime</td>"
Add-Content $fileName "<td width='10%' align='center'>TotalDeletedItemSize</td>"
Add-Content $fileName "<td width='10%' align='center'>ServerName</td>"
Add-Content $fileName "<td width='10%' align='center'>Database</td>"
Add-Content $fileName "</tr>"
}
Function writeHtmlTable
{
param($fileName)
Add-Content $fileName "</table>"
}
Function writeHtmlFooter
{
param($fileName) 

Add-Content $fileName "</body>"
Add-Content $fileName "</html>"
} 

Function get-DBInfo
{
 $dbs = Get-MailboxDatabase -Status
 foreach($db in $dbs)
 {
     $name = $db.name
    $svr = $db.servername
    $edb = $db.edbfilepath
    $edbSize = $db.DatabaseSize.Tobytes()
    $whiteSpace = $db.AvailableNewMailboxSpace.Tobytes()/1mb
    $mbxCount = (Get-Mailbox -Database $db).count
    $topMailbox = Get-Mailbox -Database $db | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending |Select-Object DisplayName -First 1 | Format-Table Displayname -HideTableHeaders | Out-String
    $topMailboxSize = Get-Mailbox -Database $db| Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object totalitemsize -First 1
    $topMailboxSize = $topMailboxSize.TotalItemSize.Value.ToBytes()
    $lastBackup =  $db.LastFullBackup; $currentDate = Get-Date
    if ($lastBackup -eq $null)
    {
     $howOldBkp =  $null
    }
    else
    {
    $howOldBkp = $currentDate - $lastBackup
    $howOldBkp = $howOldBkp.days
    }
    writedata $name $svr $edb $edbSize $whiteSpace $mbxCount $topMailbox $topMailboxSize $lastBackup $howOldBkp
 }
}
Function get-DBInfoUsers
{
 $dbs = Get-MailboxDatabase -Status
 foreach($db in $dbs)
 { 

    $Mailboxes = Get-Mailbox -Database $db | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending
    foreach($mb in $Mailboxes)
	{
	$1=$mb.DisplayName
	$2=$mb.ItemCount
	$3=$mb.TotalItemSize
	$4=$mb.LastLogonTime
	$5=$mb.TotalDeletedItemSize
	$6=$mb.ServerName
	$7=$mb.Database

    	$tableEntry = "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td><td>$6</td><td>$7</td></tr>"
	Add-Content $fileName $tableEntry
	Write-Host $tableEntry
	}
 } 

} 

Function WriteData
{
param($name,$svr,$edb,$edbSize,$whiteSpace,$mbxCount,$topMailbox,$topMailboxSize,$lastBackup,$howOldBkp) 

$tableEntry = "<tr><td>$name</td><td>$svr</td><td>$edb</td>"
#Checking if EDB size is greater than the set  Threshold
#If it is greater than the table cell will be marked red, else green.
if ($edbSize -gt $dbSizeThreshold)
{
 $edbSize = $edbSize/1mb
 $tableEntry += "<td bgcolor='#FF0000' align=center>$edbSize</td>"
}
else
{
 $edbSize = $edbSize/1mb
 $tableEntry += "<td bgcolor='#387C44' align=center>$edbSize</td>"
}
#Checking if mailbox count is greater than configured threshold
if ($mbxCount -gt $mailboxCountThreshold)
{
 $tableEntry += "<td bgcolor='#FF0000' align=center>$mbxCount</td>"
}
else
{
 $tableEntry += "<td bgcolor='#387C44' align=center>$mbxCount</td>"
}
$tableEntry +=  "<td>$whiteSpace</td>"
$tableEntry +=  "<td>$topMailbox</td>"
#Checking if mailbox count threshold is exceeded or not
if ($topMailboxSize -gt $mbxSizeThreshold)
{
 $topMailboxSize = $topMailboxSize/1mb ; $topMailboxSize =[Math]::Round($topMailboxSize,2)
 $tableEntry += "<td bgcolor='#FF0000' align=center>$topMailboxSize</td>"
}
else
{
 $topMailboxSize = $topMailboxSize/1mb ; $topMailboxSize =[Math]::Round($topMailboxSize,2)
 $tableEntry += "<td bgcolor='#387C44' align=center>$topMailboxSize</td>"
}
#Checking how old is the backup 

if ($howOldBkp -eq $null)
{ 

 $tableEntry += "<td bgcolor='#FF0000' align=center> null </td>"
 $tableEntry += "<td bgcolor='#FF0000' align=center>Never Backed Up</td>"
}
elseif ($howOldBkp -le $backupThreshold)
{
 $tableEntry += "<td bgcolor='#387C44' align=center>$lastbackup</td>"
 $tableEntry += "<td bgcolor='#387C44' align=center>$howOldBkp</td>"
}
else
{
 $tableEntry += "<td bgcolor='#FF0000' align=center>$lastbackup</td>"
 $tableEntry += "<td bgcolor='#FF0000' align=center>$howOldBkp</td>"
}
Add-Content $fileName $tableEntry
Write-Host $tableEntry
} 

Function sendEmail
{ param($from,$to,$subject,$smtphost,$htmlFileName)
$body = Get-Content $htmlFileName
$smtp= New-Object System.Net.Mail.SmtpClient $smtphost
$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body
$msg.isBodyhtml = $true
$smtp.send($msg)
} 

writehtmlheader $fileName
writetableheader $fileName
get-DBInfo
writeHtmlTable $fileName
writetableheader2 $fileName
get-DBInfoUsers
writeHtmlTable $fileName
writehtmlfooter $fileName 

#sendEmail User@Domain.com User@DOMAIN.com "Database Report" server1 $fileName
Facebooktwitterredditpinterestlinkedinmail

Read More ...

5.7.1 Unable to Relay Exchange 2010

Sometimes if you configure an external users to use the smtp service  with authentication (Relay Exchange)  of your exchange 2010 server, you can experience this error “Unable to Relay”:

Excahange2010-1

Smtp connector properties Relay Exchange

“550 5.7.1 Unable to relay”

this is becose the default smtp connector does not have basic authentication enabled by default

First, on your default smtp connector, you have to uncheck this option:

  • Basic Authentication
    • Offer Basic authentication only after starting TLS

Second, assing rights to the users to send mails to any email address:

Get-ReceiveConnector “Default SMTP” | Add-ADPermission -User “DOMAINUsers” -ExtendedRights “ms-Exch-SMTP-Accept-Any-Recipient”

Attention! if you include “AUTHORITYANONYMOUS LOGON” as user then you can have a open Relay!!:

do not do this:

Get-ReceiveConnector “Default SMTP”|Add-ADPermission -User “NT AUTHORITYANONYMOUS LOGON” -ExtendedRights “ms-Exch-SMTP-Accept-Any-Recipient”

 

my latest development (Multiplayer Online Charts game): http://mp.colome.org

 

Facebooktwitterredditpinterestlinkedinmail

Read More ...

Categories

Subscribe to my Newsletter




By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close