Lansweeper alternative
![lansweeper alternative lansweeper alternative](https://windows-cdn.softpedia.com/screenshots/Lansweeper_22.png)
PowerShell Remoting is a convenient way to execute commands on remote computers. You can see below once we type exit and hit Enter, we’re immediately brought back to our local console. Related: Installing Chocolatey Packages Remotely With PowerShell To do that, we use the exit keyword which disconnects us from the session and closes it.
![lansweeper alternative lansweeper alternative](https://img.netzwelt.de/dw1600_dh900_sw0_sh0_sx0_sy0_sr16x9_nu2/picture/original/2019/07/lansweeper-logo-254762.png)
When we’re done, we have to close the session. We don’t need to use Invoke-Command to do this. PS C:\> Enter-PSSession -ComputerName SRV1Īt this point, I can run any commands I’d like, and they will be executed on the remote computer. Notice below that I’ve entered a remote session and have a new PowerShell prompt that’s prepended by the computer name the session is running in. One way to do that is to use the ComputerName parameter. To do this though, first, you need to establish a session. The Enter-PSSession command allows you to log into a remote session, run commands, get output and work just as if you were typing commands into the local console.
![lansweeper alternative lansweeper alternative](https://static.crozdesk.com/web_app_library/screenshots/images/000/020/075/screenshot/lansweeper-screenshot-5.png)
This is more obvious when you choose to run commands interactively using the Enter-PSSession command. You may not have noticed but the Invoke-Command command created a lightweight session in the background to run that command and when the command was complete it tore it down. PS C:\> Invoke-Command -ComputerName SRV1 -ScriptBlock $scriptblock PS C:\> Invoke-Command -ComputerName SRV1 -ScriptBlock You can see that it returns different results. I’m running the hostname command locally on my computer and then running it remotely with I nvoke-Command. You can see below how this works in action. We also have a ScriptBlock parameter where we’ll encapsulate the commands we intend to run on the remote computer. This command has a ComputerName parameter that allows us to specify a computer to run on the command. To run remote commands non-interactively, we use the Invoke-Command command. Let’s start off by showing a non-interactive example. Interactively means we’ll need to be at our computer to run the commands physically. There are two ways we can run remote commands via PowerShell Remoting we can issue commands interactively or non-interactively.
Lansweeper alternative code#
As a test to ensure the code is running on the remote computer, I always like to use the hostname command which returns the name of the computer. In this context, PowerShell Remoting will use Kerberos to authenticate, and we won’t need to pass alternate credentials to the commands.Īssuming that the remote computer has PowerShell Remoting enabled, let’s first try out running simple commands on a remote computer. There are lots of different configurations a user may find themselves in, but for this article, we’re going to assume the local and remote computers are both in the same Active Directory domain.
![lansweeper alternative lansweeper alternative](https://d2t60rd7vcv5ly.cloudfront.net/latest_screenshots/1511442172_Lansweeper-home.png)
Depending on how the user wants to establish the connection, some client configuration may be necessary as well. To establish a session called a PSSession with PowerShell requires that the remote computer has PowerShell Remoting enabled and listening on port 5985 (HTTP) or 5986 (HTTPS) with all of the usual firewall exceptions.