Skip to content

How To

Setting up the Entrinsec nuget as a source.

Using nuget

Ensure you have nuget installed. nuget.org is the recommended install source.

Note : nuget has some nuances as to how it installs modules and how they are imported.

Setup the Entrinsec nuget repository

Clear-Host

# Your user module path
$modulePath = "C:\Powershell\Entrinsec"
Set-Location -Path "$modulePath"

# Check if Entrinsec source exists and remove it if it does
$sourceName = "Entrinsec"
$existingSource = nuget sources list | Select-String -Pattern $sourceName

if ($existingSource) {
    nuget sources remove -name $sourceName
}

# Add Entrinsec as a nuget source
Clear-Host

nuget sources add -name $sourceName -source "https://nuget.entrinsec.com/api/packages/Entrinsec/nuget/index.json"

# List all nuget sources
nuget sources list
You should see the following
Registered Sources:
    1.  nuget.org [Enabled]
        https://api.nuget.org/v3/index.json
    2.  Entrinsec [Enabled]
        https://nuget.entrinsec.com/api/packages/Entrinsec/nuget/index.json

Installing from Entrinsec nuget Machine Wide for PowerShell

1
2
3
4
5
6
7
8
Clear-Host

# As an administrator...
# This will install machine wide so that modules and functions are automatically visible to PowerShell
nuget.exe install Entrinsec.Powershell.Common -Source "Entrinsec" -OutputDirectory "C:\Program Files\PowerShell\Modules" -ExcludeVersion

# Run a test with...
Test-Admin

OPTIONAL

If you cannot install to a global Powershell location then you can install as a user to any location but an Import-Module may be required.

Installing from Entrinsec nuget as a User

Clear-Host

# Ensure you are in the directory that you are installing the modules into
$modulePath = pwd # Set it to the current directory, if required

# Install the core set of Entrinsec components, which have requirements on each other
Set-Location -Path "$modulePath" # For example "C:\Powershell\Entrinsec"

nuget install Entrinsec.Powershell.Common -Source "Entrinsec" -ExcludeVersion

# Importing modules in Powershell scripts
$fullModuleName = Join-Path -Path $modulePath -ChildPath  "Entrinsec.Powershell.Common\Entrinsec.Powershell.Common.psd1"
Import-Module $fullModuleName -Force

# Run a test with...
Show-ToastNotification -Title "My Title"  -Information "My First Toast !"

Importing Entrinsec nuget Modules in Powershell

Assuming you have downloaded one or more modules into your user profile PowerShell Modules folder...

Clear-Host

# Set-Location into the folder where the nuget packages were installed to 

# Removing
Remove-Module "Entrinsec.Powershell.Common"

# Importing in a specific order due to Entrinsec dependancies
Import-Module ".\Entrinsec.Powershell.Common.1.0.0\Entrinsec.Powershell.Common.psd1"

# or just provide full paths instead of ".\..."

# Run a test with...
Test-Admin