-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-OnlineVerAtlassianCompanion_BROKEN.ps1
More file actions
140 lines (113 loc) · 5.57 KB
/
Get-OnlineVerAtlassianCompanion_BROKEN.ps1
File metadata and controls
140 lines (113 loc) · 5.57 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<#
===========================================================================
Created with: PowerShell ISE - Win10 21H1/19043
Revision: v1
Last Modified: 31 Mar 2022
Created by: Jay Harper (github.com/thecatdidit/powershellusefulscripts)
Organizaiton: Happy Days Are Here Again
Filename: Get-OnlineVerAtlassianCompanion.ps1
===========================================================================
.CHANGELOG
(03.31.22) Initial script creation
.SYNOPSIS
Queries the Atlassian webside for the current version of
Companion and returns the version, date updated, and
download URLs if available.
.DESCRIPTION
This function retrieves the latest data associated with Atlassian Companion
Invoke-WebRequest queries the site to obtain app release date, version and
download URLs. This includes both the standard EXE installer and the MSI
instance
It then outputs the information as a
PSObject to the Host
App Site: https://confluence.atlassian.com/doc/atlassian-companion-app-release-notes-958455712.html
.EXAMPLE
PS C:\> Get-OnlineVerAtlassianCompanion.ps1
Software_Name : Atlassian Companion
Software_URL : https://confluence.atlassian.com
Online_Version : 1.3.1
Online_Date : 12 November 2021
EXE_Installer : https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.exe
MSI_Installer : https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.msi
PS C:\> Get-OnlineVerAtlassianCompanion -Quiet
1.3.1
.INPUTS
-Quiet
Use of this parameter will output just the current version of
Atlassian Companion instead of the entire object. It will always be the
last parameter
.OUTPUTS
An object containing the following:
Software Name: Name of the software
Software URL: The URL info was sourced from
Online Version: The current version found
Online Date: The date the version was updated
EXE Installer: Direct download link for the EXE-based installer
MSI Installer: Direct download link for the MSI-based installed
If -Quiet is specified then just the value of 'Online Version'
will be displayed.
.NOTES
Resources/Credits:
https://github.com/itsontheb
#>
function Get-OnlineVerAtlassianCompanion {
[cmdletbinding()]
param (
[Parameter(Mandatory = $false,
Position = 0)]
[switch]
$Quiet
)
begin {
# Initial Variables
$SoftwareName = 'Atlassian Companion'
$URI = 'https://confluence.atlassian.com'
$hashtable = [ordered]@{
'Software_Name' = $softwareName
'Software_URL' = $uri
'Online_Version' = 'UNKNOWN'
'Online_Date' = 'UNKNOWN'
'EXE_Installer' = 'https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.exe'
'MSI_Installer' = 'https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.msi'
}
$swObject = New-Object -TypeName PSObject -Property $hashtable
}
Process {
# Get the Version & Release Date
try {
Write-Verbose -Message "Attempting to pull info from the below URL: `n $URI"
$URI = 'https://confluence.atlassian.com/doc/atlassian-companion-app-release-notes-958455712.html'
$ACURL = (Invoke-WebRequest -Uri $URI -UseBasicParsing | Select-Object -ExpandProperty Content)
$query = "Latest versions</h2><h3 id=""AtlassianCompanionappreleasenotes-AtlassianCompanion1.3.1"">Atlassian Companion (?<version>.*)</h3><p>Released (?<date>.*)</p><p>"
$ACURL -match $query
$ACVersion = ($matches['version'])
$ACDate = ($matches['date'])
$swObject.Online_Version = $ACVersion
$swObject.Online_Date = $ACDate
}
catch {
Write-Verbose -Message "Error accessing the below URL: `n $URI"
$message = $("Line {0} : {1}" -f $_.InvocationInfo.ScriptLineNumber, $_.exception.message)
$swObject | Add-Member -MemberType NoteProperty -Name 'ERROR' -Value $message
}
finally {
# Get the Download URLs
if ($swObject.Online_Version -ne 'UNKNOWN') {
$MMDownloadEXE = "https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.exe"
$MMDownloadMSI = "https://update-nucleus.atlassian.com/Atlassian-Companion/291cb34fe2296e5fb82b83a04704c9b4/latest/win32/ia32/Atlassian%20Companion.msi"
$swObject.EXE_Installer = $MMDownloadEXE
$swObject.MSI_Installer = $MMDownloadMSI
}
}
}
End {
# Output to Host
if ($Quiet) {
Write-Verbose -Message '$Quiet was specified. Returning just the version'
Return $swObject.Online_Version
}
else {
Return $swobject
}
}
} # END Function Get-OnlineVerAtlassianCompanion