I have a situation where a user works from home but is connected to our internal network. Although I have a remote access program (LANDESK) to connect to his system, our office policy forbids me from removing programs unless I am logged into my special admin account. However, switching accounts disconnects the user from the VPN, which effectively kicks me off his system.
Therefore, as someone who is not very familiar with PowerShell, I am trying to find a way to run a command to uninstall the software with my admin account while the user is still logged in, and ideally without any disruption. The system is running Windows 10 v1803, and the software in question is SSMS 2014. Any suggestions would be greatly appreciated.
3 Answers
Introduction
Remote access programs like LANDESK are essential tools for IT professionals to connect to remote systems and troubleshoot issues. However, in some cases, the policies of the organization may restrict the IT personnel from removing programs from remote systems. This can be a challenge when a user is connected to the internal network through a VPN and the IT personnel needs to uninstall software from the remote system. In this blog post, we will discuss how to connect a remote access program (LANDESK) to a VPN and how to uninstall software from a remote system without disrupting the user.
Connecting LANDESK to a VPN
Before we discuss how to uninstall software from a remote system, we need to ensure that LANDESK is connected to the VPN. To connect LANDESK to a VPN, follow the steps below:
- Launch LANDESK on your system.
- Click on the ‘Tools’ menu and select ‘Gateway Configuration.’
- In the ‘Gateway Configuration’ window, click on the ‘VPN’ tab.
- Click on the ‘Add’ button to add a new VPN connection.
- Enter the VPN connection details, including the IP address, username, and password.
- Click on the ‘Test’ button to verify the connection.
- Click on the ‘Save’ button to save the VPN connection details.
- Close the ‘Gateway Configuration’ window.
Once you have connected LANDESK to the VPN, you can connect to the remote system using the LANDESK remote access tool.
Uninstalling Software from a Remote System
Now that we have connected LANDESK to the VPN, let’s discuss how to uninstall software from a remote system without disrupting the user. To uninstall software from a remote system, follow the steps below:
- Launch PowerShell on your system.
- Enter the following command to connect to the remote system:
Enter-PSSession -ComputerName <RemoteSystemName> -Credential <UserName>
- Enter the administrator username and password when prompted.
- Enter the following command to uninstall the software:
Get-Package -Name <SoftwareName> | Remove-Package
- Wait for the software to be uninstalled.
- Close the PowerShell window.
By using PowerShell to connect to the remote system, you can uninstall software without disrupting the user’s work. PowerShell allows you to execute commands remotely and provides a secure way to connect to remote systems.
Tips for Uninstalling Software Remotely
Uninstalling software remotely can be a challenging task, especially if you are not very familiar with PowerShell. Here are some tips to help you uninstall software from a remote system:
- Ensure that you have the necessary permissions to connect to the remote system and uninstall software.
- Make sure that you have the correct software name when uninstalling software. Using the wrong name can result in unintended consequences.
- Test the PowerShell command on a test system before running it on a production system.
- Use the ‘-WhatIf’ parameter with the PowerShell command to see what will happen before executing the command.
- Always be cautious when uninstalling software remotely, as it can disrupt the user’s work and cause other issues.
Conclusion
Remote access programs like LANDESK are essential tools for IT professionals to troubleshoot issues on remote systems. However, in some cases, the policies of the organization may restrict the IT personnel from removing programs from remote systems. By connecting LANDESK to a VPN and using PowerShell to uninstall software from a remote system, you can overcome this challenge and ensure that the user’s work is not disrupted. Always be cautious when uninstalling software remotely and follow the tips provided in this blog post to avoid unintended consequences.
References
To connect LANDESK to a VPN and perform the uninstallation of the software while the user is still logged in, you can follow these steps:
- Connect to the VPN using the VPN client provided by your organization.
- Open the Remote Desktop Connection app on your computer.
- In the “Computer” field, enter the IP address or hostname of the remote computer you want to access.
- In the “User name” field, enter the username for your admin account on the remote computer.
- Click the “Connect” button.
- When prompted, enter the password for your admin account.
- Once connected, you can use the Remote Desktop app to remotely access the remote computer and perform the uninstallation of the software using the appropriate uninstaller.
If you want to perform the uninstallation silently, you can try using the “/quiet” or “/silent” command-line switch for the uninstaller, depending on the specific software. For example:
msiexec /x {product code} /quiet
Alternatively, you can use PowerShell to remotely execute the uninstallation command on the remote computer. To do this, you can use the Invoke-Command cmdlet and specify the computer name, username, and password for the admin account on the remote computer, like this:
Invoke-Command -ComputerName {computer name} -Credential (Get-Credential) -ScriptBlock {msiexec /x {product code} /quiet}
Replace {computer name} with the name of the remote computer, and {product code} with the product code of the software you want to uninstall. This will execute the uninstallation command on the remote computer using the specified credentials, and the software will be uninstalled silently in the background.
I hope this helps! Let me know if you have any questions or need further assistance.
Doing this in PowerShell is a straightforward process. The script provided below will require you to input a computer name along with your username and password. Once entered, the script will establish a connection to the remote computer and generate a list of installed software, arranged by name:
$computerName = "SomeComputerName"
$yourAccount = Get-Credential
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_Product | Select Name
}
If you possess the name of the product that you intend to uninstall from a remote location, you can execute the uninstallation process in the following manner:
$computerName = "SomeComputerName"
$appName = "AppName"
$yourAccount = Get-Credential
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_product | Where {$_.name -eq $appName} | ForEach {
$_.Uninstall()
}
}
In the examples provided earlier, replace the term “SomeComputerName
” with the actual name of the computer from which you want to perform an uninstallation.
Alternatively, if you wish to be prompted to enter the computer name, you can utilize the following line of script:
$computerName = Read-Host "Enter Computer Name"
In case you have several computers that have the same software you want to remove, you can create an array of those computers to perform batch uninstallations across multiple machines:
$computerNames = @("SomeComputerName1", "SomeComputerName2", "SomeComputerName3")
$appName = "AppName"
$yourAccount = Get-Credential
ForEach ($computerName in $computerNames) {
Invoke-Command -ComputerName $computerName -Credential $yourAccount -ScriptBlock {
Get-WmiObject Win32_product | Where {$_.name -eq $appName} | ForEach {
$_.Uninstall()
}
}
}