Skip navigation
knowledge is power yellow road sign

5 SQL Server Tips For Getting Started with PowerShell

Get started using PowerShell in SQL Server 2012 with the following 5 tips:

1. Your execution policy must first be configured to run scripts. At a minimum, run this command in a elevated session:

PS C:\> set-executionpolicy remotesigned -force

2. For SQL Server 2012, which includes PowerShell 2.0 by default, you need to import the sqlps module, which contains all the PowerShell commands related to SQL Server.

3. A valuable cmdlet is Invoke-SQLCmd. As the name implies, the Invoke-SQLCmd cmdlet's job is to run a SQL command. It does so through its Query parameter.

4. Restoring a database from a backup is easy thanks to the Restore-SQLDatabase cmdlet.

5. When you have the SQL Server PowerShell bits installed on your desktop, you can manage multiple servers from one location, which is very handy.

Want to learn more? For more in-depth information, visit "PowerShell the SQL Server Way."

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish