SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


PowerShell Basics


PowerShell Basics

Author
Message
Shawn Melton
Shawn Melton
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11859 Visits: 3591
Comments posted to this topic are about the item PowerShell Basics

Shawn Melton
Twitter: @wsmelton
Blog: blog.wsmelton.info
parcival
parcival
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 166
Thanks Shawn. I have yet to use Powershell but this article has been a timely prompt.



Adam Sottosanti
Adam Sottosanti
SSC Veteran
SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)

Group: General Forum Members
Points: 238 Visits: 409
Thanks for the article Shawn. This is really helpful, I appreciate all the links you've provided as well.

Adam Sottosanti
Shawn Melton
Shawn Melton
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11859 Visits: 3591
parcival (1/24/2011)
Thanks Shawn. I have yet to use Powershell but this article has been a timely prompt.

Thanks, I wish my current job required me to use it more than I do. Hehe

Shawn Melton
Twitter: @wsmelton
Blog: blog.wsmelton.info
Shawn Melton
Shawn Melton
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11859 Visits: 3591
Adam Sottosanti (1/24/2011)
Thanks for the article Shawn. This is really helpful, I appreciate all the links you've provided as well.

You are welcome...here is one I left out cause I did not know if the link would stay active or not:
Bing Visual Search - PowerShell

If the link does not work, just go to http://www.bing.com search for just "PowerShell". You should see a tab show up under the search box called "Visual Search". It is a cool little graphical tool Bing created to browse the major commands and show some syntax.

Shawn Melton
Twitter: @wsmelton
Blog: blog.wsmelton.info
Abi Chapagai
Abi Chapagai
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2034 Visits: 1127
Shawn:
Thanks for the great article.
msorens
msorens
SSC-Enthusiastic
SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)

Group: General Forum Members
Points: 166 Visits: 184
Nice introduction to PowerShell! For a bit more geared toward those interested in SQL Server and PowerShell, I wrote a two-part introduction entitled Practical PowerShell for SQL Server Developers and DBAs that shows, among other cool features, how to navigate in "SQL space" just like you can navigate in a file system. See https://www.simple-talk.com/sql/database-administration/practical-powershell-for-sql-server-developers-and-dbas-%E2%80%93-part-1/
cdonlan 18448
cdonlan 18448
SSC Veteran
SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)

Group: General Forum Members
Points: 203 Visits: 283
Nice article, I'm a recent fan of PowerShell. I didn't know about the ISE. I found a use for it beyond metrics and administration that other DBA's might find useful: data traffic. I route a large chunk of our EDI traffic (text files mostly) into filetables with it. The script opens the file, reads what it needs, makes the necessary db calls, logs it, and moves it to point B. In the past I would have considered a CLR routine, but now I find myself asking myself if I can do it in PowerShell first.
Caruncles
Caruncles
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1505 Visits: 244
following the logic that "the only dumb question is the one which doesn't get asked"-- how do you start Powershell? from SSMS, cmd prompt?
Hey, you said "basic". That's where I'm at.

Thanx!

Wallace Houston
Sunnyland Farms, Inc.

"We must endeavor to persevere."
Shawn Melton
Shawn Melton
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11859 Visits: 3591
Caruncles (6/5/2014)
following the logic that "the only dumb question is the one which doesn't get asked"-- how do you start Powershell? from SSMS, cmd prompt?

It can differ a bit based on Operating System where within the start menu you find "PowerShell" to open it. As well, in some instances you want to start PowerShell "as Administrator" to have an elevate privileges within the PowerShell prompt.

Basic:
To just open PowerShell prompt (powershell.exe):
- Start Menu, just type "PowerShell" for Windows 7 and onwards (including Server 2008 and up), this brings up the list for the ISE and just prompt both (x86) and x64 if you are on 64-bit server.

To open SQL Server PowerShell (sqlps.exe):
- Start Menu, just type "sqlps.exe". You generally will not see to many folks use this method.
- Within SSMS 2008 or higher, right-click a folder or container and click "Start PowerShell".
Note that using sqlps.exe you are not in the full blown "Powershell" world, you enter into SQL Server's made up world so to speak. The basic to understand is that general PowerShell commands may not work as you thing they should. This is because of the provider you are in within that particular prompt.

Open SQL Server PowerShell from PowerShell.exe:
- This is the most common method found and a bit easier to work in.
- Within PowerShell prompt for SQL Server 2008 - SQL Server 2008 R2 you type: Add-PSSnapin *SQL*
- Within PowerShell prompt for SQL Server 2012 and up you type: Import-Module SQLPS

If you are at the basics I would start by reading through this guide, even though it is version 1.0 it covers the basics of how PowerShell operators.
Then I would highly suggest watching the beginner PowerShell videos from MidnightDBAs, how I got started in it all.

Shawn Melton
Twitter: @wsmelton
Blog: blog.wsmelton.info
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search