Stairway to SQL PowerShell Level 6: PowerShell Modules

  • 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

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

  • 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

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

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

  • Thanks. I will have that fixed.



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

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

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