Invoke-Sqlcmd Command Script running in PS 5 works but failing under PS 7.3.1

126 Views Asked by At

I am getting the following error: The term 'Invoke-Sqlcmd' 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.

The environment path appears to be correct: C:\Program Files\PowerShell\7 C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem C:\Windows\System32\WindowsPowerShell\v1.0
C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\

C:\Program Files\Microsoft SQL Server\140\DTS\Binn\

C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn
C:\Program Files\Microsoft SQL Server\140\Tools\Binn
C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio
C:\Program Files\PowerShell\7
C:\Users\srvpegasysp\AppData\Local\Microsoft\WindowsApps

The structure of the command is: Invoke-Sqlcmd -ServerInstance "ServerName" -Database "DBName" -InputFile "D:\SCRIPTS\Adds.sql" | Export-Csv "C:\temp\Adds.txt" -Delimiter "|" -UseQuotes AsNeeded -NoTypeInformation

I just upgraded PS from version 5 to 7.3.1 to use the -UseQuotes AsNeeded parm.

Thanks for the help. LK

Not sure why it would work in one version and not the other. Note: These are running on a Windows 2019 server.

0

There are 0 best solutions below