Public/Install-P1Package.ps1

function Install-P1Package {
    <#
    .Synopsis
    Get all required packages from PlannerOne NuGet server.
 
    .Description
    Connect to remote repository and get the latest release.
     
    .Parameter Package
    The PlannerOne package list.
 
    .Example
    # Install PlannerOne server, web and NAV 2016 objects
    Install-P1Package PlannerOne.Server,PlannerOne.WebApp,PlannerOne.NAV2016Objects
    #>

    [cmdletbinding()]
    param( 
    [Parameter(Mandatory=$true)]
        [string[]] $Package
    )    
    Process {
        $feedUrl = Get-FeedUrl
        if ($feedUrl -eq "") {
            return
        } else {
            Register-PackageSource -Name PlannerOne -Trusted -ProviderName NuGet -Location $feedUrl
        }

        if ($null -eq $Package) {
            Write-Output "No package specified"
            Write-Section "Run Get-P1Packages to get a list of PlannerOne packages"
            return
        }
        
        Write-Section "Getting PlannerOne packages..."

        if (Get-Command Install-Package -errorAction SilentlyContinue)
        {
            Write-Verbose "Install-Package exists"
            foreach($Pack in $Package) {
                Write-Output "Installing $Pack..."
                Install-Package $Pack -Source $feedUrl
                $Folder = Get-PackageFolder $Pack
                Write-OK "Package installed in $Folder"
            }
        } else {
            Write-Output "Install-Package doesn't exist, using NuGet"

            foreach($Pack in $Package) {
                Write-Output "Installing $Pack..."
                NuGet install $Pack -Source $feedUrl
            }
        }

    Write-OK "Packages installed"
    }
}