8
8
9
9
. DESCRIPTION
10
10
This is a set of commandlets to interface with the LabTech Agent.
11
- Tested Versions: v10.5, v11, v12, v2019
11
+ Tested Versions: v10.5- v12, v2019-v2024
12
12
13
13
. NOTES
14
- Version: 1.9.1
14
+ Version: 1.9.2
15
15
Author: Chris Taylor
16
16
Website: labtechconsulting.com
17
17
Creation Date: 3/14/2016
@@ -43,7 +43,7 @@ If (-not ($PSVersionTable)) {Write-Warning 'PS1 Detected. PowerShell Version 2.0
43
43
ElseIf ($PSVersionTable.PSVersion.Major -lt 3 ) {Write-Verbose ' PS2 Detected. PowerShell Version 3.0 or higher may be required for full functionality.' }
44
44
45
45
# Module Version
46
- $ModuleVersion = " 1.9.1 "
46
+ $ModuleVersion = " 1.9.2 "
47
47
$ModuleGuid = ' f1f06c84-00c8-11ea-b6e8-000c29aaa7df'
48
48
49
49
If ($env: PROCESSOR_ARCHITEW6432 -match ' 64' -and [IntPtr ]::Size -ne 8 -and $env: PROCESSOR_ARCHITEW6432 -ne ' ARM64' ) {
@@ -559,7 +559,7 @@ Function Uninstall-LTService{
559
559
This will uninstall the LabTech agent using the provided server URL to download the uninstallers.
560
560
561
561
. NOTES
562
- Version: 1.9
562
+ Version: 1.9.1
563
563
Author: Chris Taylor
564
564
Website: labtechconsulting.com
565
565
Creation Date: 3/14/2016
@@ -600,6 +600,9 @@ Function Uninstall-LTService{
600
600
Update Date: 6/22/2020
601
601
Purpose/Change: Use unique pathname for Uninstall MSI, add Uninstaller EXE fallback
602
602
603
+ Update Date: 7/25/2024
604
+ Purpose/Change: Uninstaller EXE fallback even if server is unavailable
605
+
603
606
. LINK
604
607
http://labtechconsulting.com
605
608
#>
@@ -687,23 +690,6 @@ Function Uninstall-LTService{
687
690
If (-not ($Server )){
688
691
$Server = Read-Host - Prompt ' Provide the URL to your LabTech server (https://lt.domain.com)'
689
692
}
690
- If (-not ($Server )){
691
- # Download $UninstallEXE
692
- $AlternateServer = $Null
693
- $uninstaller = ' https://s3.amazonaws.com/assets-cp/assets/Agent_Uninstall.exe'
694
- If ($PSCmdlet.ShouldProcess (" $uninstaller " , " DownloadFile" )) {
695
- Write-Debug " Line $ ( LINENUM) : Downloading $UninstallEXE from $uninstaller "
696
- $Script :LTServiceNetWebClient.DownloadFile ($uninstaller , " $UninstallBase \$UninstallEXE " )
697
- If ((Test-Path " $UninstallBase \$UninstallEXE " )) {
698
- If (((Get-Item " $UninstallBase \$UninstallEXE " - EA 0 ).length/ 1 KB -gt 80 )) {
699
- $AlternateServer = ' https://s3.amazonaws.com'
700
- } Else {
701
- Write-Warning " Line $ ( LINENUM) : $UninstallEXE size is below normal. Removing suspected corrupt file."
702
- Remove-Item " $UninstallBase \$UninstallEXE " - ErrorAction SilentlyContinue - Force - Confirm:$False
703
- }# End If
704
- }# End If
705
- }# End If
706
- }
707
693
$Server = ForEach ($Svr in $Server ) {If (($Svr )) {If ($Svr -notmatch ' https?://.+' ) {" https://$ ( $Svr ) " }; $Svr }}
708
694
ForEach ($Svr in $Server ) {
709
695
If (-not ($GoodServer )) {
@@ -733,8 +719,7 @@ Function Uninstall-LTService{
733
719
If ($installerResult.StatusCode -ne 200 ) {
734
720
Write-Warning " WARNING: Line $ ( LINENUM) : Unable to download $UninstallMSI from server $ ( $Svr ) ."
735
721
Continue
736
- }
737
- Else {
722
+ } Else {
738
723
If ($PSCmdlet.ShouldProcess (" $installer " , " DownloadFile" )) {
739
724
Write-Debug " Line $ ( LINENUM) : Downloading $UninstallMSI from $installer "
740
725
$Script :LTServiceNetWebClient.DownloadFile ($installer , " $UninstallBase \$UninstallMSI " )
@@ -743,8 +728,6 @@ Function Uninstall-LTService{
743
728
Write-Warning " WARNING: Line $ ( LINENUM) : $UninstallMSI size is below normal. Removing suspected corrupt file."
744
729
Remove-Item " $UninstallBase \$UninstallMSI " - ErrorAction SilentlyContinue - Force - Confirm:$False
745
730
Continue
746
- } Else {
747
- $AlternateServer = $Svr
748
731
}# End If
749
732
}# End If
750
733
}# End If
@@ -785,8 +768,8 @@ Function Uninstall-LTService{
785
768
If ($WhatIfPreference -eq $True ) {
786
769
$GoodServer = $Svr
787
770
} ElseIf ((Test-Path " $UninstallBase \$UninstallMSI " ) -and (Test-Path " $UninstallBase \$UninstallEXE " )) {
788
- $GoodServer = $Svr
789
771
Write-Verbose " Successfully downloaded files from $ ( $Svr ) ."
772
+ $GoodServer = $Svr
790
773
} Else {
791
774
Write-Warning " WARNING: Line $ ( LINENUM) : Error encountered downloading from $ ( $Svr ) . Uninstall file(s) could not be received."
792
775
Continue
@@ -807,7 +790,23 @@ Function Uninstall-LTService{
807
790
}# End Process
808
791
809
792
End {
810
- If ($GoodServer -match ' https?://.+' -or $AlternateServer -match ' https?://.+' ) {
793
+ If (-not ($GoodServer -match ' https?://.+' )) {
794
+ # Download $UninstallEXE
795
+ $uninstaller = ' https://s3.amazonaws.com/assets-cp/assets/Agent_Uninstall.exe'
796
+ If ($PSCmdlet.ShouldProcess (" $uninstaller " , " DownloadFile" )) {
797
+ Write-Debug " Line $ ( LINENUM) : Downloading $UninstallEXE from $uninstaller "
798
+ $Script :LTServiceNetWebClient.DownloadFile ($uninstaller , " $UninstallBase \$UninstallEXE " )
799
+ If ((Test-Path " $UninstallBase \$UninstallEXE " )) {
800
+ If (((Get-Item " $UninstallBase \$UninstallEXE " - EA 0 ).length/ 1 KB -gt 80 )) {
801
+ $GoodServer = ' https://s3.amazonaws.com'
802
+ } Else {
803
+ Write-Warning " Line $ ( LINENUM) : $UninstallEXE size is below normal. Removing suspected corrupt file."
804
+ Remove-Item " $UninstallBase \$UninstallEXE " - ErrorAction SilentlyContinue - Force - Confirm:$False
805
+ }# End If
806
+ }# End If
807
+ }# End If
808
+ }
809
+ If ($GoodServer -match ' https?://.+' ) {
811
810
Try {
812
811
Write-Output " Starting Uninstall."
813
812
@@ -1309,7 +1308,7 @@ Function Install-LTService{
1309
1308
" /i `" $InstallBase \Installer\$InstallMSI `" "
1310
1309
" SERVERADDRESS=$GoodServer "
1311
1310
If (($PSCmdlet.ParameterSetName -eq ' installertoken' ) -and [System.Version ]$SVer -ge [System.Version ]' 240.331' ) {" TRANSFORMS=`" Agent_Install.mst`" " }
1312
- If ($ServerPassword -and $ServerPassword -match ' .' ) {" SERVERPASS="" $ ( $ServerPassword ) " "" }
1311
+ If ($ServerPassword -and $ServerPassword -match ' .' ) {" SERVERPASS=`" $ ( $ServerPassword ) ` "" }
1313
1312
If ($LocationID -and $LocationID -match ' ^\d+$' ) {" LOCATION=$LocationID " }
1314
1313
If ($TrayPort -and $TrayPort -ne 42000 ) {" SERVICEPORT=$TrayPort " }
1315
1314
" /qn"
0 commit comments