An Introduction to PowerShell for a DBA

  • Comments posted to this topic are about the item An Introduction to PowerShell for a DBA

  • The SQLPS module has been abandoned and there will not be future development of it.  It is best to point people to the much better SqlServer module: https://www.powershellgallery.com/packages/SqlServer/

    @SQLvariantI have a PowerShell script[/url] for you.

  • I'm wondering if:

     

    $a = New-Object string[][] 3,2

    Write-Host $a.Count $a[0].Count

    should be written like this:


            $a = New-Object string[][] 3,2
      Write-Host $a.Count
      Write-Host $a[0].Length
     

    Kindest Regards, Rod Connect with me on LinkedIn.

  • Aaron Nelson - @SQLvariant - Thursday, December 21, 2017 4:54 AM

    The SQLPS module has been abandoned and there will not be future development of it.  It is best to point people to the much better SqlServer module: https://www.powershellgallery.com/packages/SqlServer/

    References to SQLPS being abandoned please.

  • Lynn Pettis - Thursday, December 21, 2017 9:17 AM

    Aaron Nelson - @SQLvariant - Thursday, December 21, 2017 4:54 AM

    The SQLPS module has been abandoned and there will not be future development of it.  It is best to point people to the much better SqlServer module: https://www.powershellgallery.com/packages/SqlServer/

    References to SQLPS being abandoned please.

    Microsoft has some information on the changes with the modules -
    SQL PowerShell: July 2016 update

    Sue

  • Sue_H - Thursday, December 21, 2017 9:25 AM

    Lynn Pettis - Thursday, December 21, 2017 9:17 AM

    Aaron Nelson - @SQLvariant - Thursday, December 21, 2017 4:54 AM

    The SQLPS module has been abandoned and there will not be future development of it.  It is best to point people to the much better SqlServer module: https://www.powershellgallery.com/packages/SqlServer/

    References to SQLPS being abandoned please.

    Microsoft has some information on the changes with the modules -
    SQL PowerShell: July 2016 update

    Sue

    Thank you for the reference.
    I just read the first couple of paragraphs so this is good to know as I start down the PowerShell learning path that I should have been going down for the past several years.

  • Lynn Pettis - Thursday, December 21, 2017 9:37 AM

    Thank you for the reference.
    I just read the first couple of paragraphs so this is good to know as I start down the PowerShell learning path that I should have been going down for the past several years.

    It's actually kind of fun sometimes and a lot of the companies that won't enable xp_cmdshell are okay with Powershell.
    But that change has been a pain - if you find some samples, scripts online you really need to look at which one they are using. This is the link I originally found on it - it has additional links. Has some info on having both loaded - it doesn't work too well and that's how I found this one.
    Out With The SQLPS, In With The SqlServer

    Sue

  • What a nice tutorial, just what I was looking for, but.  Can someone please explain this example to me? I understand what the code is trying to do, but when I run it it comes up with the continuation marker and expects me to finish, so:

    [string] $empty[string] $notempty = "qwert"if(!$empty){  Write-Host '$empty is' "Empty"}if($notempty){  Write-Host '$notempty is' "Not Empty"}

    Result is:

    PS C:\Users\Me> [string] $empty
    PS C:\Users\RMe> [string] $notempty = "qwert"
    PS C:\Users\RMe> if(!$empty)
    >> {
    >>  Write-Host '$empty is' "Empty"
    >> }
    >> if($notempty)
    >> {
    >>  Write-Host '$notempty is' "Not Empty"
    >> }

    How do I end this tiny batch?

    Thanks,
    Richard

  • Wow ... HUGE tutorial.  Thank you!!  I haven't read through it yet but it looks great at first glance.  PowerShell is on my radar for 2018 as I don't want to be left behind.  I know, I know, I've already been left behind.  Better late than never?  😀

  • Lynn Pettis - Thursday, December 21, 2017 9:37 AM

    ...this is good to know as I start down the PowerShell learning path that I should have been going down for the past several years.

    Oh thank goodness!  I thought I was the last to embark on this journey.  Good to know I'm not the only one.  🙂

    Edit: Spelling

  • thisisfutile - Friday, December 22, 2017 9:34 AM

    Lynn Pettis - Thursday, December 21, 2017 9:37 AM

    ...this is good to know as I start down the PowerShell learning path that I should have been going down for the past several years.

    Oh thank goodness!  I thought I was the last to embark on this journey.  Good to know I'm not the only one.  🙂

    Edit: Spelling

    Sigh......I have only just started as well.....

  • Lynn Pettis - Thursday, December 21, 2017 9:37 AM

    Sue_H - Thursday, December 21, 2017 9:25 AM

    Lynn Pettis - Thursday, December 21, 2017 9:17 AM

    Aaron Nelson - @SQLvariant - Thursday, December 21, 2017 4:54 AM

    The SQLPS module has been abandoned and there will not be future development of it.  It is best to point people to the much better SqlServer module: https://www.powershellgallery.com/packages/SqlServer/

    References to SQLPS being abandoned please.

    Microsoft has some information on the changes with the modules -
    SQL PowerShell: July 2016 update

    Sue

    Thank you for the reference.
    I just read the first couple of paragraphs so this is good to know as I start down the PowerShell learning path that I should have been going down for the past several years.

    Heh... I can't wait for them to abandon the SQLServer Module for something "better" in the coming years.  Why is it that they always do a "replace" instead of the needed "fix the current mess" so that people don't have to go back and change all the code they wrote when someone told them that SQLPS was "the best way to go". 

    Hmmm.... they're overdue... I wonder when they're going to throw SSIS on the floor and replace it with something else like the old DTS was.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • richlion2 - Friday, December 22, 2017 2:21 AM

    What a nice tutorial, just what I was looking for, but.  Can someone please explain this example to me? I understand what the code is trying to do, but when I run it it comes up with the continuation marker and expects me to finish, so:

    [string] $empty[string] $notempty = "qwert"if(!$empty){  Write-Host '$empty is' "Empty"}if($notempty){  Write-Host '$notempty is' "Not Empty"}

    Result is:

    PS C:\Users\Me> [string] $empty
    PS C:\Users\RMe> [string] $notempty = "qwert"
    PS C:\Users\RMe> if(!$empty)
    >> {
    >>  Write-Host '$empty is' "Empty"
    >> }
    >> if($notempty)
    >> {
    >>  Write-Host '$notempty is' "Not Empty"
    >> }

    How do I end this tiny batch?

    Thanks,
    Richard

    I apologize for a possible confusion - it was supposed to be 4 lines, not one. You simply need to copy them into ISE new window:
    [string] $empty
    [string] $notempty = "qwert"
    if(!$empty){ Write-Host '$empty is' "Empty"}
    if($notempty){ Write-Host '$notempty is' "Not Empty"}
    In ISE on the menu stripe leftmost button - click it and it will open a new window for you. Paste the snippet and it should be fine.

  • Hmmm.... they're overdue... I wonder when they're going to throw SSIS on the floor and replace it with something else like the old DTS was. 


    Both of them (I mean SSIS and DTS) are quite awful IMO 🙂

  • Alex Chamchourine - Friday, December 29, 2017 11:48 AM

    Hmmm.... they're overdue... I wonder when they're going to throw SSIS on the floor and replace it with something else like the old DTS was. 


    Both of them (I mean SSIS and DTS) are quite awful IMO 🙂

    I share that same opinion.  Heh... my little bit of "expertise" in both DTS and SSIS came from learning how to read the packages well enough to replace them with stored procedures.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 15 posts - 1 through 15 (of 38 total)

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