Thursday, 18 December 2014 00:00

PowerShell Script to Report Symantec Enterprise Vault Backup Mode Status

Written by

In my previous post, I have shared a script to Monitor Enterprise Vault Partition Growth / Size. If you are using that, it will be easy for you to understand this script as well. As you are aware, many of us run the pre and post backup script to make the EV servers ready for backup mode and release it. These scripts are normally scheduled or ran by the backup software. Regardless of the way it ran, the script provide a little information to the administrators about the status of store and index backup mode status.

This script is written to capture the backup mode status of all available store and Index location. You may schedule this script to run at a specified time, and verify the status at a glance and thus avoid regular check by logging into the EV server/Console.

Note - The Enterprise Vault scripts will only run on x86 powershell version. This limitation is because the commands from EV are not designed to work in 64 bit version of powershell. Ensure you run the script in x86 powershell.

Download the Script Here

The Full Script:

Import-Module "C:\Program Files (x86)\Enterprise Vault\Symantec.EnterpriseVault.PowerShell.AdminAPI.dll"

Import-Module "C:\Program Files (x86)\Enterprise Vault\Symantec.EnterpriseVault.PowerShell.Core.dll"

Import-Module "C:\Program Files (x86)\Enterprise Vault\Symantec.EnterpriseVault.PowerShell.IMAP.dll"

Import-Module "C:\Program Files (x86)\Enterprise Vault\Symantec.EnterpriseVault.PowerShell.Monitoring.dll"

$BkpFile = "C:\Scripts\HTML\Backup_Mode.htm" #Change the Value

$serverlist = (Get-EVComputers | select ComputerNameAlternate).ComputerNameAlternate

$evsite = (Get-EVSite | select Name).Name

$ModeValue = "False"

$date = ( Get-Date ).ToString('yyyy/MM/dd - hh:mm')

$smtphost = "yourSMTP_Server" #Change the Value

$from = "This email address is being protected from spambots. You need JavaScript enabled to view it." #Change the Value

$to = "This email address is being protected from spambots. You need JavaScript enabled to view it." #Change the Value

New-Item -ItemType file $BkpFile -Force

Function writeHtmlHeader

{

       param($fileName)

       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>Enterprise Vault MSMQ Monitor</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>"

}

Function writeTableMemHeader

{

       param($fileName)

       Add-Content $fileName "<tr bgcolor=#B0AE5B>"

       Add-Content $fileName "<td width='10%' align='center'>Server/Site Name</td>"

       Add-Content $fileName "<td width='30%' align='center'>Index Location</td>"

       Add-Content $fileName "<td width='15%' align='center'>Backup Mode Status</td>"

       Add-Content $fileName "</tr>"

}

Function writeTableMemHeader2

{

       param($fileName)

       Add-Content $fileName "<tr bgcolor=#B0AE5B>"

       Add-Content $fileName "<td width='10%' align='center'>Server/Site Name</td>"

   Add-Content $fileName "<td width='30%' align='center'>Vault Store</td>"

   Add-Content $fileName "<td width='15%' align='center'>Backup Mode Status</td>"

       Add-Content $fileName "</tr>"

}

Function writeHtmlFooter

{

       param($fileName)

   Add-Content $fileName "</body>"

   Add-Content $fileName "<br/><br/>"

       Add-Content $fileName "</html>"

}

Function writememInfo

{

       param($fileName,$server, $IndexPath, $bkpmode)

      

       Add-Content $fileName "<tr>"

       Add-Content $fileName "<td>$server</td><td>$IndexPath</td>"

       If ("$bkpmode" -eq "False")

       {

              Add-Content $fileName "<td bgcolor='#086105' align=center>OFF</td>"

       }

       Else

       {

              Add-Content $fileName "<td bgcolor='#FF6B17' align=center>ON</td>"

       }            

       Add-Content $fileName "</tr>"

}

writeHtmlHeader $BkpFile

   add-content $BkpFile "<table width='55%'>"

       add-content $BkpFile "<tr bgcolor='#CCCCCC'>"

       add-content $BkpFile "<td colspan='3' height='25' align='center'>"

       add-content $BkpFile "<font face='tahoma' color='#003399' size='4'><strong>Enterprise Vault Backup Mode Monitor - $date</strong></font>"

       add-content $BkpFile "</td>"

       add-content $BkpFile "</tr>"

       add-content $BkpFile "</table>"

foreach ($server in $evsite)

{

       Add-Content $BkpFile "<table width='55%'><tbody>"

       Add-Content $BkpFile "<tr bgcolor='#CCCCCC'>"

       Add-Content $BkpFile "<td width='55%' align='center' colSpan=3><font face='tahoma' color='#003399' size='2'><strong> $server </strong></font></td>"

       Add-Content $BkpFile "</tr>"

       writeTableMemHeader $BkpFile

       $indexs = Get-IndexLocationBackupMode $server -EVSiteName archival | select-object indexrootpath, backupmode

       foreach ($index in $indexs) {

              $IndexPath = $index.IndexRootPath

              $bkpmode = $index.BackupMode

      

       writememInfo $BkpFile $server $IndexPath $bkpmode

       }

       #Add-Content $BkpFile "</table>"

  

   writeTableMemHeader2 $BkpFile

   $stores = Get-VaultStoreBackupMode -EVServerName $server -Name archival -EvObjectType Site | select-object VaultStoreName, BackupMode

       foreach ($store in $stores) {

              $storename = $store.VaultStoreName

              $bkpmode = $store.BackupMode            

      

       writememInfo $BkpFile $server $storename $bkpmode

       }

   Add-Content $BkpFile "</table>"

}

Writehtmlfooter $BkpFile

#Sending Email

   $subject = "Attention: Enterprise Vault HEALH CHECK REPORT"

   $body = Get-Content $BkpFile

   $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)

   # --------- Script Ends ----------------

Download the Script Here

Share your experience!

-Praveen

theme by reviewshub