How to Install SQL Server PowerShell 2017 Remotely to Your Servers

As part of upgrading our SQL Servers to 2017 CTP 2.1 we have a process that runs afterwards that uses Invoke-Sqlcmd cmdlet but with SQL Server 2017, SQL Server PowerShell 2017 is a separate install from the PowerShell Gallery.  So I wrote a process to that will install the SQL Server PowerShell remotely to the servers prior to the install.

NOTE: This process has several components and pieces but when you have to run it on over 400 servers it is definitely worth while.

First step is to make sure you have at least Windows Management Framework 5.0 on your server/workstation.  The current link to the downloads are here. Below is an example of copy the file from a network share to a list of servers a servers.txt files in the local temp folder.  The CopyFiles.ps1 file is in my Tips on Managing Lots of Instances and was written by my colleague Mark Wilkinson (Twitter | Blog).

Once the file is copied to the server locally you can use run the below script from your local machine to install SQL Server PowerShell 2017 for all user to use on the server.  The Get-CMSHosts function can be found on my blog here. You will need to download PsExec from here and extract to location on your local computer and provide the path.

NOTE: This is a hotfix that requires a RESTART. Be careful in PRODUCTION.

Once you have those components in place you finally can install SQL Server PowerShell 2017 using the following script:

Tracy Boggiano
Follow me

Tracy Boggiano

Database Administrator at ChannelAdvisor
Tracy has spent over 20 years in IT and has been using SQL Server since 1999 and is currently certified as a MCSE Data Management and Analytics. She has worked on SQL Server 6.5 and up including currently SQL 2017 CTP 2.0. She enjoys monitoring, performance tuning, and high availability and disaster recovery technologies. Tracy is currently a co-organizar the for special interest group for Advanced DBA Topics for the TriPASS user group.

She also tinkered with databases in middle school to keep her sports card collection organized.

Tracy has volunteered through the NC Guardian ad Litem program since 2003 advocating for abused and neglected foster children in court.This is her passion outside of SQL Server and favorite job.More information about this program in North Carolina can be found at http://volunteerforgal.org or the national organization CASA at http://www.casaforchildren.org.
Tracy Boggiano
Follow me