And now, I am trying to add more functionalities like:
Automatically install (configure) all the Visio files (*.vssx), so that next time you open Visio, they will be there available;
And also the possibility to download the most recent version from GitHub and install it locally;
Well, the first task is quite simple, you just need to locate all the *.vssx files and copy to the folder “C:Usersyou_userDocumentsMy Shapes” (that is the default folder for the Visio custom shapes)
The second part is a little trick. I found many resources while searching on the internet, but none was what I intended to do. Some were quite nice, but we could easily reach the API Rate limit that is 60 requests per hour for unauthenticated requests or 5000 requests per hour if you use Basic Authentication or OAuth. Or it simply didn’t unzip properly.
I want to archive a simple way to download a full GitHub repository and unzip it locally. Simple as going in the browser and select Code > Download ZIP, that’s it!
Since I was doing all this work, I also decide to make it available a generic PowerShell function that will allow you to download any GitHub Repository.
######################################################################
# #
# Download and Unzip GitHub Repository #
# Author: Sandro Pereira #
# #
######################################################################
function DownloadGitHubRepository
{
param(
[Parameter(Mandatory=$True)]
[string] $Name,
[Parameter(Mandatory=$True)]
[string] $Author,
[Parameter(Mandatory=$False)]
[string] $Branch = "master",
[Parameter(Mandatory=$False)]
[string] $Location = "c:temp"
)
# Force to create a zip file
$ZipFile = "$location$Name.zip"
New-Item $ZipFile -ItemType File -Force
#$RepositoryZipUrl = "https://github.com/sandroasp/Microsoft-Integration-and-Azure-Stencils-Pack-for-Visio/archive/master.zip"
$RepositoryZipUrl = "https://api.github.com/repos/$Author/$Name/zipball/$Branch"
# download the zip
Write-Host 'Starting downloading the GitHub Repository'
Invoke-RestMethod -Uri $RepositoryZipUrl -OutFile $ZipFile
Write-Host 'Download finished'
#Extract Zip File
Write-Host 'Starting unzipping the GitHub Repository locally'
Expand-Archive -Path $ZipFile -DestinationPath $location -Force
Write-Host 'Unzip finished'
# remove the zip file
Remove-Item -Path $ZipFile -Force
}
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.