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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With