rebrand + support usedevendpoint

This commit is contained in:
Freddy Kristiansen 2019-06-06 13:29:45 +02:00
Родитель 8df4429160
Коммит 96175c3151
73 изменённых файлов: 670 добавлений и 396 удалений

Просмотреть файл

@ -1,13 +1,13 @@
<#
.Synopsis
Use Nav Container to Compile App
Use NAV/BC Container to Compile App
.Description
.Parameter containerName
Name of the container which you want to use to compile the app
.Parameter tenant
tenant to use if container is multitenant
.Parameter credential
Credentials of the NAV SUPER user if using NavUserPassword authentication
Credentials of the SUPER user if using NavUserPassword authentication
.Parameter appProjectFolder
Location of the project. This folder (or any of its parents) needs to be shared with the container.
.Parameter appOutputFolder

Просмотреть файл

@ -0,0 +1,69 @@
<#
.Synopsis
Extract the content of an App File to a Folder
.Description
.Parameter AppFile
Path of the appFile
.Parameter AppFolder
Path of the folder in which the appFile will be unpacked. If this folder exists, the content will be deleted. Default is $appFile.source.
.Example
Extract-AppFileToFolder -appFile c:\temp\baseapp.app
#>
function Extract-AppFileToFolder {
Param(
[string] $appFilename,
[string] $appFolder = "$($appFilename).source"
)
if ("$appFolder" -eq "$hostHelperFolder" -or "$appFolder" -eq "$hostHelperFolder\") {
throw "The folder specified in ObjectsFolder will be erased, you cannot specify $hostHelperFolder"
}
if (Test-Path $appFolder -PathType Container) {
Get-ChildItem -Path $appFolder -Include * | Remove-Item -Recurse -Force
} else {
New-Item -Path $appFolder -ItemType Directory -Force -ErrorAction Ignore | Out-Null
}
try {
$filestream = [System.IO.File]::OpenRead($appFileName)
$binaryReader = [System.IO.BinaryReader]::new($filestream)
$magicNumber1 = $binaryReader.ReadUInt32()
$metadataSize = $binaryReader.ReadUInt32()
$metadataVersion = $binaryReader.ReadUInt32()
$packageId = [Guid]::new($binaryReader.ReadBytes(16))
$contentLength = $binaryReader.ReadInt64()
$magicNumber2 = $binaryReader.ReadUInt32()
if ($magicNumber1 -ne 0x5856414E -or
$magicNumber2 -ne 0x5856414E -or
$metadataVersion -gt 2 -or
$filestream.Position + $contentLength -gt $filestream.Length)
{
throw "Unsupported package format"
}
Add-Type -Assembly System.IO.Compression
Add-Type -Assembly System.IO.Compression.FileSystem
$content = $binaryReader.ReadBytes($contentLength)
$memoryStream = [System.IO.MemoryStream]::new($content)
$zipArchive = [System.IO.Compression.ZipArchive]::new($memoryStream, [System.IO.Compression.ZipArchiveMode]::Read)
$prevdir = ""
$zipArchive.Entries | ForEach-Object {
$fullname = Join-Path $appFolder $_.FullName
$dir = [System.IO.Path]::GetDirectoryName($fullname)
if ($dir -ne $prevdir) {
if (-not (Test-Path $dir -PathType Container)) {
New-Item -Path $dir -ItemType Directory | Out-Null
}
}
$prevdir = $dir
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $fullname)
}
}
finally {
$binaryReader.Close()
$filestream.Close()
}
}
Export-ModuleMember -Function Extract-AppFileToFolder

Просмотреть файл

@ -0,0 +1,112 @@
<#
.Synopsis
Download App from NAV/BC Container
.Description
.Parameter containerName
Name of the container which you want to use to compile the app
.Parameter publisher
Publisher of the app you want to download
.Parameter appName
Name of the app you want to download
.Parameter appVersion
Version of the app you want to download
.Parameter tenant
Tenant from which you want to download an app
.Parameter appFile
Path to the location where you want the app to be copied
.Parameter credential
Credentials of the SUPER user if using NavUserPassword authentication
.Example
$appFile = Get-NavContainerApp -containerName test -publisher "Microsoft" -appName "BaseApp" -appVersion "
#>
function Get-NavContainerApp {
Param(
[string] $containerName = "navserver",
[string] $publisher,
[string] $appName,
[string] $appVersion,
[Parameter(Mandatory=$false)]
[string] $Tenant = "default",
[Parameter(Mandatory=$false)]
[string] $appFile = (Join-Path $extensionsFolder "$containerName\$appName.app"),
[Parameter(Mandatory=$false)]
[PSCredential] $credential = $null
)
$startTime = [DateTime]::Now
$platform = Get-NavContainerPlatformversion -containerOrImageName $containerName
if ("$platform" -eq "") {
$platform = (Get-NavContainerNavVersion -containerOrImageName $containerName).Split('-')[0]
}
[System.Version]$platformversion = $platform
$customConfig = Get-NavContainerServerConfiguration -ContainerName $containerName
$serverInstance = $customConfig.ServerInstance
if ($customConfig.DeveloperServicesSSLEnabled -eq "true") {
$protocol = "https://"
}
else {
$protocol = "http://"
}
$ip = Get-NavContainerIpAddress -containerName $containerName
if ($ip) {
$devServerUrl = "$($protocol)$($ip):$($customConfig.DeveloperServicesPort)/$ServerInstance"
}
else {
$devServerUrl = "$($protocol)$($containerName):$($customConfig.DeveloperServicesPort)/$ServerInstance"
}
$sslVerificationDisabled = ($protocol -eq "https://")
if ($sslVerificationDisabled) {
if (-not ([System.Management.Automation.PSTypeName]"SslVerification").Type)
{
Add-Type -TypeDefinition "
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static class SslVerification
{
private static bool ValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }
public static void Disable() { System.Net.ServicePointManager.ServerCertificateValidationCallback = ValidationCallback; }
public static void Enable() { System.Net.ServicePointManager.ServerCertificateValidationCallback = null; }
}"
}
Write-Host "Disabling SSL Verification"
[SslVerification]::Disable()
}
$authParam = @{}
if ($customConfig.ClientServicesCredentialType -eq "Windows") {
$authParam += @{ "usedefaultcredential" = $true }
}
else {
if (!($credential)) {
throw "You need to specify credentials when you are not using Windows Authentication"
}
$pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$authParam += @{ "headers" = $headers }
}
Write-Host "Downloading app: $appName"
$publisher = [uri]::EscapeDataString($publisher)
$url = "$devServerUrl/dev/packages?publisher=$($publisher)&appName=$($appName)&versionText=$($appVersion)&tenant=$tenant"
Write-Host "Url : $Url"
Invoke-RestMethod -Method Get -Uri $url @AuthParam -OutFile $appFile
if ($sslverificationdisabled) {
Write-Host "Re-enabling SSL Verification"
[SslVerification]::Enable()
}
}
Set-Alias -Name Get-BCContainerApp -Value Get-NavContainerApp
Export-ModuleMember -Function Get-NavContainerApp -Alias Get-BCContainerApp

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get Nav App Info from Nav container
Get App Info from NAV/BC Container
.Description
Creates a session to the Nav container and runs the Nav CmdLet Get-NavAppInfo in the container
Creates a session to the NAV/BC Container and runs the CmdLet Get-NavAppInfo in the container
.Parameter containerName
Name of the container in which you want to enumerate apps (default navserver)
.Parameter tenant
@ -20,14 +20,13 @@
#>
function Get-NavContainerAppInfo {
Param(
[string]$containerName = "navserver",
[string]$tenant = "",
[switch]$symbolsOnly,
[switch]$tenantSpecificProperties
[string] $containerName = "navserver",
[string] $tenant = "",
[switch] $symbolsOnly,
[switch] $tenantSpecificProperties
)
$args = @{ "ServerInstance" = "NAV" }
$args = @{}
if ($symbolsOnly) {
$args += @{ "SymbolsOnly" = $true }
} else {
@ -41,7 +40,7 @@ function Get-NavContainerAppInfo {
}
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($inArgs)
Get-NavAppInfo @inArgs
Get-NavAppInfo -ServerInstance $ServerInstance @inArgs
} -ArgumentList $args
}
Set-Alias -Name Get-BCContainerAppInfo -Value Get-NavContainerAppInfo

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Download Nav App Runtime Package from Container
Download App Runtime Package from NAV/BC Container
.Description
Downloads a Nav App runtime package to a shared folder and returns the filename of the app
Downloads an App runtime package to a shared folder and returns the filename of the app
.Parameter containerName
Name of the container from which you want to download a runtime package
.Parameter appName
@ -18,14 +18,14 @@
#>
function Get-NavContainerAppRuntimePackage {
Param(
[string]$containerName = "navserver",
[string]$appName,
[string] $containerName = "navserver",
[string] $appName,
[Parameter(Mandatory=$false)]
[string]$appVersion,
[string] $appVersion,
[Parameter(Mandatory=$false)]
[string]$Tenant,
[string] $Tenant,
[Parameter(Mandatory=$false)]
[string]$appFile = (Join-Path $extensionsFolder "$containerName\$appName.app")
[string] $appFile = (Join-Path $extensionsFolder "$containerName\$appName.app")
)
$containerAppFile = Get-NavContainerPath -containerName $containerName -path $appFile
@ -36,7 +36,7 @@ function Get-NavContainerAppRuntimePackage {
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion, $tenant, $appFile)
$parameters = @{
"ServerInstance" = "NAV"
"ServerInstance" = $ServerInstance
"Name" = $appName
"Path" = $appFile
}

Просмотреть файл

@ -1,13 +1,13 @@
<#
.Synopsis
Get test information from a container
Get test information from a NAV/BC Container
.Description
.Parameter containerName
Name of the container from which you want to get test information
.Parameter tenant
tenant to use if container is multitenant
.Parameter credential
Credentials of the NAV SUPER user if using NavUserPassword authentication
Credentials of the SUPER user if using NavUserPassword authentication
.Parameter testSuite
Name of test suite to get. Default is DEFAULT.
.Parameter testCodeunit
@ -19,12 +19,11 @@
#>
function Get-TestsFromNavContainer {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[string] $containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $tenant = "default",
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$credential = $null,
[PSCredential] $credential = $null,
[Parameter(Mandatory=$false)]
[string] $testSuite = "DEFAULT",
[Parameter(Mandatory=$false)]
@ -62,12 +61,11 @@ function Get-TestsFromNavContainer {
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
$publicWebBaseUrl = $customConfig.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Value
$ServerInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='ServerInstance']").Value
$clientServicesCredentialType = $customConfig.SelectSingleNode("//appSettings/add[@key='ClientServicesCredentialType']").Value
$idx = $publicWebBaseUrl.IndexOf('//')
$protocol = $publicWebBaseUrl.Substring(0, $idx+2)
$disableSslVerification = ($protocol -eq "https://")
$serviceUrl = "${protocol}localhost/NAV/cs?tenant=$tenant"
$serviceUrl = "$($protocol)localhost/$($ServerInstance)/cs?tenant=$tenant"
if ($clientServicesCredentialType -eq "Windows") {
$windowsUserName = whoami

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Copy the NavSip.dll Crypto Provider from a Container and install it locally
Copy the NavSip.dll Crypto Provider from a NAV/BC Container and install it locally
.Description
The NavSip crypto provider is used when signing extensions
Extensions cannot be signed inside the container, they need to be signed on the host.
@ -12,7 +12,7 @@
#>
function Install-NAVSipCryptoProviderFromNavContainer {
Param(
[string]$containerName = "navserver"
[string] $containerName = "navserver"
)
$msvcr120Path = "C:\Windows\System32\msvcr120.dll"
@ -26,7 +26,7 @@ function Install-NAVSipCryptoProviderFromNavContainer {
RegSvr32 /u /s $navSip64Path
RegSvr32 /u /s $navSip32Path
Log "Copy NAV SIP crypto provider from container $containerName"
Log "Copy SIP crypto provider from container $containerName"
Copy-FileFromNavContainer -containerName $containerName -ContainerPath $navSip64Path
Copy-FileFromNavContainer -containerName $containerName -ContainerPath $navSip32Path

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Install Nav App in Nav container
Install App in NAV/BC Container
.Description
Creates a session to the Nav container and runs the Nav CmdLet Install-NavApp in the container
Creates a session to the container and runs the CmdLet Install-NavApp in the container
.Parameter containerName
Name of the container in which you want to install the app (default navserver)
.Parameter appName
@ -13,21 +13,20 @@
function Install-NavContainerApp {
Param
(
[string] $containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string]$appName,
[string] $appName,
[Parameter()]
[string]$appVersion
[string] $appVersion
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion, $tenant)
Write-Host "Installing $appName on $tenant"
$parameters = @{
"ServerInstance" = "NAV";
"Name" = $appName;
"ServerInstance" = $ServerInstance
"Name" = $appName
"Tenant" = $tenant
}
if ($appVersion)

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Publish Nav App to a Nav container
Publish App to a NAV/BC Container
.Description
Copies the appFile to the container if necessary
Creates a session to the Nav container and runs the Nav CmdLet Publish-NavApp in the container
Creates a session to the container and runs the CmdLet Publish-NavApp in the container
.Parameter containerName
Name of the container in which you want to publish an app (default is navserver)
.Parameter appFile
@ -33,81 +33,169 @@
#>
function Publish-NavContainerApp {
Param(
[string]$containerName = "navserver",
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$appFile,
[switch]$skipVerification,
[switch]$sync,
[string] $appFile,
[switch] $skipVerification,
[switch] $sync,
[Parameter(Mandatory=$false)]
[ValidateSet('Add','Clean','Development')]
[string]$syncMode,
[switch]$install,
[string] $syncMode,
[switch] $install,
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $tenant = "default",
[ValidateSet('Extension','SymbolsOnly')]
[string]$packageType = 'Extension',
[string] $packageType = 'Extension',
[Parameter(Mandatory=$false)]
[ValidateSet('Global','Tenant')]
[string]$scope
[string] $scope,
[switch] $useDevEndpoint
)
Add-Type -AssemblyName System.Net.Http
$customconfig = Get-NavContainerServerConfiguration -ContainerName $containerName
$copied = $false
if ($appFile.ToLower().StartsWith("http://") -or $appFile.ToLower().StartsWith("https://")) {
$containerAppFile = $appFile
} else {
$containerAppFile = Get-NavContainerPath -containerName $containerName -path $appFile
if ("$containerAppFile" -eq "") {
$containerAppFile = Join-Path "c:\run" ([System.IO.Path]::GetFileName($appFile))
Copy-FileToNavContainer -containerName $containerName -localPath $appFile -containerPath $containerAppFile
$copied = $true
}
$appUrl = $appFile
$appFile = Join-Path $extensionsFolder "$containerName\my\$([System.Uri]::UnescapeDataString([System.IO.Path]::GetFileName($appUrl).split("?")[0]))"
(New-Object System.Net.WebClient).DownloadFile($appUrl, $appFile)
$copied = $true
}
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appFile, $skipVerification, $copied, $sync, $install, $tenant, $packageType, $scope, $syncMode)
$containerAppFile = Get-NavContainerPath -containerName $containerName -path $appFile
if ("$containerAppFile" -eq "") {
$containerAppFile = Join-Path "c:\run\my" ([System.IO.Path]::GetFileName($appFile))
Copy-FileToNavContainer -containerName $containerName -localPath $appFile -containerPath $containerAppFile
$copied = $true
}
if ($appFile.ToLower().StartsWith("http://") -or $appFile.ToLower().StartsWith("https://")) {
$appUrl = $appFile
$appFile = Join-Path "c:\run" ([System.Uri]::UnescapeDataString([System.IO.Path]::GetFileName($appUrl).split("?")[0]))
(New-Object System.Net.WebClient).DownloadFile($appUrl, $appFile)
$copied = $true
if ($useDevEndpoint) {
$handler = New-Object System.Net.Http.HttpClientHandler
if ($customConfig.ClientServicesCredentialType -eq "Windows") {
$handler.UseDefaultCredentials = $true
}
$publishArgs = @{ "packageType" = $packageType }
if ($scope) {
$publishArgs += @{ "Scope" = $scope }
if ($scope -eq "Tenant") {
$publishArgs += @{ "Tenant" = $tenant }
}
$HttpClient = [System.Net.Http.HttpClient]::new($handler)
if ($customConfig.ClientServicesCredentialType -eq "NavUserPassword") {
$pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$HttpClient.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Basic", $base64);
}
$HttpClient.Timeout = [System.Threading.Timeout]::InfiniteTimeSpan
$HttpClient.DefaultRequestHeaders.ExpectContinue = $false
if ($customConfig.DeveloperServicesSSLEnabled -eq "true") {
$protocol = "https://"
}
else {
$protocol = "http://"
}
Write-Host "Publishing $appFile"
Publish-NavApp -ServerInstance $ServerInstance -Path $appFile -SkipVerification:$SkipVerification @publishArgs
if ($sync -or $install) {
$appName = (Get-NAVAppInfo -Path $appFile).Name
$appVersion = (Get-NAVAppInfo -Path $appFile).Version
$syncArgs = @{}
if ($syncMode) {
$syncArgs += @{ "Mode" = $syncMode }
$ip = Get-NavContainerIpAddress -containerName $containerName
if ($ip) {
$devServerUrl = "$($protocol)$($ip):$($customConfig.DeveloperServicesPort)/$($customConfig.ServerInstance)"
}
else {
$devServerUrl = "$($protocol)$($containerName):$($customConfig.DeveloperServicesPort)/$($customConfig.ServerInstance)"
}
$sslVerificationDisabled = ($protocol -eq "https://")
if ($sslVerificationDisabled) {
if (-not ([System.Management.Automation.PSTypeName]"SslVerification").Type)
{
Add-Type -TypeDefinition "
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public static class SslVerification
{
private static bool ValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }
public static void Disable() { System.Net.ServicePointManager.ServerCertificateValidationCallback = ValidationCallback; }
public static void Enable() { System.Net.ServicePointManager.ServerCertificateValidationCallback = null; }
}"
}
Write-Host "Disabling SSL Verification"
[SslVerification]::Disable()
}
$url = "$devServerUrl/dev/apps?SchemaUpdateMode=synchronize"
if ($Scope -eq "tenant") {
$url += "&tenant=$tenant"
}
$appName = [System.IO.Path]::GetFileName($appFile)
$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$FileStream = [System.IO.FileStream]::new($appFile, [System.IO.FileMode]::Open)
try {
$fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$fileHeader.Name = "$AppName"
$fileHeader.FileName = "$appName"
$fileHeader.FileNameStar = "$appName"
$fileContent = [System.Net.Http.StreamContent]::new($FileStream)
$fileContent.Headers.ContentDisposition = $fileHeader
$multipartContent.Add($fileContent)
Write-Host "Publishing $appName to $url"
$result = $HttpClient.PostAsync($url, $multipartContent).GetAwaiter().GetResult()
if (!$result.IsSuccessStatusCode) {
throw "Status Code $($result.StatusCode) : $($result.ReasonPhrase)"
}
Write-Host -ForegroundColor Green "New Application successfully published to $containerName"
}
finally {
$FileStream.Close()
}
if ($sslverificationdisabled) {
Write-Host "Re-enablssing SSL Verification"
[SslVerification]::Enable()
}
if ($sync) {
Write-Host "Synchronizing $appName on tenant $tenant"
Sync-NavTenant -ServerInstance $ServerInstance -Tenant $tenant -Force
Sync-NavApp -ServerInstance $ServerInstance -Name $appName -Version $appVersion -Tenant $tenant @syncArgs -force -WarningAction Ignore
}
else {
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appFile, $skipVerification, $sync, $install, $tenant, $syncMode, $packageType, $scope)
$publishArgs = @{ "packageType" = $packageType }
if ($scope) {
$publishArgs += @{ "Scope" = $scope }
if ($scope -eq "Tenant") {
$publishArgs += @{ "Tenant" = $tenant }
}
}
if ($install) {
Write-Host "Installing $appName on tenant $tenant"
Install-NavApp -ServerInstance $ServerInstance -Name $appName -Version $appVersion -Tenant $tenant
}
}
Write-Host "Publishing $appFile"
Publish-NavApp -ServerInstance $ServerInstance -Path $appFile -SkipVerification:$SkipVerification @publishArgs
if ($copied) {
Remove-Item $appFile -Force
}
} -ArgumentList $containerAppFile, $skipVerification, $copied, $sync, $install, $tenant, $packageType, $scope, $syncMode
if ($sync -or $install) {
$appName = (Get-NAVAppInfo -Path $appFile).Name
$appVersion = (Get-NAVAppInfo -Path $appFile).Version
$syncArgs = @{}
if ($syncMode) {
$syncArgs += @{ "Mode" = $syncMode }
}
if ($sync) {
Write-Host "Synchronizing $appName on tenant $tenant"
Sync-NavTenant -ServerInstance $ServerInstance -Tenant $tenant -Force
Sync-NavApp -ServerInstance $ServerInstance -Name $appName -Version $appVersion -Tenant $tenant @syncArgs -force -WarningAction Ignore
}
if ($install) {
Write-Host "Installing $appName on tenant $tenant"
Install-NavApp -ServerInstance $ServerInstance -Name $appName -Version $appVersion -Tenant $tenant
}
}
} -ArgumentList $containerAppFile, $skipVerification, $sync, $install, $tenant, $syncMode, $packageType, $scope
}
if ($copied) {
Remove-Item $appFile -Force
}
Write-Host -ForegroundColor Green "App successfully published"
}
Set-Alias -Name Publish-BCContainerApp -Value Publish-NavContainerApp

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Publish an AL Application (including Base App) to a Container
Publish an AL Application (including Base App) to a NAV/BC Container
.Description
This function will replace the existing application (including base app) with a new application
The application will be deployed using developer mode (same as used by VS Code)
@ -76,7 +76,7 @@ function Publish-NewApplicationToNavContainer {
}
Write-Host "Uninstalling apps"
Get-NAVAppInfo $customConfig.ServerInstance | Uninstall-NAVApp -DoNotSaveData -WarningAction Ignore -Force
Get-NAVAppInfo $serverInstance | Uninstall-NAVApp -DoNotSaveData -WarningAction Ignore -Force
$tenant = "default"

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Repairs Nav App in a Nav container
Repairs App in a NAV/BC Container
.Description
Repairs a Business Central App by recompiling it against the current base application. Use this cmdlet if the base application has changed since publishing the Business Central App.
It is recommended that the Business Central Server instance is restarted after running the repair.
@ -15,17 +15,17 @@
#>
function Repair-NavContainerApp {
Param(
[string]$containerName = "navserver",
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$appName,
[string] $appName,
[Parameter()]
[string]$appVersion
[string] $appVersion
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion)
Write-Host "Repairing $appName"
$parameters = @{
"ServerInstance" = "NAV";
"ServerInstance" = $ServerInstance;
"Name" = $appName
}
if ($appVersion)

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Run a test suite in a container
Run a test suite in a NAV/BC Container
.Description
.Parameter containerName
Name of the container in which you want to run a test suite
@ -9,7 +9,7 @@
.Parameter companyName
company to use if container
.Parameter credential
Credentials of the NAV SUPER user if using NavUserPassword authentication
Credentials of the SUPER user if using NavUserPassword authentication
.Parameter testSuite
Name of test suite to run. Default is DEFAULT.
.Parameter testCodeunit
@ -17,7 +17,7 @@
.Parameter testFunction
Name of test function to run. Wildcards (? and *) are supported. Default is *.
.Parameter XUnitResultFileName
Credentials of the NAV SUPER user if using NavUserPassword authentication
Credentials of the SUPER user if using NavUserPassword authentication
.Parameter AzureDevOps
Generate Azure DevOps Pipeline compatible output. This setting determines the severity of errors.
.Example
@ -27,14 +27,13 @@
#>
function Run-TestsInNavContainer {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[string] $containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $tenant = "default",
[Parameter(Mandatory=$false)]
[string]$companyName = "",
[string] $companyName = "",
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$credential = $null,
[PSCredential] $credential = $null,
[Parameter(Mandatory=$false)]
[string] $testSuite = "DEFAULT",
[Parameter(Mandatory=$false)]
@ -97,12 +96,11 @@ function Run-TestsInNavContainer {
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
$publicWebBaseUrl = $customConfig.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Value
$ServerInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='ServerInstance']").Value
$clientServicesCredentialType = $customConfig.SelectSingleNode("//appSettings/add[@key='ClientServicesCredentialType']").Value
$idx = $publicWebBaseUrl.IndexOf('//')
$protocol = $publicWebBaseUrl.Substring(0, $idx+2)
$disableSslVerification = ($protocol -eq "https://")
$serviceUrl = "${protocol}localhost/NAV/cs?tenant=$tenant"
$serviceUrl = "$($protocol)localhost/$($ServerInstance)/cs?tenant=$tenant"
if ($clientServicesCredentialType -eq "Windows") {
$windowsUserName = whoami

Просмотреть файл

@ -1,10 +1,10 @@
<#
.Synopsis
Uses a Nav Container to signs a Nav App
Uses a NAV/BC Container to sign an App
.Description
appFile must be shared with the container
Copies the pfxFile to the container if necessary
Creates a session to the Nav container and Signs the App using the provided certificate and password
Creates a session to the container and Signs the App using the provided certificate and password
.Parameter containerName
Name of the container in which you want to publish an app (default is navserver)
.Parameter appFile
@ -20,11 +20,13 @@
#>
function Sign-NavContainerApp {
Param(
[string]$containerName = "navserver",
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$appFile,
[string]$pfxFile,
[SecureString]$pfxPassword
[string] $appFile,
[Parameter(Mandatory=$true)]
[string] $pfxFile,
[Parameter(Mandatory=$true)]
[SecureString] $pfxPassword
)
$containerAppFile = Get-NavContainerPath -containerName $containerName -path $appFile

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Upgrade Nav App in Nav container
Upgrade App in NAV/BC Container
.Description
Creates a session to the Nav container and runs the Nav CmdLet Start-NAVAppDataUpgrade in the container
Creates a session to the container and runs the CmdLet Start-NAVAppDataUpgrade in the container
.Parameter containerName
Name of the container in which you want to upgrade the app (default navserver)
.Parameter appName
@ -12,20 +12,19 @@
#>
function Start-NavContainerAppDataUpgrade {
Param(
[Parameter(Mandatory=$false)]
[string]$containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $containerName = "navserver",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string]$appName,
[Parameter()]
[string]$appVersion
[string] $appName,
[Parameter(Mandatory=$false)]
[string] $appVersion
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion, $tenant)
Write-Host "Upgrading app $appName"
$parameters = @{
"ServerInstance" = "NAV";
"ServerInstance" = $ServerInstance;
"Name" = $appName;
"Tenant" = $tenant
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Uninstall Nav App in Nav container
Uninstall App in NAV/BC Container
.Description
Creates a session to the Nav container and runs the Nav CmdLet Uninstall-NavApp in the container
Creates a session to the container and runs the CmdLet Uninstall-NavApp in the container
.Parameter containerName
Name of the container in which you want to uninstall the app (default navserver)
.Parameter appName
@ -18,23 +18,22 @@
#>
function UnInstall-NavContainerApp {
Param(
[string] $containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string]$appName,
[Parameter()]
[string]$appVersion,
[switch]$doNotSaveData,
[switch]$Force
[string] $appName,
[Parameter(Mandatory=$false)]
[string] $appVersion,
[switch] $doNotSaveData,
[switch] $Force
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion, $tenant, $doNotSaveData, $Force)
Write-Host "Uninstalling $appName from $tenant"
$parameters = @{
"ServerInstance" = "NAV";
"Name" = $appName;
"ServerInstance" = $ServerInstance
"Name" = $appName
"Tenant" = $tenant
}
if ($appVersion) {

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Unpublish Nav App in Nav container
Unpublish App in NAV/BC Container
.Description
Creates a session to the Nav container and runs the Nav CmdLet Unpublish-NavApp in the container
Creates a session to the container and runs the CmdLet Unpublish-NavApp in the container
.Parameter containerName
Name of the container in which you want to unpublish the app (default navserver)
.Parameter appName
@ -24,18 +24,18 @@
#>
function UnPublish-NavContainerApp {
Param(
[string]$containerName = "navserver",
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$appName,
[switch]$unInstall,
[switch]$doNotSaveData,
[switch]$force,
[string] $appName,
[switch] $unInstall,
[switch] $doNotSaveData,
[switch] $force,
[Parameter(Mandatory=$false)]
[string]$publisher,
[string] $publisher,
[Parameter(Mandatory=$false)]
[Version]$version,
[Version] $version,
[Parameter(Mandatory=$false)]
[string]$tenant = "default"
[string] $tenant = "default"
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $unInstall, $tenant, $publisher, $version, $doNotSaveData, $force)

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Create Apps in Azure Active Directory to allow Single Signon with NAV using AAD
Create Apps in Azure Active Directory to allow Single Signon when using AAD
.Description
This function will create an app in AAD, to allow NAV Web and Windows Client to use AAD for authentication
This function will create an app in AAD, to allow Web and Windows Client to use AAD for authentication
Optionally the function can also create apps for the Excel AddIn and/or PowerBI integration
.Parameter AadAdminCredential
Credentials for your AAD/Office 365 administrator user, who can create apps in the AAD
@ -17,22 +17,22 @@
.Parameter IncludePowerBiAadApp
Add this switch to request the function to also create an AAD app for the PowerBI service
.Example
Create-AadAppsForNAV -AadAdminCredential (Get-Credential) -appIdUri https://mycontainer/nav/
Create-AadAppsForNAV -AadAdminCredential (Get-Credential) -appIdUri https://mycontainer/bc/
#>
function Create-AadAppsForNav
{
Param
(
[Parameter(Mandatory=$true)]
[System.Management.Automation.PSCredential]$AadAdminCredential,
[PSCredential] $AadAdminCredential,
[Parameter(Mandatory=$true)]
[string]$appIdUri,
[string] $appIdUri,
[Parameter(Mandatory=$false)]
[string]$publicWebBaseUrl = $appIdUri,
[string] $publicWebBaseUrl = $appIdUri,
[Parameter(Mandatory=$false)]
[string]$iconPath,
[switch]$IncludeExcelAadApp,
[switch]$IncludePowerBiAadApp
[string] $iconPath,
[switch] $IncludeExcelAadApp,
[switch] $IncludePowerBiAadApp
)
function Create-AesKey {
@ -79,7 +79,7 @@ function Create-AadAppsForNav
$AdProperties["SsoAdAppKeyValue"] = $SsoAdAppKeyValue
Write-Host "Creating AAD App for WebClient"
$ssoAdApp = New-AzureADApplication -DisplayName "NAV WebClient for $appIdUri" `
$ssoAdApp = New-AzureADApplication -DisplayName "WebClient for $appIdUri" `
-Homepage $publicWebBaseUrl `
-IdentifierUris $appIdUri `
-ReplyUrls @($publicWebBaseUrl, ($publicWebBaseUrl.ToLowerInvariant()+"SignIn"))

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Enumerate users in AAD and create them in NAV Container
Enumerate users in AAD and create them in NAV/BC Container
.Description
This function will create an app in AAD, to allow NAV Web and Windows Client to use AAD for authentication
This function will create an app in AAD, to allow Web and Windows Client to use AAD for authentication
Optionally the function can also create apps for the Excel AddIn and/or PowerBI integration
.Parameter containerName
Name of the container in which you want to create the users (default navserver)
@ -23,18 +23,13 @@ function Create-AadUsersInNavContainer
{
Param
(
[Parameter(Mandatory=$false)]
[string]$containerName = "navserver",
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[string] $containerName = "navserver",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[System.Management.Automation.PSCredential]$AadAdminCredential,
[parameter(Mandatory=$false)]
[bool]$ChangePasswordAtNextLogOn = $true,
[Parameter(Mandatory=$false)]
[string]$permissionSetId = "SUPER",
[Parameter(Mandatory=$false)]
[Securestring]$securePassword = $AadAdminCredential.Password
[PSCredential] $AadAdminCredential,
[bool] $ChangePasswordAtNextLogOn = $true,
[string] $permissionSetId = "SUPER",
[Securestring] $securePassword = $AadAdminCredential.Password
)
if (!(Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction Ignore)) {

Просмотреть файл

@ -9,9 +9,9 @@
.Parameter alwaysPull
Include this switch if you want to make sure that you pull latest version of the docker image
.Example
Replace-NavServerContainer -imageName microsoft/dynamics-nav:devpreview-december-finus
Replace-NavServerContainer -imageName mcr.microsoft.com/dynamicsnav:2018
.Example
Replace-NavServerContainer -imageName microsoft/dynamics-nav:devpreview-december-finus -alwaysPull
Replace-NavServerContainer -imageName mcr.microsoft.com/businesscentral/onprem:w1 -alwaysPull
.Example
Replace-NavServerContainer
#>
@ -28,7 +28,7 @@ function Replace-NavServerContainer {
$settingsScript = "C:\DEMO\settings.ps1"
if (!((Test-Path $SetupNavContainerScript) -and (Test-Path $setupDesktopScript) -and (Test-Path $settingsScript))) {
throw "The Replace-NavServerContainer is designed to work inside the Nav on Azure DEMO VMs"
throw "The Replace-NavServerContainer is designed to work inside the ARM template VMs created by (ex. http://aka.ms/getbc)"
}
if ($enableSymbolLoading -ne "Default") {
@ -54,7 +54,7 @@ function Replace-NavServerContainer {
docker pull $imageName
}
Write-Host -ForegroundColor Green "Setup new Nav container"
Write-Host -ForegroundColor Green "Setup new Container"
. $SetupNavContainerScript
. $setupDesktopScript
}

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Backup databases in a Nav container as .bak files
Backup databases in a NAV/BC Container as .bak files
.Description
If the Nav Container is multi-tenant, this command will create an app.bak and a tenant.bak (or multiple tenant.bak files)
If the Nav Container is single-tenant, this command will create one .bak file called database.bak.
If the Container is multi-tenant, this command will create an app.bak and a tenant.bak (or multiple tenant.bak files)
If the Container is single-tenant, this command will create one .bak file called database.bak.
.Parameter containerName
Name of the container for which you want to export and convert objects
.Parameter sqlCredential
@ -26,14 +26,10 @@
#>
function Backup-NavContainerDatabases {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$sqlCredential = $null,
[Parameter(Mandatory=$false)]
[string]$bakFolder = "",
[Parameter(Mandatory=$false)]
[string[]]$tenant = @("tenant")
[string] $containerName = "navserver",
[PSCredential] $sqlCredential = $null,
[string] $bakFolder = "",
[string[]] $tenant = @("tenant")
)
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Export databases in a Nav container as .bacpac files
Export databases in a NAV/BC Container as .bacpac files
.Description
If the Nav Container is multi-tenant, this command will create an app.bacpac and a tenant.bacpac.
If the Nav Container is single-tenant, this command will create one bacpac file called database.bacpac.
If the Container is multi-tenant, this command will create an app.bacpac and a tenant.bacpac.
If the Container is single-tenant, this command will create one bacpac file called database.bacpac.
.Parameter containerName
Name of the container for which you want to export and convert objects
.Parameter sqlCredential
@ -31,19 +31,13 @@
#>
function Export-NavContainerDatabasesAsBacpac {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$sqlCredential = $null,
[Parameter(Mandatory=$false)]
[string]$bacpacFolder = "",
[Parameter(Mandatory=$false)]
[string[]]$tenant = @("tenant"),
[Parameter(Mandatory=$false)]
[int]$commandTimeout = 3600,
[switch]$diagnostics,
[Parameter(Mandatory=$false)]
[string[]]$additionalArguments = @()
[string] $containerName = "navserver",
[PSCredential] $sqlCredential = $null,
[string] $bacpacFolder = "",
[string[]] $tenant = @("tenant"),
[int] $commandTimeout = 3600,
[switch] $diagnostics,
[string[]] $additionalArguments = @()
)
$genericTag = Get-NavContainerGenericTag -containerOrImageName $containerName
@ -86,7 +80,7 @@ function Export-NavContainerDatabasesAsBacpac {
function Install-DACFx
{
$sqlpakcageExe = Get-Item "C:\Program Files\Microsoft SQL Server\*\DAC\bin\sqlpackage.exe"
$sqlpakcageExe = Get-Item "C:\Program Files\Microsoft SQL Server\*\DAC\bin\sqlpackage.exe" | Sort-Object -Property FullName -Descending | Select-Object -First 1
if (!($sqlpakcageExe)) {
InstallPrerequisite -Name "Dac Framework 18.2" -MsiPath "c:\download\DacFramework.msi" -MsiUrl "https://download.microsoft.com/download/9/2/2/9228AAC2-90D1-4F48-B423-AF345296C7DD/EN/x64/DacFramework.msi" | Out-Null
$sqlpakcageExe = Get-Item "C:\Program Files\Microsoft SQL Server\*\DAC\bin\sqlpackage.exe"

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Copy company in the database
Copy company in a NAV/BC Container
.Description
Create a session to a Nav container and run Copy-NavCompany
Create a session to a container and run Copy-NavCompany
.Parameter containerName
Name of the container in which you want to create the company
.Parameter tenant
@ -16,9 +16,7 @@
#>
function Copy-CompanyInNavContainer {
Param(
[Parameter(Mandatory=$true)]
[string] $containerName,
[Parameter(Mandatory=$false)]
[string] $containerName = "navserver",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string] $sourceCompanyName,

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get a list of companies in the database
Get a list of companies in the NAV/BC Container
.Description
Create a session to a Nav container and run Get-NavCompany
Create a session to a container and run Get-NavCompany
.Parameter containerName
Name of the container in which you want to get the companies
.Parameter tenant
@ -12,10 +12,8 @@
#>
function Get-CompanyInNavContainer {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[string]$tenant = "default"
[string] $containerName = "navserver",
[string] $tenant = "default"
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($tenant)

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Create a new company in the database
Create a new company in the NAV/BC Container
.Description
Create a session to a Nav container and run New-NavCompany
Create a session to a container and run New-NavCompany
.Parameter containerName
Name of the container in which you want to create the company
.Parameter tenant
@ -16,13 +16,11 @@
#>
function New-CompanyInNavContainer {
Param(
[string] $containerName = "navserver",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[Parameter(Mandatory=$true)]
[string]$companyName,
[switch]$evaluationCompany
[string] $companyName,
[switch] $evaluationCompany
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($companyName, $evaluationCompany, $tenant)

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Remove a company from the database
Remove a company from the NAV/BC Container
.Description
Create a session to a Nav container and run Remove-NavCompany
Create a session to a container and run Remove-NavCompany
.Parameter containerName
Name of the container from which you want to remove the company
.Parameter tenant
@ -14,12 +14,10 @@
#>
function Remove-CompanyInNavContainer {
Param(
[string] $containerName = "navserver",
[string] $tenant = "default",
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[string]$tenant = "default",
[Parameter(Mandatory=$true)]
[string]$companyName
[string] $companyName
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($companyName, $tenant)

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Imports a configuration package into the application database
Imports a configuration package into the application database in a NAV/BC Container
.Description
Create a session to a Nav container and run Import-NAVConfigurationPackageFile
Create a session to a container and run Import-NAVConfigurationPackageFile
.Parameter containerName
Name of the container in which you want to import the configuration package to
.Parameter configPackageFile
@ -12,10 +12,9 @@
#>
function Import-ConfigPackageInNavContainer {
Param(
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$true)]
[string]$configPackageFile
[string] $configPackageFile
)
$containerConfigPackageFile = Get-NavContainerPath -containerName $containerName -path $configPackageFile -throw

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Removes a configuration package from the application database
Removes a configuration package from the application database in a NAV/BC Container
.Description
Create a session to a Nav container and run Remove-NAVConfigurationPackageFile
Create a session to a container and run Remove-NAVConfigurationPackageFile
.Parameter containerName
Name of the container in which you want to remove the configuration package from
.Parameter configPackageCode
@ -12,10 +12,9 @@
#>
function Remove-ConfigPackageInNavContainer {
Param(
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$true)]
[string]$configPackageCode
[string] $configPackageCode
)
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($configPackageCode)

Просмотреть файл

@ -1,10 +1,10 @@
<#
.Synopsis
Enter PowerShell session in Nav Container
Enter PowerShell session in a NAV/BC Container
.Description
Use the current PowerShell prompt to enter a PowerShell session in a Nav Container.
Use the current PowerShell prompt to enter a PowerShell session in a Container.
Especially useful in PowerShell ISE, where you after entering a session, can use PSEdit to edit files inside the container.
The PowerShell session will have the Nav PowerShell modules pre-loaded, meaning that you can use most Nav PowerShell CmdLets.
The PowerShell session will have the PowerShell modules pre-loaded, meaning that you can use most PowerShell CmdLets.
.Parameter containerName
Name of the container for which you want to enter a session
.Example
@ -15,8 +15,7 @@ function Enter-NavContainer {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[string]$containerName
[string] $containerName = "navserver"
)
Process {

Просмотреть файл

@ -1,10 +1,10 @@
<#
.Synopsis
Extract Files From NAV Container Image
Extract Files From NAV/BC Container Image
.Description
Extract all files from a NAV Container Image necessary to start a generic container with these files
Extract all files from a Container Image necessary to start a generic container with these files
.Parameter imageName
Name of the NAV Container Image from which you want to extract the files
Name of the Container Image from which you want to extract the files
.Parameter path
Location where you want the files to be placed
.Parameter extract

Просмотреть файл

@ -1,10 +1,10 @@
<#
.Synopsis
Extract Files From NAV Container
Extract Files From stopped NAV/BC Container
.Description
Extract all files from a NAV Container Image necessary to start a generic container with these files
Extract all files from a Container Image necessary to start a generic container with these files
.Parameter containerName
Name of the NAV Container from which you want to extract the files
Name of the Container from which you want to extract the files
.Parameter path
Location where you want the files to be placed
.Parameter extract

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Get Best Nav Container Image Name
Get Best NAV/BC Container Image Name
.Description
If a Container Os platform name is not specified in the imageName, find the best container os and add it (if his is a microsoft image)
.Parameter imageName
@ -13,7 +13,7 @@ function Get-BestNavContainerImageName {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$imageName
[string] $imageName
)
if (!(

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Get (or create) a PSSession for a Nav Container
Get (or create) a PSSession for a NAV/BC Container
.Description
Checks the session cache for an existing session. If a session exists, it will be reused.
If no session exists, a new session will be created.
@ -14,10 +14,8 @@ function Get-NavContainerSession {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$false)]
[switch]$silent
[string] $containerName = "navserver",
[switch] $silent
)
Process {

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Import License file to Nav container
Import License file to a NAV/BC Container
.Description
Import a license from a file or a url to a container
.Parameter containerName
@ -14,10 +14,9 @@
#>
function Import-NavContainerLicense {
Param(
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[string]$containerName,
[Parameter(Mandatory=$true)]
[string]$licenseFile
[string] $licenseFile
)
if ($licensefile.StartsWith("https://", "OrdinalIgnoreCase") -or $licensefile.StartsWith("http://", "OrdinalIgnoreCase")) {
@ -49,8 +48,8 @@ function Import-NavContainerLicense {
}
}
Write-Host "Import NAV License $licensefile"
Import-NAVServerLicense -LicenseFile $licensefile -ServerInstance 'NAV' -Database NavDatabase -WarningAction SilentlyContinue
Write-Host "Import License $licensefile"
Import-NAVServerLicense -LicenseFile $licensefile -ServerInstance $ServerInstance -Database NavDatabase -WarningAction SilentlyContinue
} -ArgumentList $containerLicenseFile
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Invoke a PowerShell scriptblock in a Nav container
Invoke a PowerShell scriptblock in a NAV/BC Container
.Description
If you are running as administrator, this function will create a session to a Nav Container and invoke a scriptblock in this session.
If you are running as administrator, this function will create a session to a Container and invoke a scriptblock in this session.
If you are not an administrator, this function will create a PowerShell script in the container and use docker exec to launch the PowerShell script in the container.
.Parameter containerName
Name of the container in which you want to invoke a PowerShell scriptblock
@ -17,8 +17,7 @@
#>
function Invoke-ScriptInNavContainer {
Param(
[Parameter(Mandatory=$true)]
[string]$containerName,
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[ScriptBlock] $scriptblock,
[Parameter(Mandatory=$false)]

Просмотреть файл

@ -1,19 +1,19 @@
<#
.Synopsis
Create or refresh a Nav container
Create or refresh a NAV/BC Container
.Description
Creates a new Nav container based on a Nav Docker Image
Creates a new Container based on a Docker Image
Adds shortcut on the desktop for Web Client and Container PowerShell prompt
.Parameter accept_eula
Switch, which you need to specify if you accept the eula for running Nav on Docker containers (See https://go.microsoft.com/fwlink/?linkid=861843)
Switch, which you need to specify if you accept the eula for running NAV or Business Central on Docker containers (See https://go.microsoft.com/fwlink/?linkid=861843)
.Parameter accept_outdated
Specify accept_outdated to ignore error when running containers which are older than 90 days
.Parameter containerName
Name of the new Nav container (if the container already exists it will be replaced)
Name of the new Container (if the container already exists it will be replaced)
.Parameter imageName
Name of the image you want to use for your Nav container (default is to grab the imagename from the navserver container)
Name of the image you want to use for your Container (default is to grab the imagename from the navserver container)
.Parameter navDvdPath
When you are spinning up a Generic image, you need to specify the NAV DVD path
When you are spinning up a Generic image, you need to specify the DVD path
.Parameter navDvdCountry
When you are spinning up a Generic image, you need to specify the country version (w1, dk, etc.) (default is w1)
.Parameter navDvdVersion
@ -23,9 +23,9 @@
.Parameter licenseFile
Path or Secure Url of the licenseFile you want to use
.Parameter credential
Username and Password for the NAV Container
Username and Password for the Container
.Parameter AuthenticationEmail
AuthenticationEmail of the admin user of NAV
AuthenticationEmail of the admin user
.Parameter memoryLimit
Memory limit for the container (default is unlimited for Windows Server host else 4G)
.Parameter isolation
@ -107,11 +107,11 @@
.Example
New-NavContainer -accept_eula -containerName test -multitenant
.Example
New-NavContainer -accept_eula -containerName test -memoryLimit 3G -imageName "microsoft/dynamics-nav:2017" -updateHosts -useBestContainerOS
New-NavContainer -accept_eula -containerName test -memoryLimit 3G -imageName "mcr.microsoft.com/dynamicsnav:2017" -updateHosts -useBestContainerOS
.Example
New-NavContainer -accept_eula -containerName test -imageName "microsoft/dynamics-nav:2017" -myScripts @("c:\temp\AdditionalSetup.ps1") -AdditionalParameters @("-v c:\hostfolder:c:\containerfolder")
New-NavContainer -accept_eula -containerName test -imageName "mcr.microsoft.com/businesscentral/onprem:dk" -myScripts @("c:\temp\AdditionalSetup.ps1") -AdditionalParameters @("-v c:\hostfolder:c:\containerfolder")
.Example
New-NavContainer -accept_eula -containerName test -credential (get-credential -credential $env:USERNAME) -licenseFile "https://www.dropbox.com/s/fhwfwjfjwhff/license.flf?dl=1" -imageName "microsoft/dynamics-nav:devpreview-finus"
New-NavContainer -accept_eula -containerName test -credential (get-credential -credential $env:USERNAME) -licenseFile "https://www.dropbox.com/s/fhwfwjfjwhff/license.flf?dl=1" -imageName "mcr.microsoft.com/businesscentral/onprem:de"
#>
function New-NavContainer {
Param(
@ -225,7 +225,7 @@ function New-NavContainer {
$hostOs = "1903"
}
$bestContainerOs = "ltsc2019"
$bestGenericContainerOs = "ltsc2019"
$bestGenericContainerOs = "1903"
} elseif ($os.BuildNumber -ge 17763) {
if ($os.BuildNumber -eq 17763) {
$hostOs = "ltsc2019"
@ -313,7 +313,7 @@ function New-NavContainer {
$imageName = $useGenericImage
}
else {
$imageName = "microsoft/dynamics-nav:generic"
$imageName = "mcr.microsoft.com/dynamicsnav:generic"
}
} elseif (Test-NavContainer -containerName navserver) {
$imageName = Get-NavContainerImageName -containerName navserver
@ -488,7 +488,7 @@ function New-NavContainer {
$devCountry = Get-NavContainerCountry -containerOrImageName $imageName
}
Write-Host "Creating Nav container $containerName"
Write-Host "Creating Container $containerName"
if ("$licenseFile" -ne "") {
Write-Host "Using license file $licenseFile"
@ -543,7 +543,7 @@ function New-NavContainer {
# There is a generic image, which is better than the selected image
Write-Host "A better Generic Container OS exists for your host ($bestGenericContainerOs)"
$useGenericImage = "microsoft/dynamics-nav:generic-$bestGenericContainerOs"
$useGenericImage = "mcr.microsoft.com/dynamicsnav:generic-$bestGenericContainerOs"
}
}
@ -638,6 +638,10 @@ function New-NavContainer {
throw "IncludeAL is supported from Dynamics 365 Business Central Spring 2019 release (1904 / 14.x)"
}
if ($includeCSide -and ($version.Major -ge 15)) {
throw "IncludeCSide is no longer supported in Dynamics 365 Business Central Fall 2019 release (1910 / 15.x)"
}
if ($multitenant -and [System.Version]$genericTag -lt [System.Version]"0.0.4.5") {
throw "Multitenancy is not supported by images with generic tag prior to 0.0.4.5"
}
@ -803,7 +807,7 @@ if ($restartingInstance -eq $false) {
$ClientUserSettingsFileName = "$runPath\ClientUserSettings.config"
[xml]$ClientUserSettings = Get-Content $clientUserSettingsFileName
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""Server""]").value = "'+$winclientServer+'"
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ServerInstance""]").value="NAV"
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ServerInstance""]").value=$ServerInstance
if ($multitenant) {
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""TenantId""]").value="$TenantId"
}
@ -900,10 +904,17 @@ Get-NavServerUser -serverInstance $ServerInstance -tenant default |? LicenseType
$customNavSettings = "PublicODataBaseUrl=$restUrl/odata,PublicSOAPBaseUrl=$soapUrl/ws,PublicWebBaseUrl=$webclientUrl"
if ($version.Major -ge 15) {
$ServerInstance = "BC"
}
else {
$ServerInstance = "NAV"
}
$webclientRule="PathPrefix:$webclientPart"
$soapRule="PathPrefix:${soapPart};ReplacePathRegex: ^${soapPart}(.*) /NAV`$1"
$restRule="PathPrefix:${restPart};ReplacePathRegex: ^${restPart}(.*) /NAV`$1"
$devRule="PathPrefix:${devPart};ReplacePathRegex: ^${devPart}(.*) /NAV`$1"
$soapRule="PathPrefix:${soapPart};ReplacePathRegex: ^${soapPart}(.*) /$ServerInstance`$1"
$restRule="PathPrefix:${restPart};ReplacePathRegex: ^${restPart}(.*) /$ServerInstance`$1"
$devRule="PathPrefix:${devPart};ReplacePathRegex: ^${devPart}(.*) /$ServerInstance`$1"
$dlRule="PathPrefixStrip:${dlPart}"
$traefikHostname = $publicDnsName.Substring(0, $publicDnsName.IndexOf("."))
@ -1143,7 +1154,7 @@ Get-NavServerUser -serverInstance $ServerInstance -tenant default |? LicenseType
} -argumentList $dotnetAssembliesFolder
}
Write-Host -ForegroundColor Green "Nav container $containerName successfully created"
Write-Host -ForegroundColor Green "Container $containerName successfully created"
if ($useTraefik) {
Write-Host -ForegroundColor Yellow "Because of Traefik, the following URLs need to be used when accessing the container from outside your Docker host:"

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Open a new PowerShell session for a Nav Container
Open a new PowerShell session for a NAV/BC Container
.Description
Opens a new PowerShell window for a Nav Container.
The PowerShell prompt will have the Nav PowerShell modules pre-loaded, meaning that you can use most Nav PowerShell CmdLets.
Opens a new PowerShell window for a Container.
The PowerShell prompt will have the PowerShell modules pre-loaded, meaning that you can use most PowerShell CmdLets.
.Parameter containerName
Name of the container for which you want to open a session
.Example
@ -13,8 +13,7 @@ function Open-NavContainer {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[string]$containerName
[string] $containerName = "navserver"
)
Process {

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Remove Nav container
Remove a NAV/BC Container
.Description
Remove container, Session, Shortcuts, temp. files and entries in the hosts file,
.Parameter containerName
@ -17,7 +17,7 @@ function Remove-NavContainer {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$containerName
[string] $containerName
)
Process {

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Remove a PSSession for a Nav Container
Remove a PSSession for a NAV/BC Container
.Description
If a session exists in the session cache, it will be removed and disposed.
Remove-NavContainer automatically removes sessions created.
@ -14,7 +14,7 @@ function Remove-NavContainerSession {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$containerName
[string] $containerName
)
Process {

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Restart Nav container
Restart a NAV/BC Container
.Description
Restart a Nav Container
Restart a Container
.Parameter containerName
Name of the container you want to restart
.Parameter renewBindings
@ -19,9 +19,9 @@ function Restart-NavContainer {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$containerName,
[switch]$renewBindings,
[int]$timeout = 1800
[string] $containerName,
[switch] $renewBindings,
[int] $timeout = 1800
)
if ($renewBindings) {

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Start Nav container
Start a NAV/BC Container
.Description
Start a Nav Container
Start a Container
.Parameter containerName
Name of the container you want to start
.Parameter timeout
@ -15,8 +15,8 @@ function Start-NavContainer {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$containerName,
[int]$timeout = 1800
[string] $containerName,
[int] $timeout = 1800
)
if (!(DockerDo -command start -imageName $containerName)) {

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Stop Nav container
Stop a NAV/BC Container
.Description
Stop a Nav Container
Stop a Container
.Parameter containerName
Name of the container you want to stop
.Example
@ -13,7 +13,7 @@ function Stop-NavContainer {
Param
(
[Parameter(Mandatory=$true, ValueFromPipeline)]
[string]$containerName
[string] $containerName
)
if (!(DockerDo -command stop -imageName $containerName)) {

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Wait for Nav container to become ready
Wait for NAV/BC Container to become ready
.Description
Wait for Nav container to log "Ready for connections!"
Wait for container to log "Ready for connections!"
If the container experiences an error, the function will throw an exception
.Parameter containerName
Name of the container for which you want to wait

Просмотреть файл

@ -1,15 +1,14 @@
<#
.Synopsis
Get the country version of Nav for a Nav container or a Nav container image
Get the country version from a NAV/BC Ccontainer or a NAV/BC Container image
.Description
Returns the country version (localization) for the version of Nav in the Nav container or Nav containerImage
Financials versions of Nav will be preceeded by 'fin', like finus, finca, fingb.
Returns the country version (localization) for the version of NAV or Business Central in the Container or ContainerImage
.Parameter containerOrImageName
Name of the container or container image for which you want to get the country version
.Example
Get-NavContainerCountry -containerOrImageName navserver
.Example
Get-NavContainerCountry -containerOrImageName microsoft/dynamics-nav:2017
Get-NavContainerCountry -containerOrImageName mcr.microsoft.com/businesscentral/onprem:dk
#>
function Get-NavContainerCountry {
[CmdletBinding()]
@ -22,7 +21,7 @@ function Get-NavContainerCountry {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
return "$($inspect.Config.Labels.country)"
}

Просмотреть файл

@ -50,7 +50,7 @@ function Get-NavContainerDebugInfo {
$inspect = docker inspect $containerName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerName is not a NAV container"
throw "Container $containerName is not a NAV/BC container"
}
$debugInfo.Add('container.labels', $inspect.Config.Labels)

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Get the Eula Link for for a Nav container or a Nav container image
Get the Eula Link for for a NAV/BC Container or a NAV/BC Container image
.Description
Returns the Eula link for the version of Nav in the Nav container or Nav containerImage
This is the Eula, which you accept when running the Nav Container using -e accept_eula=Y
Returns the Eula link for the version of NAV or Business Central in the Container or Container Image
This is the Eula, which you accept when running the Container using -e accept_eula=Y
.Parameter containerOrImageName
Name of the container or container image for which you want to get the Eula link
.Example
@ -22,7 +22,7 @@ function Get-NavContainerEula {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
return "$($inspect.Config.Labels.Eula)"
}

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Get the Event log from a Nav container as an .evtx file
Get the Event log from a NAV/BC Container as an .evtx file
.Description
Get a copy of the current Event Log from a continer and open it in the local event viewer
.Parameter containerName

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Get the generic tag for a Nav container or a Nav container image
Get the generic tag for a NAV/BC Container or a NAV/BC Container image
.Description
Returns the generic Tag version referring to a release from http://www.github.com/microsoft/nav-docker
.Parameter containerOrImageName
@ -21,7 +21,7 @@ function Get-NavContainerGenericTag {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('tag').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
return "$($inspect.Config.Labels.tag)"
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get the Id of a Nav container
Get the Id of a NAV/BC Container
.Description
Returns the Id of a Nav container based on the container name
Returns the Id of a Container based on the container name
The Id returned is the full 64 digit container Id and the name must match
.Parameter containerName
Name of the container for which you want the Id

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Get the name of the image used to run a Nav container
Get the name of the image used to run a NAV/BC Container
.Description
Get the name of the image used to run a Nav container
The image name can be used to run a new instance of a Nav Container with the same version of Nav
Get the name of the image used to run a Container
The image name can be used to run a new instance of a Container with the same version of NAV/BC
.Parameter containerName
Name of the container for which you want to get the image name
.Example

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get the IP Address of a Nav container
Get the IP Address of a NAV/BC Container
.Description
Inspect the Nav Container and return the IP Address of the first network.
Inspect the Container and return the IP Address of the first network.
.Parameter containerName
Name of the container for which you want to get the IP Address
.Example

Просмотреть файл

@ -1,9 +1,9 @@
<#
.Synopsis
Get the Legal Link for for a Nav container or a Nav container image
Get the Legal Link for for a NAV/BC Container or a NAV/BC Container image
.Description
Returns the Legal link for the version of Nav in the Nav container or Nav containerImage
This is the legal agreement for running this version of Microsoft Dynamics NAV
Returns the Legal link for the version of NAV or Business Central in the Container or Container Image
This is the legal agreement for running this version of NAV or Business Central
.Parameter containerOrImageName
Name of the container or container image for which you want to get the legal link
.Example
@ -22,7 +22,7 @@ function Get-NavContainerLegal {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
return "$($inspect.Config.Labels.legal)"
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get the name of a Nav container
Get the name of a NAV/BC Container
.Description
Returns the name of a Nav container based on the container Id
Returns the name of a Container based on the container Id
You need to specify enought characters of the Id to make it unambiguous
.Parameter containerId
Id (or part of the Id) of the container for which you want to get the name

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get the version of NAV in a Nav container or a Nav container image
Get the application version from a NAV/BC Container or a NAV/BC Container image
.Description
Returns the version of NAV in the format major.minor.build.release-country
Returns the version of NAV/BC in the format major.minor.build.release-country
.Parameter containerOrImageName
Name of the container or container image for which you want to get the version
.Example
@ -21,7 +21,7 @@ function Get-NavContainerNavVersion {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
return "$($inspect.Config.Labels.version)-$($inspect.Config.Labels.country)"
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get the OS Version for a Nav container or a Nav container image
Get the OS Version for a NAV/BC Container or a NAV/BC Container image
.Description
Returns the version of the WindowsServerCore image used to build the Nav container or Nav containerImage
Returns the version of the WindowsServerCore image used to build the Container or ContainerImage
.Parameter containerOrImageName
Name of the container or container image for which you want to get the OS Version
.Example

Просмотреть файл

@ -1,7 +1,7 @@
<#
.Synopsis
Get the platform version of Business Central in a Nav container or a Nav container image
The function will return blank for Dynamics-Nav Containers
Get the Platform Version from a BC Container or BC Container image
The function will return blank for NAV Containers
.Description
Returns the platform version of Business Central in the format major.minor.build.release
.Parameter containerOrImageName
@ -22,7 +22,7 @@ function Get-NavContainerPlatformVersion {
Process {
$inspect = docker inspect $containerOrImageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV container"
throw "Container $containerOrImageName is not a NAV/BC container"
}
if ($inspect.Config.Labels.psobject.Properties.Match('platform').Count -eq 0) {
return ""

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Retrieve the NAV server configuration as a powershell object.
Retrieve the Server configuration from a NAV/BC Container as a powershell object
.Description
Returns all the settings of the middletier from a container.
.Example

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Get a list of folders shared with a Nav container
Get a list of folders shared with a NAV/BC Container
.Description
Returns a hastable of folders shared with the container.
The name in the hashtable is the local folder, the value is the folder inside the container

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get a list of all NAV Containers
Get a list of all NAV/BC Containers
.Description
Returns the names of all NAV Containers
Returns the names of all NAV/BC Containers
.Example
Get-NavContainers | Remove-NavContainer
#>

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Test whether a Nav container exists
Test whether a NAV/BC Container exists
.Description
Returns $true if the Nav container with the specified name exists
Returns $true if a NAV/BC Container with the specified name exists
.Parameter containerName
Name of the container which you want to check for existence
.Example

Просмотреть файл

@ -1,6 +1,6 @@
<#
.Synopsis
Copy Font(s) to a Nav container
Copy Font(s) to a NAV/BC container
.Description
Copies and registers missing fonts in a container to use in report printing or preview
.Parameter containerName

Просмотреть файл

@ -1,7 +1,7 @@
Get-ChildItem -Path $PSScriptRoot -Recurse | % { Unblock-File -Path $_.FullName }
Remove-Module NavContainerHelper -ErrorAction Ignore
Uninstall-module NavContainerHelper -ErrorAction Ignore
$modulePath = Join-Path $PSScriptRoot "NavContainerHelper.psd1"
Import-Module $modulePath -DisableNameChecking
Get-ChildItem -Path $PSScriptRoot -Recurse | % { Unblock-File -Path $_.FullName }
Remove-Module NavContainerHelper -ErrorAction Ignore
Uninstall-module NavContainerHelper -ErrorAction Ignore
$modulePath = Join-Path $PSScriptRoot "NavContainerHelper.psm1"
Import-Module $modulePath -DisableNameChecking

Просмотреть файл

@ -114,6 +114,8 @@ Check-NavContainerHelperPermissions -Silent
. (Join-Path $PSScriptRoot "AppHandling\Install-NAVSipCryptoProviderFromNavContainer.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Sign-NavContainerApp.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Get-NavContainerAppRuntimePackage.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Get-NavContainerApp.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Extract-AppFileToFolder.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Run-TestsInNavContainer.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Get-TestsFromNavContainer.ps1")
. (Join-Path $PSScriptRoot "AppHandling\Create-AlProjectFolderFromNavContainer")

Просмотреть файл

@ -52,7 +52,7 @@ function Convert-ModifiedObjectsToAl {
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential
$txt2al = Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { $txt2al }
if (!($txt2al)) {
throw "You cannot run Convert-ModifiedObjectsToAl on this Nav Container, the txt2al tool is not present."
throw "You cannot run Convert-ModifiedObjectsToAl on this Container, the txt2al tool is not present."
}
$suffix = "-newsyntax"

Просмотреть файл

@ -46,7 +46,7 @@ function Convert-Txt2Al {
$erroractionpreference = 'Continue'
if (!($txt2al)) {
throw "You cannot run Convert-Txt2Al on this Nav Container"
throw "You cannot run Convert-Txt2Al on this Container"
}
Write-Host "Converting files in $myDeltaFolder to .al files in $myAlFolder with startId $startId (container paths)"
Remove-Item -Path $myAlFolder -Recurse -Force -ErrorAction Ignore

Просмотреть файл

@ -11,12 +11,22 @@ Get-ChildItem -Path $PSScriptRoot -Recurse | % { Unblock-File -Path $_.FullName
Remove-Module NavContainerHelper -ErrorAction Ignore
Uninstall-module NavContainerHelper -ErrorAction Ignore
$modulePath = Join-Path $PSScriptRoot "NavContainerHelper.psm1"
$path = "c:\temp\NavContainerHelper"
if (Test-Path -Path $path) {
Remove-Item -Path $path -Force -Recurse
}
Copy-Item -Path $PSScriptRoot -Destination "c:\temp" -Exclude @("settings.ps1", ".gitignore", "README.md", "PublishNavContainerHelper.ps1") -Recurse
Remove-Item -Path (Join-Path $path ".git") -Force -Recurse
Remove-Item -Path (Join-Path $path "Tests") -Force -Recurse
$modulePath = Join-Path $path "NavContainerHelper.psm1"
Import-Module $modulePath -DisableNameChecking
$functionsToExport = (get-module -Name NavContainerHelper).ExportedFunctions.Keys | Sort-Object
$aliasesToExport = (get-module -Name NavContainerHelper).ExportedAliases.Keys | Sort-Object
Update-ModuleManifest -Path (Join-Path $PSScriptRoot "NavContainerHelper.psd1") `
Update-ModuleManifest -Path (Join-Path $path "NavContainerHelper.psd1") `
-RootModule "NavContainerHelper.psm1" `
-FileList @("ContainerHandling\docker.ico") `
-ModuleVersion $version `
@ -24,6 +34,8 @@ Update-ModuleManifest -Path (Join-Path $PSScriptRoot "NavContainerHelper.psd1")
-FunctionsToExport $functionsToExport `
-AliasesToExport $aliasesToExport `
-CompanyName $CompanyName `
-ReleaseNotes (get-content (Join-Path $PSScriptRoot "ReleaseNotes.txt"))
-ReleaseNotes (get-content (Join-Path $path "ReleaseNotes.txt"))
Publish-Module -Path $PSScriptRoot -NuGetApiKey $nugetkey
#Publish-Module -Path $path -NuGetApiKey $nugetkey
Remove-Item -Path $path -Force -Recurse

Просмотреть файл

@ -1,3 +1,10 @@
0.6.1.2
Remove .git folder and other files, which should not be published
Added function Get-NavContainerApp to download an app or symbols from a container
Added function Extract-AppFileToFolder to extract the content of an App Package to a Folder
Prepare NavContainerHelper for BC containers (without C/AL and without Windows Client)
Support for 1903 generic image (mcr.microsoft.com/dynamicsnav:generic-1903)
0.6.1.1
Reverted the change to default to hyperv isolation if the revision number is different. Instead, just write a warning to maybe specify -isolation hyperv.

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Retrieve all Tenants in a multitenant Nav container
Retrieve all Tenants in a multitenant NAV/BC Container
.Description
Get information about all tenants in the Nav container
Get information about all tenants in the Container
.Parameter containerName
Name of the container from which you want to get the tenant information
.Example
@ -20,10 +20,10 @@ function Get-NavContainerTenants {
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
if ($customConfig.SelectSingleNode("//appSettings/add[@key='Multitenant']").Value -ne "true") {
throw "The NAV Container is not setup for multitenancy"
throw "The Container is not setup for multitenancy"
}
Get-NavTenant -ServerInstance NAV
Get-NavTenant -ServerInstance $ServerInstance
}
}
Set-Alias -Name Get-BCContainerTenants -Value Get-NavContainerTenants

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Creates a new Tenant in a multitenant Nav container
Creates a new Tenant in a multitenant NAV/BC Container
.Description
Creates a tenant database in the Nav container and mounts it as a new tenant
Creates a tenant database in the Container and mounts it as a new tenant
.Parameter containerName
Name of the container in which you want create a tenant
.Parameter tenantId
@ -33,7 +33,7 @@ function New-NavContainerTenant {
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
if ($customConfig.SelectSingleNode("//appSettings/add[@key='Multitenant']").Value -ne "true") {
throw "The NAV Container is not setup for multitenancy"
throw "The Container is not setup for multitenancy"
}
$databaseServer = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Value
$databaseInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseInstance']").Value

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Removes a Tenant in a multitenant Nav container
Removes a Tenant in a multitenant NAV/BC Container
.Description
Unmounts and removes a tenant database in the Nav container
Unmounts and removes a tenant database in the Container
.Parameter containerName
Name of the container in which you want remove a tenant
.Parameter tenantId
@ -33,7 +33,7 @@ function Remove-NavContainerTenant {
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
if ($customConfig.SelectSingleNode("//appSettings/add[@key='Multitenant']").Value -ne "true") {
throw "The NAV Container is not setup for multitenancy"
throw "The Container is not setup for multitenancy"
}
$databaseServer = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Value
$databaseInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseInstance']").Value

Просмотреть файл

@ -7,6 +7,8 @@ $global:testErrors = @()
$global:currentTest = ""
Clear-Content -Path "c:\temp\errors.txt" -ErrorAction Ignore
$ErrorActionPreference = "Stop"
function randomchar([string]$str)
{
$rnd = Get-Random -Maximum $str.length
@ -87,10 +89,10 @@ $windowsCredential = get-credential -UserName $env:USERNAME -Message "Please ent
$aadAdminCredential = get-credential -Message "Please enter your AAD Admin credentials if you want to include AAD auth testing"
$testParams = @(
@{ "name" = "n2018w1"; "image" = "mcr.microsoft.com/dynamicsnav:$platform" ; "country" = "w1" },
@{ "name" = "n2018de"; "image" = "mcr.microsoft.com/dynamicsnav:de-$platform" ; "country" = "de" },
@{ "name" = "bcopw1"; "image" = "mcr.microsoft.com/businesscentral/onprem:$platform" ; "country" = "w1" },
@{ "name" = "bcopnl"; "image" = "mcr.microsoft.com/businesscentral/onprem:nl-$platform" ; "country" = "nl" }
# @{ "name" = "n2018w1"; "image" = "mcr.microsoft.com/dynamicsnav:$platform" ; "country" = "w1" }
# @{ "name" = "n2018de"; "image" = "mcr.microsoft.com/dynamicsnav:de-$platform" ; "country" = "de" }
@{ "name" = "bcopw1"; "image" = "mcr.microsoft.com/businesscentral/onprem:$platform" ; "country" = "w1" }
# @{ "name" = "bcopnl"; "image" = "mcr.microsoft.com/businesscentral/onprem:nl-$platform" ; "country" = "nl" }
)
# @{ "name" = "n2016w1"; "image" = "microsoft/dynamics-nav:2016-$platform" ; "country" = "w1" },
@ -307,8 +309,12 @@ $testParams | ForEach-Object {
$count = @(Get-NavContainerAppInfo -containerName $name).Count
Test "Publish-NavContainerApp"
$scopeArgs = @{}
if ($multitenant) {
$scopeArgs = @{ "Scope" = "Tenant" }
}
$appFile = (Get-item "$appoutputfolder\*.app").FullName
Publish-NavContainerApp -containerName $name -appFile $appFile -skipVerification -sync -install
Publish-NavContainerApp -containerName $name -appFile $appFile -skipVerification -sync -install -useDevEndpoint @scopeArgs
Test "Get-NavContainerAppInfo"
AreEqual -expr "@(Get-NavContainerAppInfo -containerName $name).Count" -expected ($count+1)
@ -399,7 +405,7 @@ $testParams | ForEach-Object {
Test "Publish-NavContainerApp"
$appFile = (Get-item "$appoutputfolder\*.app").FullName
Publish-NavContainerApp -containerName compiler -appFile $appFile -skipVerification -sync -install
Publish-NavContainerApp -containerName compiler -appFile $appFile -skipVerification -sync -install -useDevEndpoint
Test "Unpublish-NavContainerApp"
UnPublish-NavContainerApp -containerName compiler -appName TestApp -publisher TestApp -version "1.0.0.0" -unInstall
@ -497,7 +503,12 @@ $testParams | ForEach-Object {
if ($navVersion.Major -ge 12) {
Test "Setup-NavContainerTestUsers"
Setup-NavContainerTestUsers -containerName $name -password $credential2.Password
if ($auth -eq "Windows") {
Setup-NavContainerTestUsers -containerName $name -password $credential2.Password
}
else {
Setup-NavContainerTestUsers -containerName $name -password $credential2.Password -credential $credential
}
AreEqual -expr "@(Get-NavContainerNavUser -containerName $name).Count" -expected ($count+7)
}
}

Просмотреть файл

@ -1,8 +1,8 @@
<#
.Synopsis
Get list of users from container
Get list of users from NAV/BC Container
.Description
Retrieve the list of user objects from a tenant in a container
Retrieve the list of user objects from a tenant in a NAV/BC Container
.Parameter containerName
Name of the container from which you want to get the users (default navserver)
.Parameter tenant

Просмотреть файл

@ -1,15 +1,15 @@
<#
.Synopsis
Creates a new NAV User in a Nav container
Creates a new User in a NAV/BC Container
.Description
Creates a new NAV user in a Nav container.
If the Nav Container is multitenant, the NAV user will be added to a specified tenant
Creates a new user in a NAV/BC container.
If the Container is multitenant, the user will be added to a specified tenant
.Parameter containerName
Name of the container in which you want to create the user (default navserver)
.Parameter tenant
Name of tenant in which you want to create a user
.Parameter Credential
Credentials of the new NAV user (if using NavUserPassword authentication)
Credentials of the new user (if using NavUserPassword authentication)
.Parameter WindowsAccount
WindowsAccount of the new user (if using Windows authentication)
.Parameter AuthenticationEmail
@ -55,12 +55,12 @@ function New-NavContainerNavUser {
$Parameters.Add('AuthenticationEmail',$AuthenticationEmail)
}
if($WindowsAccount) {
Write-Host "Creating NAV User for WindowsAccount $WindowsAccount"
Write-Host "Creating User for WindowsAccount $WindowsAccount"
New-NAVServerUser -ServerInstance $ServerInstance @TenantParam -WindowsAccount $WindowsAccount @Parameters
Write-Host "Assigning Permission Set $PermissionSetId to $WindowsAccount"
New-NavServerUserPermissionSet -ServerInstance $ServerInstance @tenantParam -WindowsAccount $WindowsAccount -PermissionSetId $PermissionSetId
} else {
Write-Host "Creating NAV User $($Credential.UserName)"
Write-Host "Creating User $($Credential.UserName)"
if ($ChangePasswordAtNextLogOn) {
New-NAVServerUser -ServerInstance $ServerInstance @TenantParam -Username $Credential.UserName -Password $Credential.Password -ChangePasswordAtNextLogon @Parameters
} else {

Просмотреть файл

@ -1,10 +1,10 @@
<#
.Synopsis
Creates a new Winodws User in a Nav container
Creates a new Winodws User in a NAV/BC Container
.Description
Creates a new Windows user in a Nav container.
Creates a new Windows user in a NAV/BC Container.
.Parameter containerName
Name of the container in which you want to install the app (default navserver)
Name of the container in which you want to create a windows user
.Parameter Credential
Credentials of the new Winodws user
.Parameter group
@ -16,11 +16,11 @@ function New-NavContainerWindowsUser {
Param
(
[Parameter(Mandatory=$false)]
[string]$containerName = "navserver",
[string] $containerName = "navserver",
[Parameter(Mandatory=$true)]
[System.Management.Automation.PSCredential]$Credential,
[PSCredential] $Credential,
[parameter(Mandatory=$false)]
[string]$group = "administrators"
[string] $group = "administrators"
)
PROCESS