If the Powershell module is installed and can be found. Why is the cmdlet not being recognized?
PS C:\> Get-SqlInstance -Credential laptop-ql9k5dk6\david -ServerInstance "(localdb)\MSSQLLocalDB"
Get-SqlInstance: The term 'Get-SqlInstance' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\> Get-InstalledModule -Name SqlServer -AllVersions | select Name,Version
Name Version
---- -------
SqlServer 21.1.18256
I don't know the location of the Powershell SqlServer
module. But the env paths have worked for everything I have used so far:
$env:PSModulePath -split ";"
C:\Users\david\OneDrive\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\7\Modules
C:\Users\david\Documents\WindowsPowerShell\Modules
C:\Users\david\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules\
c:\Users\david\.vscode\extensions\ms-vscode.powershell-2023.1.0\modules