DBATools and Overload SQLCommand and a clean ISE session

385 Views Asked by At

I have an older server with Powershell ISE, where I can't easily install vscode.

I am trying to run DBATools.io's invoke-dbaquery using the ISE, but I get 'cannot find an overload for "sqlcommand"'. Looking online (https://dba.stackexchange.com/questions/305582/invoke-dbaquery-not-working-on-new-server-cannot-find-an-overload-for-sqlcomma), it says it occurs if sqlserver or sqlps is loaded first.

The full error:

WARNING: [15:20:11][Invoke-DbaQuery] [myserver] Failed during execution | Cannot find an overload for "SqlCommand" and the argument count: "2".

Looking at the various profiles below, they all say "this ps1 file", but none of the files exist.

  • $PROFILE.AllUsersCurrentHost
  • $PROFILE.CurrentUserAllHosts
  • $profile.CurrentUserCurrentHost
  • $PROFILE.AllUsersAllHosts

I have tried remove-module sqlserver and remove-module sqlps, and both return "no modules were removed".

If I open a blank powershell session the invoke-dbaquery works, but since i've got to do loops and a bunch of various commands, the ISE honestly is just a ton easier to use.

How do I get invoke-dbaquery to work in the ISE?

0

There are 0 best solutions below