Search code examples
sql-serverpowershellsmo

Microsoft.SqlServer.Management.Smo.Server class compatibility among different SQL Server versions


Here is my question: I have a server running SQL Server 2008 R2 (SP3) and I'm trying to create a PowerShell script to perform some administrative tasks.

This PowerShell script uses a method called EnumServerPermissions on the class Microsoft.SqlServer.Management.Smo. According to the official MS documentation on this method this is only supported on SQL Server 2012 onwards.

Now my question is this: since this class lives inside Microsoft.SqlServer.Smo.dll, isn't there a way to run an updated version of the SQL Server Management Objetcs (SMO) that is compatible with this method call, even on an older version of SQL Server (such as my 2008 R2)? Do I have to accept this just doesn't run on my version? Or is there a way to make it work by updating something?

Thanks!


Solution

  • If you are saying that Microsoft documentation is stating it only supports SQL Server 2012 + because of this: enter image description here

    That would be incorrect, and not officially stating what version it supports and doesn't support. SMO is treated just like SQL Server Management Studio. You can utilize a new version to connect to any version of SQL Server. The only stipulation is certain properties or classes would fail based on the property not existing on lower versions of SQL Server or feature is not available (e.g. AvailabilityGroup namespace on SQL Server 2008 R2 would fail).

    As an example, in the PowerShell module dbatools we have the latest version of SMO packaged with that module. So if you installed that module on a brand new machine you could connect to any version of SQL Server, from 2000+. We have commands in that module that support running against SQL Server 2000 and then some that only for 2012+ version of SQL Server.