Git Product home page Git Product logo

labtech-powershell-module's People

Contributors

apex-dwhite avatar christaylorcodes avatar christaylorrocks avatar darrenwhite99 avatar dkattan avatar drdrrae avatar labtechconsulting avatar phmcgann avatar sandersjds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

labtech-powershell-module's Issues

.NET 3.5 Install Check Error Handling

In the Install-LTService function, you do a check to see if .NET 3.5 is installed and attempt to install it. In the error handling for that .NET 3.5 installation, you do the following. (Currently lines 491-495)

Else{
Write-Output "ERROR: .NET 3.5 install failed."
Write-Output $Result
Exit
}

The problem is, if I'm manually running the Install-LTService function and not using a script, having it output the error code and then immediately exit will flash too fast to understand what's happening before it closes the window. I think having a pause or a break would be more effective.

I think I read that "exit" behaves differently on different versions of PowerShell. I don't recall exactly what OS or PoSh version I found this bug on, sorry.

server address fails with piped address list

For those with piped server address lists in the registry from the labtech template the reinstall and possibly other functions will fail as they can't use the pipe delimited string. something like this should work but I couldn't get it working

line 542 [string]$Server = (Get-LTServiceInfo).'Server Address' -split "|",0,"SimpleMatch" | select -First 1 ,

That split code works when using the get-ltserviceinfo cmdlet directly, just not from the reinstall cmdlet

Hide/Show-LTAddRemove

There are new keys with 11

HKEY_CLASSES_ROOT\Installer\Products\D1003A85576B76D45A1AF09A0FC87FAC
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\D1003A85576B76D45A1AF09A0FC87FAC
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\D1003A85576B76D45A1AF09A0FC87FAC\InstallProperties
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{58A3001D-B675-4D67-A5A1-0FA9F08CF7CA}

Server Password WIth Special Chars

If the server password contains special characters (such as a '/') it can break passing those passwords to the executable/MSI.

A fix for this is to add single quotes around the PasswordArg on line 1215 so it looks like this:

$PasswordArg = "SERVERPASS=`'$ServerPassword`'"

Can we get this put in, so the server password can have special characters in it?

PowerShell 7 (x64) error

If ($Null -eq ([System.Management.Automation.PSTypeName]'TrustAllCertsPolicy').Type) {
Add-Type -Debug:$False @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
}

It appears that PSVersion 7.1.1 isn't able to load or find the type/namespace for ICertificatePolicy. PSVersion 5.1.1 operates as it's been just fine. The error outputs are as follows.

PS C:\Users\(new-object Net.WebClient).DownloadString('https://bit.ly/LTPoSh') | iex;
Add-Type:
Line |
  91 |      Add-Type -Debug:$False @"
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~
     | (3,44): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a using directive or an assembly reference?)
        public class TrustAllCertsPolicy : ICertificatePolicy {
                                           ^

Add-Type:
Line |
  91 |      Add-Type -Debug:$False @"
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot add type. Compilation errors occurred.
New-Object:
Line |
 103 |  … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
     |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded.

Date conversion not working outside of US Date Formats - Breaks Command

$object | Add-Member -MemberType NoteProperty -Name Timestamp -Value $([datetime]$items[1])

The date conversion here results in an error on none US systems, IE in the UK where the date format is dd/mm/yyyy:

Get-LTError : ERROR: There was an error reading the log. Cannot convert value "15/11/2018 08:30:59" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."

Feature Request: Support For Proxy

For the "To Do" bucket. The module needs a way to work when a proxy configuration is required. Although the user would have trouble getting LT-POSH to download in the first place if there was a proxy. But assuming that the module was pre-downloaded. Perhaps a function could be included to set the proxy policy for the current powershell session (needed to pull the MSI, etc.)

But also, if the module was used to install an agent the proxy settings will need to be passed to the Automate Agent configuration (since it won't have learned the location specific information from the MSI). That would mean injecting the Proxy, ProxyUser, and ProxyPass registry values AFTER the installer completes but before Agent registration would be able to succeed.

To start, I found this code that may allow a proxy configuration to be set for the powershell session. Setting the registry values would still need to be worked out.

function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword)
{
     #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
     $proxyUrl = $proxyHost+":"+$proxyPort;
     Write-Host "proxy url [$proxyUrl]";
     $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
     $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
     $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
     return $proxy;
}

$wc=new-object net.webclient;
$wc.UseDefaultCredentials = $true
$wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
$wc.DownloadString('https://SERVERNAME/SOMETHING.ps1');

Reset-LTService removes the location ID by mistake

The issue:
The command Reset-LTService -ID -Mac is not supposed to remove the location ID. But it does.

To reproduce:

C:\Windows\LTSvc>"%windir%\System32\WindowsPowerShell\v1.0\powershell.exe" -noprofile -command "& {(new-object Net.WebCl
ient).DownloadString('http://bit.ly/ltposh') | iex; Reset-LTService -ID -Mac}"
OLD ID: 5374 LocationID: 291 MAC: 00059A3C7A00
Waiting for Services to Stop.........
Services Stopped successfully.
.Removing ID
.Removing LocationID    <-- NOOOO!!!!!!!!!!
.Removing MAC
Waiting for Services to Start..
Services Started successfully.
...

The fix: Line 1922
If (!($ID -and $LocationID -and $MAC)){
should be
If (!($ID -and $Location -and $MAC)){

:)

If LT Server Discovered by Script No Longer Exists, Fallback to Amazon AWS uninstaller fails

Hi there,
We recently powered off our LT server, and now the script is failing. As far as I can tell, there's logic to fallback to Amazon AWS, but it doesn't work. Either that or it just compares the download sizes.

Is it supposed to fall back to AWS?

Because of the way the script works, I can't just point it to an uninstaller file - it wants to traverse the directory on it's own, instead of letting me put in a full path to a uninstall.exe - I tried putting one on MS devops, but it won't work, because it hardcodes the location of the file from the domain it grabs or that is specified.

Installation fails when server password contains double quote

You probably should build up the Arguments using a string array and pass them to Start-Process so it can properly escape them.

$Arguments = @()
$Arguments += "/i"
$Arguments += $InstallerFilePath
$Arguments += "/qn"
if($ServerPassword)
{
   $Arguments += $ServerPassword
}

Start-Process -Wait msiexec -ArgumentList $Arguments

$(If ($ServerPassword -and $ServerPassword -match '.') {"SERVERPASS=""$ServerPassword"""} Else {""}),

64-bit OS Detection causing script to fail on ARM processors (Surface Pro X)

When you try to run the "(new-object Net.WebClient).DownloadString('https://bit.ly/LTPoSh') | iex;" command on a Surface Pro X (64-bit custom ARM CPU), it tries to switch to 64-bit PowerShell and creates an endless loop of spawned Powershell.exe processes.

Output looks like:

PS C:\windows\system32> (new-object Net.WebClient).DownloadString('https://bit.ly/LTPoSh') | iex;
WARNING: 32-bit PowerShell session detected on 64-bit OS. Attempting to launch 64-Bit session to process commands.
WARNING: 32-bit PowerShell session detected on 64-bit OS. Attempting to launch 64-Bit session to process commands.
WARNING: 32-bit PowerShell session detected on 64-bit OS. Attempting to launch 64-Bit session to process commands.
WARNING: 32-bit PowerShell session detected on 64-bit OS. Attempting to launch 64-Bit session to process commands.

https://oofhours.com/2020/02/04/powershell-on-windows-10-arm64/ this site indicates that 64-bit tests should exclude the ARM processor architecture to avoid these issues.

Agent_Uninstall.exe doesn't exit on Windows 7 when PSRemoting

I started out writing a small script to reinstall agents using PSRemote. I ran into an issue where Agent_Uninstall.exe hangs on some (maybe most) Windows 7 machines, but not all. I've been working with this on and off for a few weeks. Script is fairly basic, but during my researching I came across this module. The module is great, but I noticed the same issue is present. If I kill Agent_Uninstall.exe the clean up portion of the Uninstall-LTService function does a good job of forcefully removing the software though.

After more tinkering on one of the affected Windows 7 machines I upgraded WMF 2.0 to WMF 5.1 and that resolved the issue of Agent_Uninstall.exe hanging. This isn't really an issue with the module, but something you may want to consider working around in a future update. I'm sure I'm not the first person to consider using this module to install / reinstall agents using PSRemote.

Could not create SSL/TLS secure channel

Reinstall module from this is not allowing me to reinstall the LT agent

Error:
Could not create SSL/TLS secure channel

Function that I ran:
(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -Server xxxxxxxx == -LocationID xxxxx

ReInstall-LTService function fails to install

ReInstall-LTservice command completes the Uninstall, then starts the Install, but it calls a different URL than the Install-LTService command - it looks to be the old deprecated probe URL and thus fails to download the installer.

DEBUG: Starting Reinstall-ltservice at line 1593
DEBUG: Starting Get-LTServiceInfo at line 212
DEBUG: Exiting Get-LTServiceInfo at line 255
Reinstalling LabTech with the following information, -Server https://{sanitized},https://{sanitized} -LocationID 1

DEBUG: Starting Uninstall-LTService at line 684
DEBUG: Line 780: Testing Server Response and Version: https://{sanitized}/LabTech/Agent.aspx
DEBUG: Line 783: Raw Response: ||||||200.278
DEBUG: Line 805: Downloading RemoteAgent.msi from https://{sanitized}/LabTech/Service/LabTechRemoteAgent.msi
DEBUG: Line 842: Downloading Agent_Uninstall.exe from https://{sanitized}/LabTech/Service/LabUninstall.exe
DEBUG: Line 869: Server https://{sanitized} has been selected.
Starting Uninstall.
DEBUG: Starting Stop-LTService at line 409
DEBUG: Line 3093: Sending service command 'Kill VNC' (141) to 'LTService'
DEBUG: Line 3093: Sending service command 'Kill Trays' (142) to 'LTService'
Waiting for Services to Stop.....
Services Stopped successfully.
DEBUG: Exiting Stop-LTService at line 463
DEBUG: Line 888: Terminating Process LTSVC
DEBUG: Line 896: Executing Command "regsvr32.exe /u C:\Windows\LTsvc\wodVPN.dll /s"
DEBUG: Line 906: Executing Command "msiexec.exe /x "C:\Windows\Temp\RemoteAgent.msi" /qn"
DEBUG: Line 918: Executing Command "C:\Windows\Temp\Agent_Uninstall.exe"
DEBUG: Line 957: Found Registry Key: Registry::HKEY_CURRENT_USER\SOFTWARE\LabTech\Service
DEBUG: Line 957: Found Registry Key: Registry::HKEY_CURRENT_USER\SOFTWARE\LabTech\LabVNC
LabTech has been successfully uninstalled.
DEBUG: Exiting Uninstall-LTService at line 996
DEBUG: Starting Install-LTService at line 1142
DEBUG: Line 1250: Testing Server Response and Version: https://{sanitized}/LabTech/Agent.aspx
DEBUG: Line 1252: Raw Response: ||||||200.278
DEBUG: Line 1288: Downloading Agent_Install.msi from https://{sanitized}/LabTech/Deployment.aspx?Probe=1&installType=msi&MSILocations=1
WARNING: WARNING: Line 1308: Error encountered downloading from https://{sanitized}.
DEBUG: Line 1250: Testing Server Response and Version: https://{sanitized}/LabTech/Agent.aspx
DEBUG: Line 1252: Raw Response: ||||||200.278
DEBUG: Line 1288: Downloading Agent_Install.msi from https://{sanitized}/LabTech/Deployment.aspx?Probe=1&installType=msi&MSILocations=1
WARNING: WARNING: Line 1308: Error encountered downloading from https://{sanitized}.
Install-LTService : ERROR: Line 1474: No valid server was reached to use for the install.
DEBUG: Exiting Install-LTService at line 1476
DEBUG: Exiting Reinstall-ltservice at line 1697

Install-LTService output:

Install-LTService -server https://{sanitized} -Password '{sanitized}' -SkipDotNet
DEBUG: Starting Install-LTService at line 1142
DEBUG: Line 1250: Testing Server Response and Version: https://{sanitized}/LabTech/Agent.aspx
DEBUG: Line 1252: Raw Response: ||||||200.278
DEBUG: Line 1288: Downloading Agent_Install.msi from https://{sanitized}/LabTech/Service/LabTechRemoteAgent.msi
DEBUG: Starting Test-LTPorts at line 2487
DEBUG: Exiting Test-LTPorts at line 2566
Starting Install.
Waiting for agent to register..........
DEBUG: Starting Get-LTProxy at line 3652
DEBUG: Line 3143: Decoding Server Password.
DEBUG: Line 3226: Attempting Decode for '{sanitized}' with Key 'Thank you for using LabTech.'
DEBUG: Line 3146: Decoding Agent Password.
DEBUG: Line 3226: Attempting Decode for '{sanitized}' with Key '{sanitized}'
DEBUG: Line 3226: Attempting Decode for '{sanitized}' with Key 'Thank you for using LabTech.'
DEBUG: Line 3226: Attempting Decode for '{sanitized}' with Key ''
DEBUG: Line 3266: Failed to Decode string: '{sanitized}'
DEBUG: Line 3266: Failed to Decode string: '{sanitized}'
DEBUG: Line 3266: Failed to Decode string: '{sanitized}'
DEBUG: Line 3668: Setting ProxyServerURL to
DEBUG: Line 3676: Setting ProxyUsername to
DEBUG: Line 3683: Setting ProxyPassword to
DEBUG: Exiting Get-LTProxy at line 3697
LabTech has been installed successfully. Agent ID: 3299 LocationID: 1
DEBUG: Exiting Install-LTService at line 1476

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.