Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rvrsh3ll/78739132045f7a58a6428830f44cdec4 to your computer and use it in GitHub Desktop.

Select an option

Save rvrsh3ll/78739132045f7a58a6428830f44cdec4 to your computer and use it in GitHub Desktop.

Revisions

  1. @gwalkey gwalkey revised this gist Apr 15, 2020. No changes.
  2. @gwalkey gwalkey revised this gist Apr 13, 2020. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -41,12 +41,8 @@ Install-Package MyModuleName
    -- Check Nuget Package Version After Installation
    get-package | where-object {$_.name -match 'MyModuleName'}

    --- Install Modules and Check Status
    Install-Module MyModuleName -Repository Local_Nuget_Feed
    Get-Module -ListAvailable -Name MyModuleName

    --- Test Loading/Calling a Function from your PS Module
    LoadSQLSMO
    MyFunction

    --- List all functions in your PSM1 module
    Get-Command -Module MyModuleName
  3. @gwalkey gwalkey revised this gist Apr 13, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    Download the CLI Version of NuGet
    https://dist.nuget.org/win-x86-commandline/latest/nuget.exe

    --Create Work Paths
    md c:\nuget
    md c:\nuget\source
  4. @gwalkey gwalkey created this gist Apr 13, 2020.
    52 changes: 52 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    --Create Work Paths
    md c:\nuget
    md c:\nuget\source
    md c:\nuget\publish

    -- One-Time - Create local NuGet Repo/feed using a local drive path
    cd c:\nuget
    Register-PSRepository -Name Local_Nuget_Feed -SourceLocation C:\Nuget\publish -PublishLocation c:\Nuget\publish -InstallationPolicy Trusted
    (To Remove: Unregister-PSRepository -Name Local_Nuget_Feed)

    --- Verift/Show all PS Repository
    Get-PSRepository

    -- Create Prep folder for your New NuGet Package
    cd c:\nuget\source
    md MyModuleName
    Copy MyModuleName.PSD1 and MyModuleName.PSM1 files from your dev location to here (c:\nuget\source\MyModuleName)

    -- Edit your Powershell Module Manifest .psd1 File
    Set the RootModule to the name of your Module.psm1 file
    Set the ModuleVersion

    --- Create and Install your Powershell Module as a NuGet Package ans save into the Nuget Package Repo/Feed
    cd c:\nuget\source
    Publish-Module -Path .\MyModuleName -Repository Local_Nuget_Feed -NuGetApiKey 'ABC123'
    (The .nupkg file is created here: c:\nuget\publish)

    -- List Packages in Repository
    nuget list -source c:\nuget\publish

    -- Delete Package
    nuget delete MyModuleName 1.0.3 -source c:\nuget\publish

    --- Install your Powershell module from the .nupkg file you just created
    --- In an Elevated Powershell console:
    Install-Package MyModuleName

    -- Check Nuget Package Version After Installation
    get-package | where-object {$_.name -match 'MyModuleName'}

    --- Install Modules and Check Status
    Install-Module MyModuleName -Repository Local_Nuget_Feed
    Get-Module -ListAvailable -Name MyModuleName

    --- Test Loading/Calling a Function from your PS Module
    LoadSQLSMO

    --- List all functions in your PSM1 module
    Get-Command -Module MyModuleName

    --- Verify the correct version of your module and manifest files were installed in the Global Modules Folder here:
    C:\Program Files\WindowsPowerShell\Modules\MyModuleName