-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathScript.ps1
51 lines (46 loc) · 1.72 KB
/
Script.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# x64
$Object1 = Invoke-RestMethod -Uri 'https://update.googleapis.com/service/update2' -Method Post -Body @'
<?xml version="1.0" encoding="UTF-8"?>
<request protocol="3.0">
<os platform="win" version="10" arch="x64" />
<app appid="{8A69D345-D564-463C-AFF1-A69D9E530F96}" version="" ap="x64">
<updatecheck />
</app>
</request>
'@
$Version1 = $Object1.response.app.updatecheck.manifest.version
# x86
$Object2 = Invoke-RestMethod -Uri 'https://update.googleapis.com/service/update2' -Method Post -Body @'
<?xml version="1.0" encoding="UTF-8"?>
<request protocol="3.0">
<os platform="win" version="10" arch="x86" />
<app appid="{8A69D345-D564-463C-AFF1-A69D9E530F96}" version="" ap="x86">
<updatecheck />
</app>
</request>
'@
$Version2 = $Object2.response.app.updatecheck.manifest.version
if ($Version1 -ne $Version2) { throw 'Distinct versions detected' }
# Version
$this.CurrentState.Version = $Version1
# Installer
$this.CurrentState.Installer += [ordered]@{
Architecture = 'x86'
InstallerUrl = ($Object2.response.app.updatecheck.urls.url.codebase | Select-String -Pattern 'https://dl.google.com' -Raw -SimpleMatch) + $Object2.response.app.updatecheck.manifest.actions.action.Where({ $_.event -eq 'install' }, 'First')[0].run
}
$this.CurrentState.Installer += [ordered]@{
Architecture = 'x64'
InstallerUrl = ($Object1.response.app.updatecheck.urls.url.codebase | Select-String -Pattern 'https://dl.google.com' -Raw -SimpleMatch) + $Object1.response.app.updatecheck.manifest.actions.action.Where({ $_.event -eq 'install' }, 'First')[0].run
}
switch -Regex ($this.Check()) {
'New|Changed|Updated' {
$this.Write()
}
'Changed|Updated' {
$this.Print()
$this.Message()
}
'Updated' {
$this.Submit()
}
}