Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PowerShell for SQL Server Essentials

You're reading from   PowerShell for SQL Server Essentials Manage and monitor SQL Server administration and application deployment with PowerShell

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher Packt
ISBN-13 9781784391492
Length 186 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Donabel Santos Donabel Santos
Author Profile Icon Donabel Santos
Donabel Santos
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with PowerShell FREE CHAPTER 2. Using PowerShell with SQL Server 3. Profiling and Configuring SQL Server 4. Basic SQL Server Administration 5. Querying SQL Server with PowerShell 6. Monitoring and Automating SQL Server A. Implementing Reusability with Functions and Modules Index

Snap-ins and modules

You can extend PowerShell by loading snap-ins and modules. Snap-ins or PSSnapins are dynamic linked library (DLLs) compiled from .NET code, which may contain additional cmdlets and PSProvider. The PSSnapins are old school—they are primarily how you extend version 1, but still supported in version 2, version 3, and version 4. Although considered old school, you can still create snap-ins. Refer to http://msdn.microsoft.com/en-us/library/ms714450(v=vs.85).aspx on how to do this.

The related snap-in cmdlets are as follows:

  • Add-PSSnapin
  • Get-PSSnapin
  • Remove-PSSnapin

Instead of snap-ins, the recommended way of extending the PowerShell functionality from version 2 onwards is using modules. Modules are similar to snap-ins when it comes to extending functionality, but unlike snap-ins, modules can also add functions. Modules also support autoloading, which means the module can be loaded as soon as one of its cmdlets/functions/PSDrive are used.

Modules can be script-based or binary-based. A script module uses PowerShell code saved in a .psm1 file. A binary module is more similar to PSSnapin, where it references a .NET DLL.

Modules are the new school way of extending PowerShell, from version 2 onwards. Related cmdlets are listed as follows:

  • Import-Module
  • Get-Module
  • Remove-Module

If you want to write PowerShell extensions, Microsoft recommends that you create modules instead of snap-ins.

You have been reading a chapter from
PowerShell for SQL Server Essentials
Published in: Feb 2015
Publisher: Packt
ISBN-13: 9781784391492
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image