Applying cumulative updates to SQL Servers remotely using PowerShell.
I had to apply some cumulative updates to a couple of SQL Servers and was struggling to remote desktop onto the server.
So instead of continuing with struggling to connect I decided to try and use a Powershell remote session which turned out to work quite well.
- Copy the cumulative update to the server to be patched.
- Open an elevated Powershell command prompt.
- Enter-PSSession -ComputerName <COMPUTERNAME>
- cd to the folder with the CU
- Run the command to install the cumulative update.
- Open the installer logs to confirm the installation succeeded (Log File Location).
As this is a Powershell remote session we want to run the installer with no GUI, so here is the command to update all instances.
.\SQLServer2012-KB3007556-x64.exe /q /action=patch /allinstances /IAcceptSQLServerLicenseTerms