Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created February 23, 2017 16:54
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 tugberkugurlu/216484ed4265ab6943993bf55dc84f72 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/216484ed4265ab6943993bf55dc84f72 to your computer and use it in GitHub Desktop.
Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } | sort -property Id -unique | % {
$pkg = $_ ;
Try {
$targetFile = "C:\sqlclone-licenses\$($pkg.Id)-$($pkg.Version).txt"
(New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, $targetFile)
$lineToAppend = "License downloaded from '$($pkg.LicenseUrl)' on '$([DateTime]::UtcNow.ToString('R'))'$([Environment]::NewLine)$([Environment]::NewLine)"
Set-Content $targetFile ($lineToAppend + (get-content $targetFile))
} Catch [system.exception] {
Write-Host "Could not download license for ($pkg.Id)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment