andrewjamesbowen
andrewjamesbowen

Reputation: 641

Only a single command in "Get-Command -Module SqlServer" of "Invoke-SqlNotebook". How to get the rest?

I want to run Invoke-Sqlcmd but it's not found on my Windows 11 system

For some reason the only result is "Invoke-SqlNotebook"

I've removed, installed, imported, updated SqlServer module

Ran the following commands in PowerShell, and expected Invoke-SqlCmd to come up https://learn.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps

Install-Module -Name SqlServer -Force
Import-Module SqlServer
Get-Command -Module SqlServer

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Invoke-SqlNotebook                                 22.1.1     SqlServer


Get-Module SqlServer

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     22.1.1                SqlServer                           Invoke-SqlNotebook

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Upvotes: 0

Views: 163

Answers (2)

sphillips22
sphillips22

Reputation: 1

With Azure Automations I had to ensure both the Runbook was set to use 5.1 runtime and the installed SqlServer module was 5.1. This is despite 7.2 being the recommended during Runbook creation. Once this was completed, I could run "Get-Command -Module SqlServer" and see all cmdlets. When using 7.2 only "Invoke-SqlNotebook" was visible.

Intriguingly (as of 6/1/2024) when using "Deploy to Automation" (under Azure Automations) from https://www.powershellgallery.com/packages/SqlServer/22.2.0, this installs version 5.1 of SqlServer Module.

Upvotes: 0

andrewjamesbowen
andrewjamesbowen

Reputation: 641

Shortly after posting this I decided to upgrade PowerShell to the latest version 7.3.7 at the time of writing. All the appropriate modules appear such as Invoke-Sqlcmd.

When running out an support version of Powershell (7.1 in 2023), there's no warnings of incompatibility when installing modules, or at least installing the last compatible version instead of "succeeding". A bit disappointing user experience.

End of support for those with similar experience

https://learn.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.3#powershell-end-of-support-dates

Upvotes: 1

Related Questions