Using the simple Powershell script we can uninstall notepad++ and reinstall, let’s discuss how to write the code.
IT administrator has to upgrade software’s when there is a new release or when it has become obsolete, it is easy to upgrade when there is only one computer to upgrade any software however when there are hundreds and thousands of computers then it is difficult to uninstall manually, but we have a solution, yes using a simple Powershell script.
we need to call the uninstall.exe file to get it removed from the computer, first, we need create a batch file to call it.
Notepad++ uninstall
@each off
:Notepad++ Uninstall Batch file
cd C:\Program Files (x86)\Notepad++
start /wait uninstall.exe /s
exit
Just copy the above code in a notepad file and save it as Notepad++Uninstall.bat file, remember I have a 32-bit version of notepad++ if you have a 64-bit version is installed then change path to C:\Program Files\Notepad++ in the above code, here is the screenshot to do it similar way.
We need to create a file for storing all the servers or multiple machines list, I named it as Allservers.txt and saved it in my local machine c:\temp\Allservers.txt
#remote machines list
$machines= Get-Content -Path "C:\temp\AllServers.txt"
foreach ($onemachine in $computers)
{
#notepad++ uninstall batch file location file and where to copy on the remote system
Copy-Item -Path "\\sourcemachine\\Notepad++Uninstall.bat -Destination "\\$onemachine\c$\temp" -Recurse -force
Invoke-command -ComputerName $onemachine-Scriptblock {C:\temp\Notepad++Uninstall.bat} -Asjob
}
The above simple code copies the uninstall notepad++ bat file on the remote computers and uninstalls the notepad++ program, each computer execution runs a background job and finishes the un-installation, wait for all jobs to complete, to get the running job status, use the command get-job -state running.
I hope you find this article useful, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply