What is the required version of SQL Server PS module for SQL Server 2012?

I have SQL Server Express 2012 and SQL Server 2017 Advanced.

I was able to get the SQL Server 2017 to start the PowerShell command.

I cannot get SQL Server 2012 to run the Start SQL Server command.

I was able to do this oreviously but not now.

I see the SQLPS in the Binn file but I get the following error:

import-module : Could not load file or assembly ‘file:///C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShe
ll\Modules\SQLPS\Microsoft.SqlServer.Management.PSSnapins.dll’ or one of its dependencies. This assembly is built by a
runtime newer than the currently loaded runtime and cannot be loaded.
At line:1 char:14

  • import-module <<<< SQLPS -DisableNameChecking
  • CategoryInfo : NotSpecified: (:slight_smile: [Import-Module], BadImageFormatException
  • FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand

PowerShell is PowerShell not matter where you run it.
PS is tied to Windows, not SQL.
SQLPS in only adding cmdlets, not some SQL PowerShell instance.

As for this…

I have SQL Server Express 2012 and SQL Server 2017 Advanced.

Are you saying, you are running both on the same system?

If so, that does not make a difference to using PowerShell proper. There is not a different PowerShell instance for different SQL or other sever roles.

If you are saying, you have the SQL PowerShell module loaded for SQL2017, and you are trying to use that with SQL2012, this is not something I’ve tried, yet, in most cases, you can use a higher version on a lower version but not vice versa. Yet, there will be cmdlets in higher versions that may not work in lower versions.

See also:

BREAKING CHANGE: Check for SQLPS & SQLServer modules required https://github.com/PowerShell/SqlServerDsc/issues/91

SQLPS module will be faded slowly, so use SQLServer module from PSGalary itself.

and I don’t know how you are adding assemblies, you can use any one of the following based on your reference

or

Add-PSSnapin <snapin.dll>