Skip to content

Instantly share code, notes, and snippets.

@chelnak
Created September 21, 2016 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelnak/63410d041bbf9bff620b3722a9a52740 to your computer and use it in GitHub Desktop.
Save chelnak/63410d041bbf9bff620b3722a9a52740 to your computer and use it in GitHub Desktop.
Export vRA blueprints as content packages with PowervRA
#requires -version 5
<#
- Export vRA Blueprint content package and extract the archive
- Requires PowerShell 5
#>
# --- Set Filter
$Filter = "CentOS*"
# --- Get blueprints
$Blueprints = Get-vRABlueprint -Verbose | Where-Object {$_.Name -like $Filter}
# --- Create a content package for each blueprint in $Blueprints
$Blueprints | ForEach-Object {
New-vRAContentPackage -BlueprintId $_.Id -Name "$($_.Name)" -Description "Content package for blueprint $($_.Name)" -Verbose | Out-Null
}
# --- Get content packages
$ContentPackages = Get-vRAContentPackage -Verbose | Where-Object {$_.Name -like $Filter}
# --- Export each content package to the current directory
$ContentPackages | ForEach-Object {
$File = Export-vRAContentPackage -Id $_.Id -File "$($_.Name).zip" -Verbose
# --- Unzip
$Destination = "$($File.DirectoryName)\$($File.BaseName)"
Expand-Archive -Path $File.FullName -DestinationPath $Destination -Verbose
Remove-Item -Path $File.FullName -Force -Verbose
}
@jzajac2
Copy link

jzajac2 commented Dec 14, 2017

Was New-vRAContentPackage deprecated in later versions of powervra? can't seem to find it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment