I have been using the DbaTools module in Powershell for years with no issue. However this morning I can no longer connect to any database due to the error An attempt was made to load a program with an incorrect format. (0x8007000B)
. I did some research and I saw several posts about it being an issue with 32-bit compatibility with 64-bit. At the moment it appears to only affect my local machine, and our automated scripts are running normally on their dedicated servers.
After rebooting and trying again I got this error message, which did not appear before:
The dbatools.io/newdefaults URL in the message redirects you this article. I do not have permission to create certificates on my local machine, and changing the defaults with Set-DbatoolsConfig
did not fix the error.
The dbatools version was 2.1.4. Using Powershell 7.3.8 gave me the error. I reverted back to dbatools 1.1.42, but am still getting the same error. Using Powershell 5.1 with dbatools 1.1.42 I am able to connect perfectly fine.
Has anybody else encountered this error, or knows of a solution?
For anybody finding this later, I found out it was a me problem. A few weeks ago I installed the newest PSVersion, 7.3.8, and accidentally installed the x86 version.
I found this StackOverflow post about the same issue, and it showed some commands to run to check your OS.
Running that in the command line told me the process (Powershell) was not the same as the OS. I installed the 64-bit version from Microsoft using this link. Once I installed the correct Powershell I was able to get it working. Hopefully this helps somebody in the future.