Patch/Cmdlets/NAV/Import-NavModule.ps1
function Import-NavModule { param ( [switch]$Service, [switch]$Development ) $RegistryBasePath = "HKLM:\SOFTWARE\{0}\Microsoft\Microsoft Dynamics NAV\140\{1}" if ($Service) { if (-not (Get-Module Microsoft.Dynamics.Nav.Apps.Management)) { $ModulePath = Get-ItemProperty -Path ($RegistryBasePath -f "", 'Service') -Name "Path" Import-Module (Join-Path $ModulePath.Path, 'NavAdminTool.ps1') -Force -Verbose:$false -WarningAction "SilentlyContinue" *>$null Write-Verbose "Microsoft.Dynamics.Nav.Apps.Management loaded from path $ModulePath" } } if ($Development) { if (-not (Get-Module Microsoft.Dynamics.Nav.Model.Tools)) { if ([Environment]::Is64BitProcess) { $Wow6432Node = "Wow6432Node" } $ModulePath = Get-ItemProperty -Path ($RegistryBasePath -f $Wow6432Node, 'RoleTailored Client') -Name "Path" Import-Module (Join-Path $ModulePath, 'Microsoft.Dynamics.Nav.Model.Tools.psd1') -Force -Verbose:$false -WarningAction "SilentlyContinue" -ErrorAction Stop | Out-Null Write-Verbose "Microsoft.Dynamics.Nav.Model.Tools loaded from path $ModulePath" } } } Export-ModuleMember -Function Import-NavModule |