-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRfaSystrackTools.psm1
More file actions
223 lines (179 loc) · 8.16 KB
/
Copy pathRfaSystrackTools.psm1
File metadata and controls
223 lines (179 loc) · 8.16 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#v0.1.0.5
function Test-SysTrackInstalled {
<#
.SYNOPSIS
Check to see if SysTrack and its prerequisites are installed and up-to-date.
.DESCRIPTION
Check the local system to see if SysTrack and its prerequisites are installed and the versions meet known minimums for RFA.
.PARAMETER OutFile
Writes verbose output to file for later retrieval
.PARAMETER SystrackVersionUri
URL for the TXT files that contains the deployed version number. Default value populated by CW Automate replacements.
.EXAMPLE
$uri = "https://automate.rfa.com/LabTech/Transfer/@SystrackVersionUri@"
Test-SystrackInstalled -SystrackVersionUri $uri -OutFile 'c:\temp\systrack.log.txt'
.INPUTS
This function doesn't require input, but a log path can be specified if desired.
.OUTPUTS
Returns a simple [boolean] value where true means requirements have been met and false means some requirement failed.
.NOTES
A digital experience monitoring solution that reduces IT costs and improves end-user experience. https://www.lakesidesoftware.com
#>
[CmdletBinding()]
param(
# (Over)writes verbose output to file for later retrieval
[Parameter(Position=0)]
[ValidateScript({Test-Path (Split-Path $_ -Parent)})]
[string]
$OutFile,
# URL for the TXT files that contains the deployed version number. Default value populated by CW Automate replacements.
[Parameter(Mandatory=$true)]
[string]
$SystrackVersionUri
)
Begin {
# Define the default boolean value as true
# If any of 3 items presents a problem, change to false
$SysTrackInstalled = $true
# Initialize an Output Message for the verbose stream
[string[]]$Message = $null
# Make sure the URL doesn't have raw replacement string from Automate
if ($SystrackVersionUri -like '@') {
throw "Invalid URL: [$($SystrackVersionUri)]"
} else {
Write-Verbose "SystrackVersionUri: [$($SystrackVersionUri)]"
}
# Define the requirements for versions on the 2 prerequsite packages
# Define the URL to the version files
$web = New-Object Net.WebClient
$uriSysTrackParent = 'https://automate.rfa.com/LabTech/Transfer/Software/SysTrack Cloud Agent'
[version]$vcRedist64VersionShouldBe = $web.DownloadString(("$($uriSysTrackParent)/prereq64version.txt")).Trim()
[version]$vcRedist86VersionShouldBe = $web.DownloadString(("$($uriSysTrackParent)/prereq86version.txt")).Trim()
[version]$SysTrackVersionShouldBe = $web.DownloadString($SystrackVersionUri).Trim()
# Pull in info related to the 3 packages we need to check
$allSoftware = Get-InstalledSoftware
$vcRedist64Info = $allSoftware |
Where-Object {
($_.Name -like '*visual c++*redist*x64*' -or
$_.Name -like '*visual c++*x64*redist*') -and
$_.Name -notlike '*visual c++*x86*'
} |
Sort-Object @{expr={[version]($_.Version)};Descending=$true} |
Select-Object -First 1
$vcRedist86Info = $allSoftware |
Where-Object {
($_.Name -like '*visual c++*redist*x86*' -or
$_.Name -like '*visual c++*x86*redist*') -and
$_.Name -notlike '*visual c++*x64*'
} |
Sort-Object @{expr={[version]($_.Version)};Descending=$true} |
Select-Object -First 1
$SysTrackInfo = $allSoftware |
Where-Object {$_.Name -eq 'Systems Management Agent'}
# Ensure all 3 apps are installed and meet version requirements
if ( -not $vcRedist64Info) {
$Message += "FAIL: Microsoft Visual C++ Redistributable (x64) not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} elseif (($vcRedist64Info.Version -as [version]) -lt $vcRedist64VersionShouldBe) {
$Message += "FAIL: Microsoft Visual C++ Redistributable (x64) version $($vcRedist64VersionShouldBe) or higher not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} else {
$Message += "OK: Microsoft Visual C++ Redistributable (x64) version $($vcRedist64Info.Version) is installed on $($env:COMPUTERNAME)"
}
if ( -not $vcRedist86Info) {
$Message += "FAIL: Microsoft Visual C++ Redistributable (x86) not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} elseif (($vcRedist86Info.Version -as [version]) -lt $vcRedist86VersionShouldBe) {
$Message += "FAIL: Microsoft Visual C++ Redistributable (x86) version $($vcRedist86VersionShouldBe) or higher not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} else {
$Message += "OK: Microsoft Visual C++ Redistributable (x86) version $($vcRedist86Info.Version) is installed on $($env:COMPUTERNAME)"
}
if ( -not $SysTrackInfo) {
$Message += "FAIL: Systems Management Agent (SysTrack) not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} elseif (($SysTrackInfo.Version -as [version]) -lt $SysTrackVersionShouldBe) {
$Message += "FAIL: Systems Management Agent (SysTrack) version $($SysTrackVersionShouldBe) or higher not detected on $($env:COMPUTERNAME)"
$SysTrackInstalled = $false
} else {
$Message += "OK: Systems Management Agent (SysTrack) version $($SysTrackInfo.Version) is installed on $($env:COMPUTERNAME)"
}
}
Process {}
End {
Write-Output $SysTrackInstalled
$Message | ForEach-Object {
Write-Verbose -Message $_
}
if ($OutFile) {
$Parent = Split-Path $OutFile -Parent
if( -not (Test-Path $Parent)) {
[void](New-Item -ItemType Directory -Path $Parent -Force)
}
$Message | Out-File -FilePath $OutFile -Force | Out-Null
}
$web.Dispose()
}
}#END function Test-SysTrackInstalled
function Uninstall-Systrack {
<#
.NOTES
Quick uninstall, use at own risk.
#>
[CmdletBinding()]
param (
[switch]$KeepPrerequisiteRedist
)
begin {
# Load external functions
$URLs = @(
'https://raw.githubusercontent.com/tonypags/PsWinAdmin/master/Get-InstalledSoftware.ps1'
'https://raw.githubusercontent.com/tonypags/PsWinAdmin/master/Get-PendingReboot.ps1'
)
$web = New-Object Net.WebClient
Foreach ($URL in $URLs) {
Invoke-Expression ($web.DownloadString( $URL ))
sleep 1
}
$preRebootStatus = Get-PendingReboot
}
process {
}
end {
& msiexec.exe /qn /x "{5A10C299-1D99-4478-94F9-64C9DE93751D}" REBOOT=R
sleep 3
if (!($KeepPrerequisiteRedist)) {
& "C:\ProgramData\Package Cache\{282975d8-55fe-4991-bbbb-06a72581ce58}\VC_redist.x64.exe" /uninstall /quiet /norestart
sleep 2
& "C:\ProgramData\Package Cache\{e31cb1a4-76b5-46a5-a084-3fa419e82201}\VC_redist.x86.exe" /uninstall /quiet /norestart
sleep 3
}
gps LsiSupervisor -ea 0 | stop-process -force -ea 0
sleep 1
del -force -recurse "C:\Windows\LtSvc\packages\SysTrack Cloud Agent\" -ea 0
sleep 1
del -force -recurse "C:\Program Files (x86)\SysTrack\" -ea 0
sleep 2
del -force -recurse "HKLM:\SOFTWARE\WOW6432Node\Lakeside Software\" -ea 0
sleep 1
$postRebootStatus = Get-PendingReboot
'reboot status:'
$postRebootStatus
'changes in reboot status:'
Compare $preRebootStatus $postRebootStatus |
?{$_.sideindicator -eq '=>'} |
Select inputobject
sleep 1
Try{ & quser } Catch { ($_.Exception.Message) }
$web.Dispose()
}
}#END Uninstall-Systrack
# Load external functions
$URLs = @(
'https://raw.githubusercontent.com/tonypags/PsWinAdmin/master/Get-InstalledSoftware.ps1'
)
$web = New-Object Net.WebClient
Foreach ($URL in $URLs) {
Invoke-Expression ($web.DownloadString( $URL ))
}
$web.Dispose()