VMware Cloud Community
pizzle85
Expert
Expert
Jump to solution

Exporting Content Package via REST through Power-Shell

I'm attempting to script the export and import of content between our vRA environments in Power-Shell. I am having issues downloading the package as a ZIP file from the REST API as described at this link Syntax for Exporting a Package

The command I'm executing is:

Invoke-WebRequest https://vraserver/content-management-service/api/packages/ef43b494-140f-44c3-9ded-3a1a48aa1190 -Headers $header -OutFile .\file.zip

This does not work.

A test command that does work is:

Invoke-WebRequest https://github.com/me/dotfiles/archive/master.zip -OutFile .\master.zip

I am able to download the file successfully from a Linux machine using the command:

curl --insecure -s -H "Accept: application/zip" -H "Authorization: Bearer $token" https://vraserver/content-management-service/api/packages/ef43b494-140f-44c3-9ded-3a1a48aa1190 -o package.zip

I've tried everything i can think of but it looks like the REST API is just returning me some JSON that Power-Shell is sticking into a file not actually grabbing a ZIP file.

0 Kudos
1 Solution

Accepted Solutions
thecloudxpert
Enthusiast
Enthusiast
Jump to solution

Hi pizzle85,

Have you tried using PowerVRA? GitHub - jakkulabs/PowervRA: vRealize Automation PowerShell Toolkit

I have successfully exported content from one environment to another using this PowerShell/PowerCLI Module AND it does all the heavy lifting for you!

Chris

View solution in original post

0 Kudos
2 Replies
thecloudxpert
Enthusiast
Enthusiast
Jump to solution

Hi pizzle85,

Have you tried using PowerVRA? GitHub - jakkulabs/PowervRA: vRealize Automation PowerShell Toolkit

I have successfully exported content from one environment to another using this PowerShell/PowerCLI Module AND it does all the heavy lifting for you!

Chris

0 Kudos
pizzle85
Expert
Expert
Jump to solution

I had forgotten all about PowervRA. I grabbed it from the gallery and was able to use it to export and import my content. Thanks for the reminder!

FWIW i wrote up a blog that contains the script i used.

https://wordpress.com/post/paulsmithit.wordpress.com/63

0 Kudos