Advertisement
lunort

test

Mar 7th, 2021
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ######################################################################
  2. #                                                                    #
  3. # Download and Unzip GitHub Repository                               #
  4. # Author: Sandro Pereira                                             #
  5. #                                                                    #
  6. ######################################################################
  7.  
  8. function DownloadGitHubRepository
  9. {
  10.     param(
  11.        [Parameter(Mandatory=$True)]
  12.        [string] $Name,
  13.          
  14.        [Parameter(Mandatory=$True)]
  15.        [string] $Author,
  16.          
  17.        [Parameter(Mandatory=$False)]
  18.        [string] $Branch = "master",
  19.          
  20.        [Parameter(Mandatory=$False)]
  21.        [string] $Location = "c:\temp"
  22.     )
  23.      
  24.     # Force to create a zip file
  25.     $ZipFile = "$location\$Name.zip"
  26.     New-Item $ZipFile -ItemType File -Force
  27.  
  28.     #$RepositoryZipUrl = "https://github.com/sandroasp/Microsoft-Integration-and-Azure-Stencils-Pack-for-Visio/archive/master.zip"
  29.     $RepositoryZipUrl = "https://api.github.com/repos/$Author/$Name/zipball/$Branch"
  30.     # download the zip
  31.     Write-Host 'Starting downloading the GitHub Repository'
  32.     Invoke-RestMethod -Uri $RepositoryZipUrl -OutFile $ZipFile
  33.     Write-Host 'Download finished'
  34.  
  35.     #Extract Zip File
  36.     Write-Host 'Starting unzipping the GitHub Repository locally'
  37.     Expand-Archive -Path $ZipFile -DestinationPath $location -Force
  38.     Write-Host 'Unzip finished'
  39.      
  40.     # remove the zip file
  41.     Remove-Item -Path $ZipFile -Force
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement