Stairway to SQL PowerShell Level 6: PowerShell Modules

  • Ben Miller

    SSCrazy

    Points: 2964

    Comments posted to this topic are about the item Stairway to SQL PowerShell Level 6: PowerShell Modules



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • rstelma

    SSC Enthusiast

    Points: 187

    In this article you say:

    Listing 6.3 Creating a file that will be used with dot-sourcing

    Dot-sourcing simply means to use a period and then a space followed by the name of a .ps1 file to load in.

    OK... Here's what I'm reading. (a dot, followed by a space, then the name of a file)

    . FirstPowerShell.ps1

    Is that what you mean? Somehow I don't think I'm understanding this correctly.

  • Ben Miller

    SSCrazy

    Points: 2964

    I simply mean that when you think of a module you will use Import-Module modulename.

    With dot-sourcing, it is simply a .ps1 file somewhere that has a function in it or code that you want run without typing it in.

    So it is a . PathTo.ps1

    dot space FullPath (unless it is in the same directory, then it is a ./file.ps1 for the path)

    Does that help?



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

  • rstelma

    SSC Enthusiast

    Points: 187

    Yes... that helps. Thank you for confirming. It just sounded odd to me having a file that is dot, space, [name]ps1

  • quicknclever

    SSC Rookie

    Points: 27

    Listing 6.1 contains a bug.

    if($Username -and $Password)

    { $con = new-object ("Microsoft.SqlServer.Management.Common.ServerConnection") $sqlserver,$username,$password }

    else

    { $connection = new-object ("Microsoft.SqlServer.Management.Common.ServerConnection") $sqlserver }

    The $con variable is never used and should be changed to $connection.

  • Ben Miller

    SSCrazy

    Points: 2964

    Thanks. I will have that fixed.



    Ben Miller
    Microsoft Certified Master: SQL Server, SQL MVP
    @DBAduck - http://dbaduck.com

Viewing 6 posts - 1 through 6 (of 6 total)

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