Getting started with Powershell

  • 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?

  • 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

  • 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

  • Duplicate post.

  • 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.

  • Thanks both.

    Looks like I've got a lot of reading to do.

  • 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

  • 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.

  • 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.

  • 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 ;).

    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.

  • Tom_Hogan - Thursday, October 26, 2017 7:14 AM

    I would imagine you could over complicate things in either language.  

    Absolutely!

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply