Skip to content

Instantly share code, notes, and snippets.

@NEExploiT NEExploiT/updater.ps1 Secret
Last active Dec 6, 2018

Embed
What would you like to do?
SpoilerAL patch updater
if ($PSVersionTable.PSVersion.Major -lt 5) {
Write-Output PowerShell 5.0未満では動きません
Write-Output http://aka.ms/wmf5download
Write-Output よりPowerShell 5をダウンロードしてください
Start-Process http://aka.ms/wmf5download
exit
}
if (Test-Path SpoilerAL -PathType Any) {
Write-Output SpoilerALフォルダ/ファイルがあるとうまく動かないので中断します
exit
}
if (Test-Path SpoilerAL.exe -PathType Leaf) {
$api_base = "https://dev.azure.com/SpoilerAL/b1994a7a-8882-40d3-bb41-8f34be1b434e/_apis/build/builds/"
$builds = Invoke-RestMethod ($api_base+"?definitionId=12")
$latest = $builds.value | Where-Object{ $_.result -eq "succeeded" } | Select-Object -First 1
if ($latest) {
$commit = $latest.sourceVersion
$buildnumber = $latest.buildNumber
$branch = $latest.sourceBranch.Split("/")[-1]
$archive_name = "./Patch$($buildnumber)-$($branch)[$($commit.SubString(0,7))].zip"
if (!(Test-Path -LiteralPath $archive_name)) {
$artifact = Invoke-RestMethod ($api_base + $latest.id + "/artifacts")
Invoke-WebRequest -Uri $artifact.value.resource.downloadUrl -OutFile $commit
Move-Item $commit $archive_name
}
Expand-Archive -LiteralPath $archive_name -DestinationPath .
Move-Item SpoilerAL/winmm.dll . -Force
Get-Item winmm.dll |
ForEach-Object {Set-ItemProperty $_ -Name LastWriteTime -Value (($_.LastWriteTime)+([TimeZoneInfo]::Local.BaseUtcOffset))}
Remove-Item ./SpoilerAL -Recurse
Write-Output アップデート成功しました
} else {
Write-Output 成功したビルドが見つかりません
}
}else{
Write-Output SpoilerAL.exeがあるフォルダで実行してください
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.