Created
September 21, 2016 14:48
-
-
Save chelnak/63410d041bbf9bff620b3722a9a52740 to your computer and use it in GitHub Desktop.
Export vRA blueprints as content packages with PowervRA
This file contains 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
#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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was New-vRAContentPackage deprecated in later versions of powervra? can't seem to find it