Tutorials References Exercises Menu

Zeal For Wisdom


SQL Server PowerShell

PowerShell

There are two SQL Server PowerShell modules; SqlServer and SQLPS. The SqlServer module is the current PowerShell module to use. The SQLPS module is included with the SQL Server installation (for backward compatibility) but is no longer updated. The SqlServer module contains updated versions of the cmdlets in SQLPS and includes new cmdlets to support the latest SQL features. Previous versions of the SqlServer module were included with SQL Server Management Studio (SSMS), but only with the 16.x versions of SSMS. To use PowerShell with SSMS 17.0 and later, install the SqlServer module from the PowerShell Gallery.

SQL Server PowerShell Components

PowerShell Providers, which enables a simple navigation mechanism similar to file system paths. You can build paths similar to file system paths, where the drive is associated with a SQL Server management object model, and the nodes are based on the object model classes. You can then use familiar commands such as cd (alias for Set-Location) and dir (alias for Get-ChildItem) to navigate the paths similar to the way you navigate folders in a command prompt window. You can use other commands, such as ren (alias for Rename-Item) or del (alias for Remove-Item), to perform actions on the nodes in the path.

Use PowerShell Cmdlet

For example, you can use one of the following sets of cmdlets or aliases to retrieve a listing of the SQL Server instances available to you by navigating to the SQLSERVER:\SQL folder and requesting the list of child items for the folder:

Read More ...


Zeal For Wisdom

Learn Today For Better Tomorrow