0
votes

I am running a script. But when trying to run it outside Powershell ISE it comes with the error "The term 'Invoke-SqlCommand' is not recognized as the name of a cmdlet".

The SQL module is importet via the script and in both cases the script is executed in the same user context. Any ideas?

In Powershell ISE

and

In powershell CMD

1
Are you using this function? If so, try dot-sourcing the script or module that defines Invoke-SqlCommand, or call Import-Module xxxx, where xxxx is the name of the module that defines it, or copy-paste the function directly into your script. Otherwise, see the native Invoke-SqlCmd cmdlets provided by Microsoft in their sqlps and sqlserver modules.leeharvey1

1 Answers

0
votes

Think the mistake was placing function after mainscript. Rookie Mistake ;-)