Bobcares

Powershell Cannot Find Type microsoft.sqlserver.management.smo.server

by | Jun 27, 2022

Powershell Cannot find type microsoft.sqlserver.management.smo.server error troubleshooting methods by our Bobcare’s specialist team.

At Bobcares, as part of our Microsoft SQL Server Support service, we respond to every question from the customers.

Let’s have a closer look at various troubleshooting methods for the error by our experts.

Powershell cannot find type Microsoft.SqlServer.Management.Smo.Server Error

When customers attempt to run a fast Server backup using a PowerShell script to backup databases, sometimes the following error may appear:

PS>TerminatingError(New-Object): “Cannot find type [Microsoft.SqlServer.Management.Smo.Server]: verify that assembly containing this type is loaded.”
new-object : Cannot find type [Microsoft.SqlServer.Management.Smo.Server]: verify that  assembly containing this type is loaded.

Our Support team looked into this error. They came up with a few ways to troubleshoot the error for our customers. Now let’s examine them closely.

We have found that there is a need to install extensions for PowerShell to be able to run this script. So we must install the compatible PowerShell Extensions for our SQL Server. For instance, if we have SQL Server 2016 as a target server, we need PowerShell Extensions for SQL Server 2016.

Troubleshooting the error

SqlServer and SQLPS are two SQL Server PowerShell modules. The SQLPS module comes pre-installed with SQL Server. However, it is no longer updated. The SqlServermodule is the most recent PowerShell module. The SqlServer module includes new cmdlets to support the latest SQL capabilities. It also includes updated versions of the SQLPS cmdlets.

Now we can see how Bobcares support team suggests a customer with SQL Server 2016 as a target server to fix this issue.

  • Firstly, install SQLSysClrTypes.msi – Microsoft System CLR Types for Microsoft SQL Server 2016.
  • Then install SharedManagementObjects.msi – Microsoft SQL Server 2016 Shared Management Objects.
  • Lastly, install PowerShellTools.msi – Microsoft Windows PowerShell Extensions for Microsoft SQL Server 2016.

Once we install all the components, then we can check it with the command;

Get-Module -ListAvailable -Name SQLPS

Here is another solution provided by our techs to the customer for the below error.

new-object : Cannot find type [Microsoft.SqlServer.Management.Smo.Server]: verify that assembly containing this
type is loaded.
At line:1 char:6
+ $s = new-object ('Microsoft.SqlServer.Management.Smo.Server') 'sqlnod ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId :
TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Now we can see how our server management team help the client to fix this issue. The steps are:

  • Start a PowerShell session. Then use the following instructions to install the SqlServer module from the PowerShell Gallery.

Install-Module -Name SqlServer

  • If there are previous versions of the SqlServer module on the computer, then we can use Update-Module or provide the -AllowClobber parameter:

Install-Module -Name SqlServer -AllowClobber

  • If we are unable to run the PowerShell session as admin, we can install for the current user:

Install-Module -Name SqlServer -Scope CurrentUser

  • Using Update-Module, we can upgrade the SqlServer module versions:

Update-Module -Name SqlServer

  • To see the installed module versions:

Get-Module SqlServer -ListAvailable

  • To utilize a particular version of the module, import it with a version number. For e.g.,

Import-Module SqlServer -Version Version_number

With these solutions, we can definitely fix the error for our customers.

[Looking for a solution to another query? We are just a click away.]

Conclusion

When doing a quick server backup, some users could get the following error: cannot find type microsoft.sqlserver.management.smo.server. Here, our Support Team keenly look into the issue and developed troubleshooting techniques to address the issue easily.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.