I was trying to retrieve the SQL edition using a PowerShell script recently. After executing that query, I got this error. In this article, I will discuss the cause and the solution to this error.
Cannot find type [microsoft.sqlserver.management.smo.server]
I was executing the below query.
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | Out-Null
$s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "LAPTOP-KK75M6V0\LOCALDB#75161C73"
$s.Edition
After executing the above query, I got the error as shown below.
New-Object : Cannot find type [Microsoft.SqlServer.Management.Smo.Server]: verify that the assembly
containing this type is loaded.
At line:2 char:6
+ $s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "LAPTOP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
You can see the same error shown in the screenshot below.
![Cannot find type [microsoft.sqlserver.management.smo.server]](https://databasefaqs.com/wp-content/uploads/2025/01/Cannot-find-type-microsoft.sqlserver.management.smo_.server-1024x295.jpg)
Solution
To fix the error, follow the below steps.
1. Open Windows PowerShell ISE with Run as administrator.

2. Now, execute the below PowerShell command to install the SqlServer module.
Install-Module -Name SqlServer
After executing the above command, I got the expected output, as shown below.

3. Now, execute the Powershell script below with the import SQL server statement, as shown below.
Import-Module -Name SqlServer
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | Out-Null
$s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "LAPTOP-KK75M6V0\LOCALDB#75161C73"
$s.Edition
After executing the above command, I got the expected output, as shown below, with no error.

Video Tutorial
Conclusion
This article discussed how I fixed the error Cannot Find Type microsoft.sqlserver.management.smo.server. Now, you can select the above steps to fix this error.
You may also like following the articles below.
- An Explicit Value For The Identity Column In Table
- How To Check DB Size In SQL Server
- How To See What Version Of SQL Server Is Running

Rajkishore Sahoo is a Microsoft Azure consultant with more than 14 years of hands-on experience building cloud-native data solutions across Azure and AWS, focused on Azure SQL Database, Azure SQL Managed Instance, and the pipelines that connect them to production apps. Day to day, he provisions Azure SQL instances, configures firewalls and connection strings, tunes queries for cloud workloads, and wires databases into Azure Functions and Logic Apps. Read more