Public/Import-P1NavTool.ps1

function Import-P1NavTool{
    <#
    .Synopsis
    Import in local environnement the powershell module PlannerOne.NavTool.
 
    .Description
    Get the module from local package.
 
    .Parameter Version
    Dynamics NAV version.
    #>
<#
    param(
        [Parameter(Mandatory=$True)] [string] $Version
    )
        $ModuleName = Get-Version $P1NavToolPackage $Version
        $path = Get-PackageFolder $ModuleName
     
        $modRepo = "$env:SystemDrive\Program Files\WindowsPowerShell\Modules"
        Copy-item "$path\PlannerOne.NavTool\" "$modRepo" -recurse -Force
        Write-host "copy $path in $modRepo"
         
 
        Import-module "PlannerOne.NavTool" -force
        Write-OK "Import Module PlannerOne.NavTool done.."
    Dynamics NAV version.
    #>

    param(
        [Parameter(Mandatory=$True)] [string]   $Version
    )
        $ModuleName = Get-Version $P1NavToolPackage $Version
        $path = Get-PackageFolder $ModuleName

        foreach($modRepo in $ENV:PSModulePath.split(";"))
        {
            if((! $modRepo.Contains("User")) -and ($modRepo.Contains("WindowsPowerShell\v1.0\Modules") )){
                Copy-item "$path\PlannerOne.NavTool\" "$modRepo" -recurse -force
                Write-host "copy $path in $modRepo"
            }
        }

        Import-module "PlannerOne.NavTool" -force
        Write-OK "Import Module PlannerOne.NavTool done.."
}