Public/Get-P1Packages.ps1

function Get-P1Packages {
    <#
    .Synopsis
    Get all required packages from PlannerOne NuGet server.
 
    .Description
    Connect to remote repository and get the latest release.
     
    .Parameter PlannerOneVersion
    The PlannerOne version to install (ex: 5.0).
 
    .Parameter NAVVersion
    The Dynamics NAV version (ex: 2016).
 
    #>

    [cmdletbinding()]
    param( 
        [string] $PlannerOneVersion,
        [string] $NAVVersion
    )    
    Process {

        # Add PlannerOne NuGet server to package sources
        #Register-PackageSource -Name plannerone -Provider NuGet -Trusted -Location $SourceURL
        
        if (Get-Command Install-Package -errorAction SilentlyContinue)
        {
            Write-Output "Install-Package exists"
                        
            Install-Package $P1SrvPackage -Source $SourceURL
            
            Install-Package $P1WebPackage -Source $SourceURL
        } else {
            Write-Output "Install-Package doesn't exist, using NuGet"
            $packagePath = Get-ServicePath
            
            NuGet install $P1SrvPackage -Source $SourceURL -OutputDirectory $packagePath
            
            NuGet install $P1WebPackage -Source $SourceURL -OutputDirectory $packagePath
        }
    }
}