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
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.