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


Getting started with Powershell


Getting started with Powershell

Author
Message
richardmgreen1
richardmgreen1
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5656 Visits: 1338
Hi all

I'm just getting started with PowerShell and following the series by Ben Miller here. I'm trying to do things properly and learn rather than just nicking bits of code from the interweb.
I've come a bit unstuck on the second article in the series as I can't seem to load these modules :-
SqlServerCmdletSnapin100
SqlServerProviderSnapin100

When I do :-
Get-PSSnapin –registered

I get :-
Name : WDeploySnapin3.0
PSVersion : 2.0
Description : This is a PowerShell snap-in that contains cmdlets for managing Microsoft Web Deployment infrastructure.

and that's it.

I've followed the instructions to download and install the CLR, SMO and Powershell objects (near the top here) but I'm still getting nowhere.

Anyone any ideas?
Sue_H
Sue_H
SSC-Forever
SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)

Group: General Forum Members
Points: 48789 Visits: 12347


Powershell has had a lot of changes since that series so you can run into issues like that with older articles.
Those modules have been replaced with SQLPS. And then SQLPS has been replaced by SQLServer. But you can still use the older modules.
For SQL Server, most things use SQLPS, some starting to use SQLServer. It gets fairly confusing with all the different versions, modules but that's another story.
You should be okay if you import SQLPS. So just try: Import-Module Sqlps -DisableNameChecking
The documentation for this is here:
Import the SQLPS Module

You might want to start with the MS documentation on Powershell for SQL Server as it's a bit more current and does go through loading this module as well as SMO assemblies. It's not you, it's how the changes have been managed with Powershell and the modules that have made it more difficult than it probably needs to be.
SQL Server PowerShell

Here is an article about the SQLPS and SQLServer modules that you may want to check as that is something you would want to be aware of:
Out With The SQLPS, In With The SqlServer

Sue



Tom_Hogan
Tom_Hogan
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2460 Visits: 3088
I'm liking PowerShell but it has changed a lot over the past couple of years. I believe we're up to version 5.1.

I'd recommend watching this course at Microsoft Virtual Academy as it does a nice intro to the language in about 4 hours of videos:
https://mva.microsoft.com/en-US/training-courses/powershell-for-sql-data-professionals-16532?l=KKuf31PgC_6705121157
Tom_Hogan
Tom_Hogan
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2460 Visits: 3088
Duplicate post.
SQLPirate
SQLPirate
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1595 Visits: 1278
Sue_H - Wednesday, October 25, 2017 7:42 AM
...
For SQL Server, most things use SQLPS, some starting to use SQLServer. It gets fairly confusing with all the different versions, modules but that's another story.
...
Sue

It's another story, but I think this is a good point for people starting in Powershell just to keep in mind as they do more unguided work that requires looking for solutions online. Many articles, forum answers, and scripts floating around are presented to the reader as if there's a standard set of modules that everyone is using and it's just not the case. It's also something that you may just get dumped into - my current job heavily relies on a web of obscure modules with little to no documentation that has required a lot of digging and working backward for me to understand.

richardmgreen1
richardmgreen1
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5656 Visits: 1338
Thanks both.

Looks like I've got a lot of reading to do.
Sue_H
Sue_H
SSC-Forever
SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)SSC-Forever (48K reputation)

Group: General Forum Members
Points: 48789 Visits: 12347
SQLPirate - Wednesday, October 25, 2017 8:10 AM
Sue_H - Wednesday, October 25, 2017 7:42 AM
...
For SQL Server, most things use SQLPS, some starting to use SQLServer. It gets fairly confusing with all the different versions, modules but that's another story.
...
Sue

It's another story, but I think this is a good point for people starting in Powershell just to keep in mind as they do more unguided work that requires looking for solutions online. Many articles, forum answers, and scripts floating around are presented to the reader as if there's a standard set of modules that everyone is using and it's just not the case. It's also something that you may just get dumped into - my current job heavily relies on a web of obscure modules with little to no documentation that has required a lot of digging and working backward for me to understand.


Totally agree. I like Powershell but not nearly as much as I used to due to all of these issues. I think you said it well about how there is a presumption that everyone is using the same set of modules. And also it's assumed that everyone is on the same current Powershell version. It's a nightmare at times and takes a lot of time to figure things out. And sometimes it's too much time so I go in another direction. Sad as Powershell really wasn't intended to be a mess like that and it has great potential.

Sue




SQLPirate
SQLPirate
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1595 Visits: 1278
Sue_H - Wednesday, October 25, 2017 8:24 AM


Totally agree. I like Powershell but not nearly as much as I used to due to all of these issues. I think you said it well about how there is a presumption that everyone is using the same set of modules. And also it's assumed that everyone is on the same current Powershell version. It's a nightmare at times and takes a lot of time to figure things out. And sometimes it's too much time so I go in another direction. Sad as Powershell really wasn't intended to be a mess like that and it has great potential.

Sue

I feel like a big part of the mess is that Powershell is used as an out to not make the jump into something like developing in C# even when the task at hand starts to become overly large or overly complex. Just because Powershell can be used, doesn't necessarily mean it's the right tool for the job. I still like Powershell in all its messy glory, but I have to admit that I've started to rewrite/port some of my larger administrative processes into compiled code.

Steve Jones
Steve Jones
SSC Guru
SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)SSC Guru (462K reputation)

Group: Administrators
Points: 462882 Visits: 20599
We are looking at updating the PoSh Stairway for this reason. PoSh has changed a lot. Likely we'll go with WS2008+ and W8+ as the PoSh installation.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Tom_Hogan
Tom_Hogan
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2460 Visits: 3088
SQLPirate - Wednesday, October 25, 2017 10:35 AM

I feel like a big part of the mess is that Powershell is used as an out to not make the jump into something like developing in C# even when the task at hand starts to become overly large or overly complex. Just because Powershell can be used, doesn't necessarily mean it's the right tool for the job. I still like Powershell in all its messy glory, but I have to admit that I've started to rewrite/port some of my larger administrative processes into compiled code.

If you have a hammer Wink.

I would imagine you could over complicate things in either language. I think PowerShell has improved a lot but it's not easy finding current resources for it.

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