Loading SMO assemblies

Before you can use the SMO library, the assemblies need to be loaded. With the introduction of the SQLPS module, this step is easier than ever.

Getting ready

In this recipe, we assume you have already installed SMO on your machine.

How to do it...

To load SMO assemblies via the SQLPS module, perform the following steps:

  1. Open up your PowerShell console, PowerShell ISE, or your favorite PowerShell Editor.
  2. Type the import-module command as follows:
    Import-Module SQLPS
  3. Confirm that the module is loaded by running the following. This should give the name of the module if it is loaded:
    Get-Module

How it works...

The way to load SMO assemblies has changed between different versions of PowerShell and SQL Server. Before the SQLPS module and ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.