88
99. DESCRIPTION
1010 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
1212
1313. NOTES
14- Version: 1.9.1
14+ Version: 1.9.2
1515 Author: Chris Taylor
1616 Website: labtechconsulting.com
1717 Creation Date: 3/14/2016
@@ -43,7 +43,7 @@ If (-not ($PSVersionTable)) {Write-Warning 'PS1 Detected. PowerShell Version 2.0
4343ElseIf ($PSVersionTable.PSVersion.Major -lt 3 ) {Write-Verbose ' PS2 Detected. PowerShell Version 3.0 or higher may be required for full functionality.' }
4444
4545# Module Version
46- $ModuleVersion = " 1.9.1 "
46+ $ModuleVersion = " 1.9.2 "
4747$ModuleGuid = ' f1f06c84-00c8-11ea-b6e8-000c29aaa7df'
4848
4949If ($env: PROCESSOR_ARCHITEW6432 -match ' 64' -and [IntPtr ]::Size -ne 8 -and $env: PROCESSOR_ARCHITEW6432 -ne ' ARM64' ) {
@@ -559,7 +559,7 @@ Function Uninstall-LTService{
559559 This will uninstall the LabTech agent using the provided server URL to download the uninstallers.
560560
561561. NOTES
562- Version: 1.9
562+ Version: 1.9.1
563563 Author: Chris Taylor
564564 Website: labtechconsulting.com
565565 Creation Date: 3/14/2016
@@ -600,6 +600,9 @@ Function Uninstall-LTService{
600600 Update Date: 6/22/2020
601601 Purpose/Change: Use unique pathname for Uninstall MSI, add Uninstaller EXE fallback
602602
603+ Update Date: 7/25/2024
604+ Purpose/Change: Uninstaller EXE fallback even if server is unavailable
605+
603606. LINK
604607 http://labtechconsulting.com
605608#>
@@ -687,23 +690,6 @@ Function Uninstall-LTService{
687690 If (-not ($Server )){
688691 $Server = Read-Host - Prompt ' Provide the URL to your LabTech server (https://lt.domain.com)'
689692 }
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- }
707693 $Server = ForEach ($Svr in $Server ) {If (($Svr )) {If ($Svr -notmatch ' https?://.+' ) {" https://$ ( $Svr ) " }; $Svr }}
708694 ForEach ($Svr in $Server ) {
709695 If (-not ($GoodServer )) {
@@ -733,8 +719,7 @@ Function Uninstall-LTService{
733719 If ($installerResult.StatusCode -ne 200 ) {
734720 Write-Warning " WARNING: Line $ ( LINENUM) : Unable to download $UninstallMSI from server $ ( $Svr ) ."
735721 Continue
736- }
737- Else {
722+ } Else {
738723 If ($PSCmdlet.ShouldProcess (" $installer " , " DownloadFile" )) {
739724 Write-Debug " Line $ ( LINENUM) : Downloading $UninstallMSI from $installer "
740725 $Script :LTServiceNetWebClient.DownloadFile ($installer , " $UninstallBase \$UninstallMSI " )
@@ -743,8 +728,6 @@ Function Uninstall-LTService{
743728 Write-Warning " WARNING: Line $ ( LINENUM) : $UninstallMSI size is below normal. Removing suspected corrupt file."
744729 Remove-Item " $UninstallBase \$UninstallMSI " - ErrorAction SilentlyContinue - Force - Confirm:$False
745730 Continue
746- } Else {
747- $AlternateServer = $Svr
748731 }# End If
749732 }# End If
750733 }# End If
@@ -785,8 +768,8 @@ Function Uninstall-LTService{
785768 If ($WhatIfPreference -eq $True ) {
786769 $GoodServer = $Svr
787770 } ElseIf ((Test-Path " $UninstallBase \$UninstallMSI " ) -and (Test-Path " $UninstallBase \$UninstallEXE " )) {
788- $GoodServer = $Svr
789771 Write-Verbose " Successfully downloaded files from $ ( $Svr ) ."
772+ $GoodServer = $Svr
790773 } Else {
791774 Write-Warning " WARNING: Line $ ( LINENUM) : Error encountered downloading from $ ( $Svr ) . Uninstall file(s) could not be received."
792775 Continue
@@ -807,7 +790,23 @@ Function Uninstall-LTService{
807790 }# End Process
808791
809792 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?://.+' ) {
811810 Try {
812811 Write-Output " Starting Uninstall."
813812
@@ -1309,7 +1308,7 @@ Function Install-LTService{
13091308 " /i `" $InstallBase \Installer\$InstallMSI `" "
13101309 " SERVERADDRESS=$GoodServer "
13111310 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 ) ` "" }
13131312 If ($LocationID -and $LocationID -match ' ^\d+$' ) {" LOCATION=$LocationID " }
13141313 If ($TrayPort -and $TrayPort -ne 42000 ) {" SERVICEPORT=$TrayPort " }
13151314 " /qn"
0 commit comments