PowerShell 4 - Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory
56,059
Sounds like you need to manually update the module path.
Check to see that this directory exists on the computer.
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS
[Fixed]
If it does then run
$env:PSModulePath = $env:PSModulePath + ";C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules"
Then check to see if the SQLPS module is in the list of available modules using
get-module -listavailable
Comments
-
Yogesh Patel almost 2 years
Previously working with PowerShell 3. Upgraded to PowerShell 4 and uninstalled it as facing error stated.
Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory.
But all SQL related stuff is working fine without the error. What is the root cause of this error in PowerShell console? -
Yogesh Patel about 8 yearsI have run "$env:PSModulePath = $env:PSModulePath + ";C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS" as directory exist. And then execute get-module -listavailable, SQLPS is available, but still facing same error. And if I restart power Shell editor SQLPS is not listing in get-module -listavailable.
-
RiverHeart about 8 yearsTry dropping the SQLPS portion when you add the path to psmodulepath
$env:PSModulePath = $env:PSModulePath + ";C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules"
-
Yogesh Patel about 8 yearsIt works, but I have to run same each and every time after restarting the power Shell editor. So is it correct behaviour?
-
RiverHeart about 8 yearsYes, it is normal behavior. The environment variable will reset every time you open powershell. You can either run "sysdm.cpl" --> Advanced --> Environment Variables and modify the PSModulePath path there or you can try copying the SQLPS module to the system path for power shell modules at C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
-
Yogesh Patel about 8 yearsGreat!! I have copied SQLPS module at power shell module at C:\Windows\system32\WindowsPowerShell\v1.0\Modules. It works perfectly..
-
David Mohundro almost 6 yearsQuick note - the
SQLPS
module is now deprecated in favor of theSqlServer
module which can be installed viaInstall-Module SqlServer
. See docs.microsoft.com/en-us/sql/powershell/… for reference. -
RiverHeart almost 6 years@DavidMohundro Good to know. That module does appear to require Powershell v5, so if you are on Server 2016 or higher you should be good to go otherwise you'll need to update your Powershell install to use it.