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
        $getVal = $false

        foreach($modRepo in $ENV:PSModulePath.split(";"))
        {
            if($modRepo.Contains($HOME)){
                $getVal = $true
                break
            }
        }

        if(! $getVal){
           Write-Verbose "No PSModule folder for this user. "
           $modRepo = $ENV:PSModulePath.split(";")[0]
        }

        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.."
}