Created
January 20, 2016 02:11
-
-
Save rufflabs/61ef2ae12d08ead6ec91 to your computer and use it in GitHub Desktop.
Emails a report of VM's that aren't assigned a backup policy tag in vCenter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin VMware.VimAutomation.Core | |
Set-PowerCliConfiguration -InvalidCertificateAction Ignore -Confirm:$False | |
Connect-VIServer $vCenterServer | |
# vCenter hostname | |
$vCenterServer = '' | |
$smtpServer = '' | |
# Email report from address | |
$reportFrom = '' | |
# Email report subject | |
$reportSubject = 'Report: Unprotected VMs' | |
# Email recipients | |
$Recipients = @( | |
'[email protected]', | |
'[email protected]' | |
) | |
# VM's to ignore, these are not backed up | |
$Ignored = @( | |
'test', | |
'test2' | |
) | |
$Unprotected = Get-VM | Where-Object { | |
(Get-TagAssignment -Entity $_).Tag.Category.Name -ne 'Backup Policies' -and | |
$_.Name -notin $Ignored | |
} | |
$Body = "The following VM's are not being backed up by Veeam. If one needs backed up, please add an appropriate tag in vCenter from the Backup Policies category. If one of these is intentionaly not backed up add it to the `$Ignored array in this script to no longer show it in this report.`n`n" | |
$Unprotected | Sort Name | ForEach-Object { $Body += "$($_.Name) $(if($_.PowerState -eq 'PoweredOff'){"($($_.PowerState))"})`n"} | |
Send-MailMessage -To $Recipients -From $reportFrom -Subject $reportSubject -SmtpServer $smtpServer -Body $Body | |
Disconnect-VIServer -Confirm:$False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment