44)
55
66$ModuleName = ' SqlServer-Version-Management' ;
7- $ModuleVersion = ' 2.1.177 ' ;
7+ $ModuleVersion = ' 2.1.179 ' ;
88$ModuleFiles = @ (
99 @ {
1010 FileName = ' SqlServer-Version-Management\SqlServer-Version-Management.psd1' ;
@@ -15,7 +15,7 @@ $ModuleFiles = @(
1515 " ModuleToProcess = @('SqlServer-Version-Management.psm1')" ,
1616 " " ,
1717 " # Version below is automatically incremented on build" ,
18- " ModuleVersion = `" 2.1.177 `" " ,
18+ " ModuleVersion = `" 2.1.179 `" " ,
1919 " " ,
2020 " GUID = 'dd03b53d-575a-4056-ae08-e6dfea3384ea'" ,
2121 " " ,
@@ -480,7 +480,7 @@ $ModuleFiles = @(
480480 " Troubleshoot-Info `" Starting download ```"`" -Highlight `"`$ url`" `"```" using aria2c as ```"`" -Highlight `"`$ outfile`" `"```"`" " ,
481481 " # `" -k`" , `" 2M`" ," ,
482482 " `$ startAt = [System.Diagnostics.Stopwatch]::StartNew()" ,
483- " & aria2c.exe @(`" --allow-overwrite=true`" , `" --check-certificate=false`" , `" -x`" , `" 16`" , `" -j`" , `" 16`" , `" -d`" , `"`$ (`$ dirName)`" , `" -o`" , `"`$ ([System.IO.Path]::GetFileName(`$ outfile))`" , `"`$ url`" );" ,
483+ " & aria2c.exe @(`" --allow-overwrite=true`" , `" --check-certificate=false`" , `" -x`" , `" 16`" , `" -j`" , `" 16`" , `" -d`" , `"`$ (`$ dirName)`" , `" -o`" , `"`$ ([System.IO.Path]::GetFileName(`$ outfile))`" , `"`$ url`" ) | out-null ;" ,
484484 " if (`$ ?) { " ,
485485 " <# Write-Host `" aria2 rocks (`$ ([System.IO.Path]::GetFileName(`$ outfile)))`" ; #> " ,
486486 " try { `$ length = (new-object System.IO.FileInfo(`$ outfile)).Length; } catch {}; `$ milliSeconds = `$ startAt.ElapsedMilliseconds;" ,
@@ -1687,6 +1687,83 @@ $ModuleFiles = @(
16871687 " # @(42) | Reverse-Pipe" ,
16881688 " # @(1,2,3,4,`" 42`" ) | Reverse-Pipe" ,
16891689 " " ,
1690+ " # Include File: [\Includes\Run-Remote-Script.ps1]" ,
1691+ " function Get-FileName-by-Uri([string] `$ url) {" ,
1692+ " `$ uri = [uri]`$ url" ,
1693+ " `$ ret = `$ uri.Segments[-1]" ,
1694+ " if (`$ ret -eq `" download`" -and `$ uri.Segments.Count -gt 1) {" ,
1695+ " `$ ret = `$ uri.Segments[-2]" ,
1696+ " `$ ret=`"`$ ret`" .TrimEnd(`" /`" )" ,
1697+ " }" ,
1698+ " return `$ ret" ,
1699+ " }" ,
1700+ " " ,
1701+ " function Run-Remote-Script() {" ,
1702+ " `$ pars = @(`$ args)" ,
1703+ " `$ url=`$ null" ,
1704+ " `$ runner=`"`" " ,
1705+ " `$ passthrowArgs=@()" ,
1706+ " for(`$ p=0; `$ p -lt `$ pars.Length; `$ p++) {" ,
1707+ " `$ vType=`" 'null'`" ; if (`$ v -ne `$ null) { `$ vType = `"`$ (`$ v.GetType().Name)`" }" ,
1708+ " # Write-Host `" [DEBUG ARGS] v=[`$ v], `$ vType`" -ForegroundColor Yellow" ,
1709+ " `$ v = `$ pars[`$ p];" ,
1710+ " if ((`$ p -le 1) -and (`$ v -eq `" -r`" -or `$ v -eq `" --runner`" )) {" ,
1711+ " if (`$ p+1 -lt `$ pars.Length) {" ,
1712+ " `$ runner=`$ pars[`$ p+1];" ,
1713+ " `$ p++;" ,
1714+ " continue;" ,
1715+ " } Else {" ,
1716+ " throw `" Run-Remote-Script Arguments Error: -r|--runner requires a value`" " ,
1717+ " }" ,
1718+ " }" ,
1719+ " Else {" ,
1720+ " if (`$ url -eq `$ null -or -not `$ url) { " ,
1721+ " `$ url=`$ v" ,
1722+ " } Else {" ,
1723+ " `$ passthrowArgs += `$ v" ,
1724+ " }" ,
1725+ " }" ,
1726+ " }" ,
1727+ " " ,
1728+ " " ,
1729+ " `$ fileOnly = Get-FileName-by-Uri `$ url" ,
1730+ " `$ folder = Combine-Path (Get-PS1-Repo-Downloads-Folder) `" Scripts`" " ,
1731+ " `$ fileFullName = Combine-Path `$ folder `$ fileOnly" ,
1732+ " `$ runnerParameter=`"`" " ,
1733+ " if (-not `$ runner) {" ,
1734+ " if (`"`$ fileFullName`" .ToLower().EndsWith(`" .ps1`" )) {" ,
1735+ " `$ runner=`"`$ ([System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName)`" " ,
1736+ " # or if (([System.IO.Path]::GetFileName(`$ runner)) -eq `" powershell.exe`" )" ,
1737+ " if (`$ PSVersionTable.PSEdition -and `$ PSVersionTable.PSEdition -eq `" Desktop`" -or ([System.IO.Path]::GetFileName(`$ runner)) -eq `" powershell.exe`" ) {" ,
1738+ " `$ runnerParameter=`" -f`" " ,
1739+ " }" ,
1740+ " }" ,
1741+ " elseif (`"`$ fileFullName`" .ToLower().EndsWith(`" .sh`" )) {" ,
1742+ " `$ runner=`" bash`" " ,
1743+ " }" ,
1744+ " else {" ,
1745+ " `$ err=`" [Run-Remote-Script] Abort. Unable to infer runner for remote script '`$ url', file is '`$ fileFullName'`" " ,
1746+ " Write-Line -TextRed `"`$ err`" " ,
1747+ " throw `$ err;" ,
1748+ " }" ,
1749+ " }" ,
1750+ " Write-Line `" Invoking `" -TextCyan `"`$ runner`$ runnerParameter`" `" `" -TextGreen `"`$ url`" `" `" -TextGreen `"`$ passthrowArgs`" " ,
1751+ " # Write-Host `" RUNNER: [`$ runner]`" " ,
1752+ " # Write-Host `" URL: [`$ url]`" " ,
1753+ " # Write-Host `" Arguments (Count = `$ (`$ passthrowArgs.Length)): `$ passthrowArgs`" " ,
1754+ " # Write-Host `" Local File: `$ fileFullName`" " ,
1755+ " `$ okDownload = Download-File-Managed `"`$ url`" `"`$ fileFullName`" " ,
1756+ " # Write-Host `" okDownload: `$ okDownload`" " ,
1757+ " if (`$ okDownload) {" ,
1758+ " `$ allWorld = `$ runner.Split(`" `" ) + @(`$ runnerParameter) + @(`$ fileFullName) + `$ passthrowArgs;" ,
1759+ " `$ allWorld = @(`$ allWorld | ? { `"`$ _`" })" ,
1760+ " & `$ allWorld[0] @(`$ allWorld | Select-Object -Skip 1) | Out-Host" ,
1761+ " if (-not `$ ?) {" ,
1762+ " Write-Line -TextRed `" Run-Remote-Script FAIL: '`$ url'`" " ,
1763+ " }" ,
1764+ " }" ,
1765+ " }" ,
1766+ " " ,
16901767 " # Include File: [\Includes\Say.ps1]" ,
16911768 " function Say { # param( [string] `$ message )" ,
16921769 " if (`$ Global:_Say_Stopwatch -eq `$ null) { `$ Global:_Say_Stopwatch = [System.Diagnostics.Stopwatch]::StartNew(); }" ,
@@ -4168,6 +4245,7 @@ $ModuleFiles = @(
41684245 " Export-ModuleMember -Function Download-File-FailFree" ,
41694246 " Export-ModuleMember -Function Download-File-FailFree-and-Cached" ,
41704247 " Export-ModuleMember -Function Download-File-Managed" ,
4248+ " Export-ModuleMember -Function Run-Remote-Script" ,
41714249 " Export-ModuleMember -Function Query-Download-File-Size" ,
41724250 " Export-ModuleMember -Function Download-Fresh-SQLServer-and-Extract" ,
41734251 " Export-ModuleMember -Function Download-SQLServer-and-Extract" ,
0 commit comments