<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OneView Backup Script - powershell Invoke-Rest in HPE OneView</title>
    <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7097163#M5505</link>
    <description>&lt;P&gt;Aweomse, thanks for the tip!&amp;nbsp; I'll look for the HPE supported commandlets.&amp;nbsp; The company I'm with allows us to download from HPE so I probably just need to dig around a bit more.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the guidance on the invoke-rest command though!&amp;nbsp; Solves that mystery.&amp;nbsp; As always, the advice is much appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2020 13:04:20 GMT</pubDate>
    <dc:creator>thecakeisalie</dc:creator>
    <dc:date>2020-08-04T13:04:20Z</dc:date>
    <item>
      <title>OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096926#M5498</link>
      <description>&lt;P&gt;Hi all, im trying trying to create a script with powershell using Invoke-Rest and having an odd issue.&amp;nbsp; When i run the script i get the download.uri location but when i use the to download uri the file size appears to be different than when i download from the gui.&amp;nbsp; If I change the encoding option to ascii the file size is the same as when i download through the gui.&amp;nbsp; However, when i upload the file i create from the api, to the appliance, it fails verification.&amp;nbsp; &amp;nbsp;Most of the code is below, any advice?&amp;nbsp; This is the first time i've tried downloading through powershell so not sure if im missing a step.&amp;nbsp; Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Kick off the backup&lt;BR /&gt;$uri = $url + "/rest/backups"&lt;/P&gt;&lt;P&gt;$data = Invoke-RestMethod -Method POST -Headers $auth -Uri $uri&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#Download backup from download uri&lt;/P&gt;&lt;P&gt;$data = Invoke-RestMethod -Method GET -Headers $auth -Uri $uri&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$data.members[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$uri1 = $url + $data.members[0].taskUri&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DO{&lt;BR /&gt;$taskState = Invoke-RestMethod -Method GET -Headers $auth -Uri $uri1&lt;/P&gt;&lt;P&gt;Write-Progress -Activity "Creating backup..." -Status "% Complete: " -PercentComplete $taskState.percentComplete&lt;/P&gt;&lt;P&gt;} Until ($taskState.taskState -eq "Completed")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Write-Host "Location o download uri" -ForegroundColor Green&lt;BR /&gt;$data.members[0].downloadUri&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$download = $data.members[0].downloadUri&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$uri = $url + $download&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$auth.Add("Accept", 'application/octetstream;q=0.8,application/json')&lt;BR /&gt;$auth.Add("Content-type", 'text/plain')&lt;BR /&gt;$auth.Add("Content-Length", '0')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#download the file&lt;BR /&gt;$data = Invoke-RestMethod -Method GET -Headers $auth -Uri $uri -Verbose&lt;/P&gt;&lt;P&gt;#shorten the name of the saved file&lt;/P&gt;&lt;P&gt;$name = $download.IndexOf("/t")&lt;BR /&gt;$newName = $download.Substring($name+1)&lt;BR /&gt;$newName&lt;/P&gt;&lt;P&gt;$data | Out-File -FilePath .\"$newName".bkp -Encoding ascii&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 14:20:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096926#M5498</guid>
      <dc:creator>thecakeisalie</dc:creator>
      <dc:date>2020-07-31T14:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096949#M5499</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/2017640"&gt;@thecakeisalie&lt;/a&gt;&amp;nbsp;, and welcome to the HPE OneView communities.&lt;/P&gt;&lt;P&gt;Is there any reason why you cannot use the existing HPE OneView PowerShell library?&amp;nbsp; We already have a Cmdlet that does this for you:&amp;nbsp; &lt;A href="https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v5.30/appliance/new-ovbackup" target="_blank" rel="noopener"&gt;New-OVBackup&lt;/A&gt;&amp;nbsp;(legacy CMdlet: &lt;A href="https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v5.20/appliance/new-hpovbackup" target="_blank" rel="noopener"&gt;New-HPOVBackup&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;You can get the HPE OneView PowerShell Library from the &lt;A href="https://www.powershellgallery.com/packages?q=HPEOneView&amp;amp;sortOrder=package-created" target="_blank" rel="noopener"&gt;PowerShell Gallery&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 22:41:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096949#M5499</guid>
      <dc:creator>ChrisLynch</dc:creator>
      <dc:date>2020-07-31T22:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096950#M5500</link>
      <description>&lt;P&gt;Well well, we meet at last Mr. Lynch...&amp;nbsp; Thanks for the frequent solutions on other posts, theyve assited me in the past on a variety of issues!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm well aware of the powershell library and do use the iLo and bios commandlets as they can be downloaded from HPE's website.&amp;nbsp; However, the current org im working for doesnt allow downloads from github at the moment so im using this as an oppurtunity to reinvent the wheel a little instead of bypassing the current security policy.&amp;nbsp; It's also a bit of an excercise in "can i get this to work" now.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 02:22:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096950#M5500</guid>
      <dc:creator>thecakeisalie</dc:creator>
      <dc:date>2020-08-01T02:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096992#M5502</link>
      <description>&lt;P&gt;Except the library isn't on Github for customers to download and use. It is the source. The final customer version is digitally signed and supported by HPE.&amp;nbsp; Sure, someone could download it from Github, but then it isn't digitally signed and certainly open for someone to modify at their discretion.&lt;/P&gt;&lt;P&gt;You can certainly look at the source for New-OV Backup for how the library does it. But I would suggest you concider using the library already provided.&lt;/P&gt;&lt;P&gt;And the reason why the upload fails is due to the fact the upload expects a multi-partform binary.&amp;nbsp; Which Invoke-RestMethod does not support.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Aug 2020 03:27:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7096992#M5502</guid>
      <dc:creator>ChrisLynch</dc:creator>
      <dc:date>2020-08-02T03:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7097163#M5505</link>
      <description>&lt;P&gt;Aweomse, thanks for the tip!&amp;nbsp; I'll look for the HPE supported commandlets.&amp;nbsp; The company I'm with allows us to download from HPE so I probably just need to dig around a bit more.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the guidance on the invoke-rest command though!&amp;nbsp; Solves that mystery.&amp;nbsp; As always, the advice is much appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:04:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7097163#M5505</guid>
      <dc:creator>thecakeisalie</dc:creator>
      <dc:date>2020-08-04T13:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: OneView Backup Script - powershell Invoke-Rest</title>
      <link>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7097212#M5507</link>
      <description>&lt;P&gt;As I stated above, the HPE OneView PowerShell library is only located on &lt;A href="https://www.powershellgallery.com/packages?q=HPEOneView&amp;amp;sortOrder=package-created" target="_blank" rel="noopener"&gt;PowerShell Gallary&lt;/A&gt;, which is a Microsoft owned and operated site.&amp;nbsp; They allow anyone to publish scripts and modules there.&amp;nbsp; However, they must have a valid account.&amp;nbsp; All HPE PowerShell libraries are located here, under the "&lt;A href="https://www.powershellgallery.com/packages?q=hp.powershell" target="_blank" rel="noopener"&gt;hp.powershell&lt;/A&gt;" account.&amp;nbsp; So if you go looking on hpe.com, you will not find the HPE OneView PowerShell library hosted there.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 16:34:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-oneview/oneview-backup-script-powershell-invoke-rest/m-p/7097212#M5507</guid>
      <dc:creator>ChrisLynch</dc:creator>
      <dc:date>2020-08-04T16:34:26Z</dc:date>
    </item>
  </channel>
</rss>

