SQLPS Error After Upgrading PowerShell

Another Error I thought that was worth blogging about.

I upgraded to PowerShell 5.1 and then suddenly the SQLPS module seemed to disappear. When I start PowerShell, the SQLPS module should be automatically loaded but I received the below error. Even manually importing the module wouldn’t work.

So I needed to update the module path for it to be found. So I went and found the module in my SQL tools folder. I found it here:

C:\Program Files\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS

Depending on the version of SQL Server you are using, this  may be in another version folder.

To resolve and update the module path, I then ran the following:

$env:PSModulePath = $env:PSModulePath + ";C:\Program Files\Microsoft SQL Server\130\Tools\PowerShell\Modules"

I then checked that the SQLPS module was available:

Get-Module -ListAvailable

I was then able to import the module manually and also loaded it automatically with my user profile.

import-module SQLPS