functions/common/Import-BcManagement.ps1
function Import-BcManagement { [CmdletBinding()] param ( [Parameter()] [int]$MajorVersion ) if ($BcInstallationProperty = Get-BcInstallationProperty -MajorVersion $MajorVersion -Component Service) { $BcManagementPath = (Join-Path $BcInstallationProperty.Path 'Management') $MicrosoftDynamicsNavManagementFilePath = (Join-Path $BcManagementPath 'Microsoft.Dynamics.Nav.Management.dll') if (Test-Path -Path $MicrosoftDynamicsNavManagementFilePath -PathType Leaf) { Write-Information 'Import Microsoft.Dynamics.Nav.Management.dll' Write-Information $MicrosoftDynamicsNavManagementFilePath Import-Module "$($MicrosoftDynamicsNavManagementFilePath)" -NoClobber Write-Output "$($MicrosoftDynamicsNavManagementFilePath)" } else { Write-Warning 'Business Central Service Management Module not found (not installed?)' } } else { Write-Warning 'BcInstallationProperty not found (not installed?)' } if ($BcInstallationProperty = Get-BcInstallationProperty -MajorVersion $MajorVersion -Component WebClient) { $NAVWebClientManagementPath = (Join-Path $BcInstallationProperty.Path 'Modules\NAVWebClientManagement') $NAVWebClientManagementFilePath = (Join-Path $NAVWebClientManagementPath 'NAVWebClientManagement.psm1') if (Test-Path -Path $NAVWebClientManagementFilePath -PathType Leaf) { Write-Information 'Import NAVWebClientManagement.psm1' Write-Information $NAVWebClientManagementFilePath Import-Module "$($NAVWebClientManagementFilePath)" Write-Output "$($NAVWebClientManagementFilePath)" } else { Write-Warning 'Business Central Web Client Management Module not found (not installed?)' } } else { Write-Warning 'BcInstallationProperty not found (not installed?)' } } |