-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Get-MicrosoftOneDrive.ps1
91 lines (83 loc) · 4.38 KB
/
Get-MicrosoftOneDrive.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function Get-MicrosoftOneDrive {
<#
.SYNOPSIS
Returns the current version and download URL for the Microsoft OneDrive sync client for Windows.
.NOTES
Site: https://stealthpuppy.com
Author: Aaron Parker
Twitter: @stealthpuppy
#>
[OutputType([System.Management.Automation.PSObject])]
[CmdletBinding(SupportsShouldProcess = $false)]
param (
[Parameter(Mandatory = $false, Position = 0)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSObject]
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
)
# Step through each release URI
foreach ($ring in $res.Get.Update.Uri.GetEnumerator()) {
$params = @{
Uri = $res.Get.Update.Uri[$ring.Key]
ContentType = $res.Get.Update.ContentType
Raw = $true
ErrorAction = "Stop"
}
[System.XML.XMLDocument] $xmlDocument = Invoke-EvergreenWebRequest @params
# Build an output object by selecting installer entries from the feed
if ($xmlDocument -is [System.XML.XMLDocument]) {
# Select the required node/s from the XML feed
$nodes = Select-Xml -Xml $xmlDocument -XPath $res.Get.Update.XmlNode | Select-Object -ExpandProperty "node"
# Find the latest version
foreach ($node in $nodes) {
if ([System.Boolean]($node.PSobject.Properties.name -match "amd64binary")) {
[PSCustomObject] @{
Version = $node.currentversion
Ring = $ring.Name
Throttle = $node.throttle
Sha256 = ConvertFrom-Base64String -Base64String $node.amd64binary.sha256hash
Architecture = Get-Architecture -String $node.amd64binary.url
Type = Get-FileType -File $node.amd64binary.url
URI = $node.amd64binary.url
} | Write-Output
}
if ([System.Boolean]($node.PSobject.Properties.name -match "arm64binary")) {
[PSCustomObject] @{
Version = $node.currentversion
Ring = $ring.Name
Throttle = $node.throttle
Sha256 = ConvertFrom-Base64String -Base64String $node.arm64binary.sha256hash
Architecture = Get-Architecture -String $node.arm64binary.url
Type = Get-FileType -File $node.arm64binary.url
URI = $node.arm64binary.url
} | Write-Output
}
if ([System.Boolean]($node.PSobject.Properties.name -match "msixbinary")) {
# Construct the output for MSIX; Return the custom object to the pipeline
[PSCustomObject] @{
Version = $node.currentversion
Ring = $ring.Name
Throttle = $node.throttle
Sha256 = if ($node.msixbinary.sha256hash) { ConvertFrom-Base64String -Base64String $node.msixbinary.sha256hash } else { "N/A" }
Architecture = Get-Architecture -String $node.msixbinary.url
Type = Get-FileType -File $node.msixbinary.url
URI = $node.msixbinary.url
} | Write-Output
}
# Construct the output for EXE; Return the custom object to the pipeline
if ([System.Boolean]($node.PSobject.Properties.name -match "binary")) {
$PSObject = [PSCustomObject] @{
Version = $node.currentversion
Ring = $ring.Name
Throttle = $node.throttle
Sha256 = ConvertFrom-Base64String -Base64String $node.binary.sha256hash
Architecture = Get-Architecture -String $node.binary.url
Type = Get-FileType -File $node.binary.url
URI = $node.binary.url
}
Write-Output -InputObject $PSObject
}
}
}
}
}