doughardy 0 Posted January 4, 2018 Hope someone can shed some light. I'm taking on board a few clients from another MSP that uses labtech. The other MSP isn't doing any offboarding or removing the labtech agent. So i've created a script that I run from on machine after installing the agent manually and turn on the network probe. The command just hangs on the script and times out. I can login to the machine running the probe and run the same command and it works everytime. Would love to get the script running as there are quite a few machines coming on that I don't really want to do manually. the main line of the script that fails is %ltsvcdir%\psexec.exe -h \\@pcName@ c:\windows\temp\Agent_Uninstall.exe The agent_uninstall.exe is copied in a previous line on script ok. The process starts but nothing else happens. I've tried running with system option (-s) the script line runs as admin so it has access to the machine. Any help or other methods appreciated. Doug Share this post Link to post Share on other sites
DarrenWhite99 313 Posted January 4, 2018 Just attempting to install the agent on top of an existing one won't work. But to Quote SlackBot: slackbot Custom Response [06:26] "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService " REM To rip and replace to a new server, add this: -Server https://yourserver.com -LocationID XXX REM Full Docs at http://labtechconsulting.com/labtech-agent-powershell-module/ That module will handle the heavy lifting of cleaning the old agent off, then downloading and running the installer. You will still need to use a tool like psexec to push that command out, or a computer startup script pushed via GPO that tests for the agent and runs that command if the agent isn't installed. (You don't want to reinstall after every reboot..) Share this post Link to post Share on other sites
doughardy 0 Posted January 5, 2018 This is the agent_uninstall.exe not the install The command works fine except when run manually on the network probe machine running in cmd. when you call the same command from a script via the probe machine the psexec service starts on the remote machine but the agent_uninstall never completes. i Share this post Link to post Share on other sites
DarrenWhite99 313 Posted January 5, 2018 2 hours ago, doughardy said: This is the agent_uninstall.exe not the install Sorry, I thought you said you were replacing another installation.. The LTPosh module has cmdlets/functions you could use such as Remove-LTService and Install-LTService, but I was specifically mentioning the ReInstall-LTService function which will REMOVE AND INSTALL in just one step. Share this post Link to post Share on other sites
HSVDG 0 Posted January 8, 2018 This is a timely thread for me to find. The MSP I work for just took on a client and their previous MSP used ConnectWise and did not offboard the machines. I have manually removed the old agent from the server that will be the network probe and this module looks perfect for moving the remaining computers to our server. I hope to get this taken care of this week, as we were just notified that our cloud server will be upgraded to v12 early next week. Has anyone tested this module with v12 to see if there are any issues? Share this post Link to post Share on other sites
DarrenWhite99 313 Posted January 10, 2018 The powershell commands are all executed through agent side processing. Nothing is loaded into the server, there is no specific dependency on the server beyond being able to reach the new server you are trying to join to. (Therefore, it is compatible with any server.) You can download the .psm1 and permanently install it on each machine, or the more popular way is to use the powershell 1-line command shown to download and load the module on demand, allowing you to use the functions on any machine with Internet Access and PowerShell 2.0 or above. Share this post Link to post Share on other sites
timbo83251 5 Posted March 22, 2018 (edited) This is so great! We have a huge client we are taking over one location at a time, so I needed a way to do this by subnet. Came up with this little .bat: for a = 1 to 254 \\domain.local\NETLOGON\PsExec.exe \\10.148.160.a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://LABTECHSERVER.com -LocationID 320" next a @DarrenWhite99: Do you know if the ReInstall-LTService command will continue to install it if it's not already there, or will it bomb out if there's nothing to uninstall? The old MSP did remove some of their agents, but not others... UPDATE: Confirmed it will install if not there! Edited March 22, 2018 by timbo83251 new info Share this post Link to post Share on other sites
Rafe Spaulding 0 Posted January 18 I used a bit from many parts of this forum, and a little of my own batch file knowledge to create this. This BATCH script will create a loop from x to x (1-254 for example) and apply the variable to the end of an ip address to cycle through each IP on your network to rip and replace Labtech. for /L %%a in (1,1,254) do c:\windows\ltsvc\PsExec.exe \\192.168.1.%%a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://fqdnofLabtech.com -LocationID xxx" Definition: for /L %%a in (1,1,254) = create a loop from 1-254 and store in value %%a (To be run from a batch file) 5-250 would look like (5,1,250) Definition: 192.168.1.%%A = 192.168.1.1-254 (You can use any internal network IP's you wish) RipAndReplaceLabtech - Sanitized.bat Share this post Link to post Share on other sites
Jalfo27 0 Posted February 14 Can't seem to get the script to actually uninstall. RUnning it on just 1-2 machines at a time. It starts the uninstall, stops the labtech services, and then just hangs. Any ideas? I am using PsExec.exe \\192.168.3.202 -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Uninstall-LTService -server https://fqdn Share this post Link to post Share on other sites
DarrenWhite99 313 Posted Monday at 07:33 PM I have had trouble before running through psexec.. Try adding " <NUL" to the end (without quotes).. You might need ^<NUL since you want that to be passed to the remote machine. Share this post Link to post Share on other sites
Braingears 2 Posted Tuesday at 10:51 PM (edited) I updated the Rip & Replace PowerShell script yesterday. It will check: • If an agent is not already installed, it will download the agent and install silently. • If an agent is already installed, it will compare the existing server it's checking into, if it's your automate server, it will comment that it's already installed. If it's another MSP, it will download the uninstaller, run it, then download and install your agent to the same computer. At the end, it will give you confirmation that it's checking in along with the ComputerID in Automate. Edited Tuesday at 10:53 PM by Braingears forgot link Share this post Link to post Share on other sites
ZenTekDS 0 Posted 21 hours ago On 1/18/2019 at 3:36 PM, Rafe Spaulding said: I used a bit from many parts of this forum, and a little of my own batch file knowledge to create this. This BATCH script will create a loop from x to x (1-254 for example) and apply the variable to the end of an ip address to cycle through each IP on your network to rip and replace Labtech. for /L %%a in (1,1,254) do c:\windows\ltsvc\PsExec.exe \\192.168.1.%%a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://fqdnofLabtech.com -LocationID xxx" Definition: for /L %%a in (1,1,254) = create a loop from 1-254 and store in value %%a (To be run from a batch file) 5-250 would look like (5,1,250) Definition: 192.168.1.%%A = 192.168.1.1-254 (You can use any internal network IP's you wish) RipAndReplaceLabtech - Sanitized.bat This worked flawlessly. Share this post Link to post Share on other sites
timbo83251 5 Posted 10 hours ago I'll share what I have for powershell -- not working 100% for the auto downloading of psexec to sysvol and stuff, but I tweak as needed. You can prob see where I as going. I'm sure someone can make it way better... Write-Host "This script will use PSEXEC to run a powershell command on every remote PC on the a specific network to Replace and/or Install our Labtech Agent" Write-Host "It will attempt to download PSEXEC.exe to the NETLOGON folder of the domain. If this script fails, you may need to place it there manually." Write-Host "You should be running this script from a domain controller AS ADMINISTRATOR" Write-Host "Networks will be broken down into /24" $SUBNET = Read-Host -Prompt 'Input the Network ID (e.g. 192.168.1.0)' $SUBNET = $SUBNET.Substring(0,$SUBNET.Length-2) $LocationID = Read-Host -Prompt 'Input the Labtech Location ID' $Domain = $env:userdnsdomain $PSEXECPATH = \\$Domain\NETLOGON\psexec.exe #If (-Not(Test-Path -Path "C:\Windows\SYSVOL\domain\scripts\psexec.exe" -PathType leaf)) #{ #Invoke-WebRequest -Uri "https://ltserverfqdn.com/Labtech/Transfer/Tools/psexec.exe" -OutFile "C:\Windows\SYSVOL\domain\scripts\psexec.exe" #} Write-Host "Labtech will now be pushed out to '$SUBNET.0' and will go into Location '$LocationID'. The location of PSEXEC is '$PSEXECPATH'" $x=1 DO { $IP = "$SUBNET.$x" Write-Host "$IP" $ARGUMENTLIST = "-n 9 \\$IP C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://ltserverfqdn.com -LocationID $locationID" Start-Process -filepath "$PSEXECPATH" -ArgumentList $ARGUMENTLIST $x++ "Now `$x is $x" } While ($x -le 254) Share this post Link to post Share on other sites