{"id":584,"date":"2021-05-30T20:23:01","date_gmt":"2021-05-30T20:23:01","guid":{"rendered":"https:\/\/www.spktechfit.com\/?p=584"},"modified":"2021-05-30T20:37:04","modified_gmt":"2021-05-30T20:37:04","slug":"simplivity-backup-reports-with-powershell","status":"publish","type":"post","link":"https:\/\/www.spktechfit.com\/?p=584","title":{"rendered":"Simplivity Backup Reports with PowerShell"},"content":{"rendered":"<p>An issue with Flash in the web browser and the version of Simplivity we are running forced my hand to learn to manage the backups using PowerShell. I started managing the backups through the Simplivity CLI but then discovered there was an PowerShell API which made life a lot easier. If you have experience using PowerShell you will find these commands easy to pick up. I was also able to create a Daily Report that I schedule to email me each day.<\/p>\n<h2>HPE Simplivity PowerShell Module<\/h2>\n<p>This website has everything you need for installing and using the module:<\/p>\n<p><a href=\"https:\/\/developer.hpe.com\/blog\/hpe-simplivity-powershell-module\/\" target=\"_blank\" rel=\"noopener\">https:\/\/developer.hpe.com\/blog\/hpe-simplivity-powershell-module\/<\/a><\/p>\n<p><strong>Install the module:<\/strong><\/p>\n<pre>PS C:\\&gt; Install-Module -Name HPESimpliVity<\/pre>\n<p><strong>Connect to OVC:<\/strong><\/p>\n<pre>PS C:\\&gt; $Cred = Get-Credential -Message 'Enter OVC\/MVA Credentials'\r\nPS C:\\&gt; Connect-SVT -OVC -Credential $Cred<\/pre>\n<p>and away you go!<\/p>\n<p>You will find all the commands on the page listed above.<\/p>\n<h3>Examples<\/h3>\n<p>1- Create Manual backup and retain for 4 days<\/p>\n<pre>New-SVTbackup -VmName SRV1-DestinationName DR -BackupName SRV1_ManualBackup -RetentionDay 4<\/pre>\n<p>2- Get all backups for server &#8220;SRV1&#8221; on the &#8220;DR&#8221; cluster that were created before 31st December 2020<\/p>\n<pre>Get-SVTbackup -VmName SRV1 -DestinationName DR -CreatedBefore \"31\/12\/2020\"<\/pre>\n<h2>Backup Report<\/h2>\n<p>This is a simple Daily Report I created which gives me:<\/p>\n<ul>\n<li>Host storage information<\/li>\n<li>Lists any failed backups<\/li>\n<li>Lists the last 200 backups (VM name, Backup state, Destination, Sent MB)<\/li>\n<\/ul>\n<p>Here is an example of the Report:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-588\" src=\"https:\/\/www.spktechfit.com\/wp-content\/uploads\/2021\/05\/SimplivityReport.png\" alt=\"\" width=\"880\" height=\"880\" \/><\/p>\n<p>To be honest, the hardest thing about setting up this report for me was getting the HTML right so it formats properly. Getting the data I needed was relatively easy.<\/p>\n<p>Below is the code I used for my report. I set this to run as a scheduled task daily.<\/p>\n<pre><span style=\"color: #339966;\">#Date Information to be used in the headers<\/span>\r\n<span style=\"color: #ff0000;\">$TodaysDate<\/span> = (Get-Date).ToString('yyyy-MM-dd')\r\n<span style=\"color: #ff0000;\">$LastWeek<\/span> = (Get-Date).Adddays(-7).ToString('dd\/MM\/yyyy')\r\n\r\n<span style=\"color: #339966;\">#Get Creds to login to OVC. This is covered in the https:\/\/developer.hpe.com\/blog\/hpe-simplivity-powershell-module\/<\/span>\r\n<span style=\"color: #ff0000;\">$Cred<\/span> = Import-CLIXML .\\OVCcred.XML\r\n\r\n<span style=\"color: #339966;\">#Connect to OVC<\/span>\r\nConnect-SVT -OVC <em>(IP of your OVC)<\/em> -Credential <span style=\"color: #ff0000;\">$cred<\/span>\r\n\r\n<span style=\"color: #339966;\">#Location to save report<\/span>\r\n<span style=\"color: #ff0000;\">$reportLocation<\/span> = \"\\\\Server\\Reports\\SimplivityReport-<span style=\"color: #ff0000;\">$TodaysDate<\/span>.html\"\r\n\r\n<span style=\"color: #339966;\">#Create HTML Table<\/span>\r\n<span style=\"color: #ff0000;\">$head<\/span> = @\u2019\r\n&lt;style&gt;\r\nbody { background-color:#dddddd;\r\nfont-family:Tahoma;\r\nfont-size:12pt; }\r\ntd, th { border:1px solid black;\r\nborder-collapse:collapse; }\r\nth { color:white;\r\nbackground-color:black; }\r\ntable, tr, td, th { padding: 2px; margin: 0px }\r\ntable { margin-left:50px; }\r\n&lt;\/style&gt;\r\n\u2018@\r\n\r\n\r\n<span style=\"color: #339966;\">#-------Building Report--------------#<\/span>\r\n\r\n<span style=\"color: #339966;\">#Get Host Information - Name, Cluster, Freespace, Usedspace, IP<\/span>\r\n<span style=\"color: #ff0000;\">$hostInfo<\/span> = Get-SVThost | Select HostName, ClusterName, FreeSpaceGB, UsedCapacityGB,ManagementIP | ConvertTo-Html -PreContent \"&lt;h2&gt;Host Information&lt;\/h2&gt;\" | Out-String\r\n\r\n<span style=\"color: #339966;\">#Get backups with the backup state \"Failed\" that were created in the last week <\/span>\r\n<span style=\"color: #ff0000;\">$FailedBackups<\/span> =\"\"\r\nTry\r\n{\r\n<span style=\"color: #ff0000;\">$FailedBackups<\/span> = Get-SVTbackup -BackupState FAILED -CreatedAfter $LastWeek |Select VMNAme, BackupState, CreateDate, DestinationName | ConvertTo-Html -PreContent \"&lt;h2&gt;Failed Backups&lt;\/h2&gt;\" | Out-String\r\n}\r\ncatch { <span style=\"color: #ff0000;\">$FailedBackups<\/span> = ConvertTo-Html -PreContent \"&lt;h2&gt;No FAILED Backups found&lt;\/h2&gt;\" | Out-String }\r\n<span style=\"color: #339966;\">\r\n#GEt last 200 backups<\/span>\r\n<span style=\"color: #ff0000;\">$Last200Backups<\/span> = GEt-SVTBackup -limit 200 -Hour 1000| Select VMNAme, BackupState, CreateDate, DataStoreName, DestinationName, SentMB, SizeGB | ConvertTo-Html -PreContent \"&lt;h2&gt;Last 200 Backups&lt;\/h2&gt;\" | Out-String\r\n\r\n<span style=\"color: #339966;\">#Set Display Title<\/span>\r\n<span style=\"color: #ff0000;\">$DisplayTitle<\/span> = \"Simplivity Server Report: \" + (Get-Date).ToString('dd\/MM\/yyyy')\r\n\r\n<span style=\"color: #339966;\">#Create Report<\/span>\r\nConvertTo-Html -Head <span style=\"color: #ff0000;\">$head<\/span> -Title \"Simplivity Report\" -Body (GEt-date) -PostContent <span style=\"color: #ff0000;\">$hostInfo<\/span>,<span style=\"color: #ff0000;\">$FailedBackups<\/span>, <span style=\"color: #ff0000;\">$Last200Backups<\/span> -PreContent \u201c&lt;h1&gt;$DisplayTitle&lt;\/h1&gt;\u201d &gt; <span style=\"color: #ff0000;\">$reportLocation<\/span>\r\n\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>An issue with Flash in the web browser and the version of Simplivity we are running forced my hand to learn to manage the backups using PowerShell. I started managing the backups through the Simplivity CLI but then discovered there was an PowerShell API which made life a lot easier. If you have experience using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":588,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8,3],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/584"}],"collection":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":3,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":589,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/589"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/media\/588"}],"wp:attachment":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}