Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell 4 - Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory

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?

like image 209
Yogesh Patel Avatar asked Oct 30 '15 05:10

Yogesh Patel


People also ask

How do I import a Sqlps module into PowerShell?

To install the SqlServer module from the PowerShell Gallery, start a PowerShell session and run Install-Module SQLServer . If running on Windows PowerShell you can use Install-Module SQLServer -Scope CurrentUser to install the module for just the current user and avoid needing elevated permissions.

What is Sqlps?

The sqlps utility starts a Windows PowerShell session with the SQL Server PowerShell provider and cmdlets loaded and registered. You can enter PowerShell commands or scripts that use the SQL Server PowerShell components to work with instances of SQL Server and their objects.

Was not loaded because no valid module file was?

Solution: This error is because the PowerShell console or ISE is unable to get the module from given module path's in the environment variable “PSModulePath”. To fix the issue, You have to make sure your custom module's path is appended to the PSModulePath environment variable.

How do I import a PowerShell module?

To import the module into all sessions, add an Import-Module command to your PowerShell profile. To manage remote Windows computers that have PowerShell and PowerShell remoting enabled, create a PSSession on the remote computer and then use Get-Module -PSSession to get the PowerShell modules in the PSSession.


1 Answers

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
like image 148
RiverHeart Avatar answered Sep 16 '22 18:09

RiverHeart