-
Notifications
You must be signed in to change notification settings - Fork 20
/
Install.ps1
34 lines (34 loc) · 1.4 KB
/
Install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$Uri = "https://api.github.com/repos/aaronparker/image-customise/releases/latest"
$Filter = "\.zip$"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$params = @{
ContentType = "application/vnd.github.v3+json"
ErrorAction = "SilentlyContinue"
MaximumRedirection = 0
DisableKeepAlive = $true
UseBasicParsing = $true
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
Uri = $Uri
}
$release = Invoke-RestMethod @params
if ($null -ne $release) {
foreach ($item in $release) {
foreach ($asset in $item.assets) {
if ($asset.browser_download_url -match $Filter) {
$Uri = $asset.browser_download_url
}
}
}
$TmpDir = $([System.IO.Path]::Combine($Env:Temp, $(New-Guid)))
New-Item -Path $TmpDir -ItemType "Directory" | Out-Null
$OutFile = $([System.IO.Path]::Combine($TmpDir, $(Split-Path -Path $Uri -Leaf)))
Invoke-WebRequest -Uri $Uri -OutFile $OutFile -UseBasicParsing
if (Test-Path -Path $OutFile -ErrorAction "SilentlyContinue") {
Push-Location -Path $TmpDir
Expand-Archive -Path $OutFile -DestinationPath $TmpDir -Force
Get-ChildItem -Path $TmpDir -Recurse | Unblock-File
& .\Install-Defaults.ps1
Pop-Location
Remove-Item -Path $TmpDir -Recurse -Force -ErrorAction "SilentlyContinue"
}
}