SilentInstall.psm1
Import-Module -Name powershell-yaml function Get-SilentTools{ $SilentInstall_TOOLS = if ($env:ChocolateyToolsLocation) {$env:ChocolateyToolsLocation} else {"$env:HOMEDRIVE/tools/"} if (!(Test-Path -Path $SilentInstall_TOOLS)) { New-Item -Path $SilentInstall_TOOLS -ItemType Directory} return $SilentInstall_TOOLS } function Import-SilentFile{ param( [string] $url ) # TODO: remove bad file system chars $name = Split-Path $url -leaf; $pseudoUnique = $url.GetHashCode(); $into = "$env:temp/$($pseudoUnique)_${name}"; Invoke-WebRequest -Uri $url -OutFile $into; return $into; } function Install-SilentFileMsi{ param( [string] $url ) msiexec /i $url /quiet /lv $env:TEMP/SilenInstall.log; } # expands any archives # works over ssh and fallbacks to tar if neeeded function Expand-ArchiveRobust { param ( [string] $from, [string] $to ) try { Expand-Archive -Path $from -DestinationPath $to -Force } catch { Write-Output "https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/77" Write-Output "https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/79" tar -xkf $from -C $to } } Export-ModuleMember -Function Get-SilentTools, Expand-ArchiveRobust, Import-SilentFile |