Multitenancy support 0.2.5.0
This commit is contained in:
Родитель
7885d369e8
Коммит
d2d0ad9476
|
@ -8,20 +8,24 @@
|
|||
.Parameter appName
|
||||
Name of app you want to install in the container
|
||||
.Example
|
||||
Install-NavApp -containerName test2 -appName myapp
|
||||
Install-NavContainerApp -containerName test2 -appName myapp
|
||||
#>
|
||||
function Install-NavContainerApp {
|
||||
Param(
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$tenant = "default",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$appName,
|
||||
[string]$containerName = "navserver"
|
||||
[string]$appName
|
||||
)
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName)
|
||||
Write-Host "Installing app $appName"
|
||||
Install-NavApp -ServerInstance NAV -Name $appName
|
||||
} -ArgumentList $appName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName, $tenant)
|
||||
Write-Host "Installing app $appName on $tenant"
|
||||
Install-NavApp -ServerInstance NAV -Name $appName -Tenant $tenant
|
||||
} -ArgumentList $appName, $tenant
|
||||
Write-Host -ForegroundColor Green "App successfully installed"
|
||||
}
|
||||
Export-ModuleMember -Function Install-NavContainerApp
|
||||
|
|
|
@ -12,16 +12,19 @@
|
|||
#>
|
||||
function Sync-NavContainerApp {
|
||||
Param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$tenant = "default",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$appName
|
||||
)
|
||||
$session = Get-NavContainerSession -containerName $containerName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName)
|
||||
Write-Host "Synchronizing app $appFile"
|
||||
Sync-NavTenant -ServerInstance NAV -Tenant default -Force
|
||||
Sync-NavApp -ServerInstance NAV -Name $appName
|
||||
} -ArgumentList $appName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName,$tenant)
|
||||
Write-Host "Synchronizing app $appFile on $tenant"
|
||||
Sync-NavTenant -ServerInstance NAV -Tenant $tenant -Force
|
||||
Sync-NavApp -ServerInstance NAV -Name $appName -Tenant $tenant
|
||||
} -ArgumentList $appName, $tenant
|
||||
Write-Host -ForegroundColor Green "App successfully synchronized"
|
||||
}
|
||||
Export-ModuleMember -Function Sync-NavContainerApp
|
||||
|
|
|
@ -8,20 +8,23 @@
|
|||
.Parameter appName
|
||||
Name of app you want to uninstall in the container
|
||||
.Example
|
||||
Uninstall-NavApp -containerName test2 -appName myapp
|
||||
Uninstall-NavContainerApp -containerName test2 -appName myapp
|
||||
#>
|
||||
function UnInstall-NavContainerApp {
|
||||
Param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$tenant = "default",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$appName
|
||||
)
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName)
|
||||
Write-Host "Uninstalling app $appName"
|
||||
Uninstall-NavApp -ServerInstance NAV -Name $appName
|
||||
} -ArgumentList $appName
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($appName, $tenant)
|
||||
Write-Host "Uninstalling app $appName from $tenant"
|
||||
Uninstall-NavApp -ServerInstance NAV -Name $appName -tenant $tenant
|
||||
} -ArgumentList $appName, $tenant
|
||||
Write-Host -ForegroundColor Green "App successfully uninstalled"
|
||||
}
|
||||
Export-ModuleMember -Function UnInstall-NavContainerApp
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
.Parameter appName
|
||||
Name of app you want to unpublish in the container
|
||||
.Example
|
||||
Unpublish-NavApp -containerName test2 -appName myapp
|
||||
Unpublish-NavContainerApp -containerName test2 -appName myapp
|
||||
#>
|
||||
function UnPublish-NavContainerApp {
|
||||
Param(
|
||||
|
|
|
@ -15,7 +15,9 @@ function Get-NavContainerSession {
|
|||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$containerName
|
||||
[string]$containerName,
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$silent
|
||||
)
|
||||
|
||||
Process {
|
||||
|
@ -33,13 +35,26 @@ function Get-NavContainerSession {
|
|||
}
|
||||
if (!($sessions.ContainsKey($containerId))) {
|
||||
$session = New-PSSession -ContainerId $containerId -RunAsAdministrator
|
||||
Invoke-Command -Session $session -ScriptBlock {
|
||||
. "c:\run\prompt.ps1" | Out-Null
|
||||
. "c:\run\HelperFunctions.ps1" | Out-Null
|
||||
Invoke-Command -Session $session -ScriptBlock { Param([bool]$silent)
|
||||
|
||||
$runPath = "c:\Run"
|
||||
$myPath = Join-Path $runPath "my"
|
||||
|
||||
function Get-MyFilePath([string]$FileName)
|
||||
{
|
||||
if ((Test-Path $myPath -PathType Container) -and (Test-Path (Join-Path $myPath $FileName) -PathType Leaf)) {
|
||||
(Join-Path $myPath $FileName)
|
||||
} else {
|
||||
(Join-Path $runPath $FileName)
|
||||
}
|
||||
}
|
||||
|
||||
. (Get-MyFilePath "prompt.ps1") -silent:$silent | Out-Null
|
||||
. (Get-MyFilePath "HelperFunctions.ps1") | Out-Null
|
||||
|
||||
$txt2al = $NavIde.replace("finsql.exe","txt2al.exe")
|
||||
cd c:\run
|
||||
}
|
||||
cd $runPath
|
||||
} -ArgumentList $silent
|
||||
$sessions.Add($containerId, $session)
|
||||
}
|
||||
$sessions[$containerId]
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
Avoid exporting objects for baseline from the container (Saves time, but you will not be able to use the object handling functions without the baseline)
|
||||
.Parameter alwaysPull
|
||||
Always pull latest version of the docker image
|
||||
.Parameter mulittenant
|
||||
Setup container for multitenancy by adding this switch
|
||||
.Parameter restart
|
||||
Define the restart option for the container
|
||||
.Parameter auth
|
||||
|
@ -52,6 +54,8 @@
|
|||
This allows you to specify a number of scripts you want to copy to the c:\run\my folder in the container (override functionality)
|
||||
.Example
|
||||
New-NavContainer -containerName test
|
||||
.Example
|
||||
New-NavContainer -containerName test -multitenant
|
||||
.Example
|
||||
New-NavContainer -containerName test -memoryLimit 3G -imageName "microsoft/dynamics-nav:2017" -updateHosts
|
||||
.Example
|
||||
|
@ -83,6 +87,7 @@ function New-NavContainer {
|
|||
[switch]$enableSymbolLoading,
|
||||
[switch]$doNotExportObjectsToText,
|
||||
[switch]$alwaysPull,
|
||||
[switch]$multitenant,
|
||||
[switch]$includeTestToolkit,
|
||||
[ValidateSet('no','on-failure','unless-stopped','always')]
|
||||
[string]$restart='unless-stopped',
|
||||
|
@ -154,6 +159,10 @@ function New-NavContainer {
|
|||
docker pull $imageName
|
||||
}
|
||||
|
||||
if ($multitenant) {
|
||||
$parameters += "--env multitenant=Y"
|
||||
}
|
||||
|
||||
if ("$navDvdPath" -ne "") {
|
||||
$navversion = (Get-Item -Path (Join-Path $navDvdPath "setup.exe")).VersionInfo.FileVersion
|
||||
$devCountry = $navDvdCountry
|
||||
|
@ -186,6 +195,10 @@ function New-NavContainer {
|
|||
Write-Host "Generic Tag: $genericTag"
|
||||
$locale = Get-LocaleFromCountry $devCountry
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
if (Test-NavContainer -containerName $containerName) {
|
||||
Remove-NavContainer $containerName
|
||||
}
|
||||
|
@ -255,6 +268,9 @@ function New-NavContainer {
|
|||
[xml]$ClientUserSettings = Get-Content $clientUserSettingsFileName
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""Server""]").value = "$publicDnsName"
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ServerInstance""]").value="NAV"
|
||||
if ($multitenant) {
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""TenantId""]").value="$TenantId"
|
||||
}
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ServicesCertificateValidationEnabled""]").value="false"
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ClientServicesPort""]").value="$publicWinClientPort"
|
||||
$clientUserSettings.SelectSingleNode("//configuration/appSettings/add[@key=""ACSUri""]").value = ""
|
||||
|
@ -331,15 +347,27 @@ function New-NavContainer {
|
|||
Wait-NavContainerReady $containerName
|
||||
}
|
||||
|
||||
Write-Host "Read CustomSettings.config from $containerName"
|
||||
Write-Host "Reading CustomSettings.config from $containerName"
|
||||
$ps = '$customConfigFile = Join-Path (Get-Item ''C:\Program Files\Microsoft Dynamics NAV\*\Service'').FullName "CustomSettings.config"
|
||||
[System.IO.File]::ReadAllText($customConfigFile)'
|
||||
[xml]$customConfig = docker exec $containerName powershell $ps
|
||||
|
||||
Write-Host "Create Desktop Shortcuts for $containerName"
|
||||
Write-Host "Creating Desktop Shortcuts for $containerName"
|
||||
$publicWebBaseUrl = $customConfig.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Value
|
||||
if ("$publicWebBaseUrl" -ne "") {
|
||||
New-DesktopShortcut -Name "$containerName Web Client" -TargetPath "$publicWebBaseUrl" -IconLocation "C:\Program Files\Internet Explorer\iexplore.exe, 3" -Shortcuts $shortcuts
|
||||
$webClientUrl = "$publicWebBaseUrl"
|
||||
if ($multitenant) {
|
||||
$webClientUrl += "?tenant=default"
|
||||
}
|
||||
New-DesktopShortcut -Name "$containerName Web Client" -TargetPath "$webClientUrl" -IconLocation "C:\Program Files\Internet Explorer\iexplore.exe, 3" -Shortcuts $shortcuts
|
||||
if ($includeTestToolkit) {
|
||||
if ($multitenant) {
|
||||
$webClientUrl += "&page=130401"
|
||||
} else {
|
||||
$webClientUrl += "?page=130401"
|
||||
}
|
||||
New-DesktopShortcut -Name "$containerName Test Tool" -TargetPath "$webClientUrl" -IconLocation "C:\Program Files\Internet Explorer\iexplore.exe, 3" -Shortcuts $shortcuts
|
||||
}
|
||||
}
|
||||
New-DesktopShortcut -Name "$containerName Command Prompt" -TargetPath "CMD.EXE" -IconLocation "C:\Program Files\Docker\docker.exe, 0" -Arguments "/C docker.exe exec -it $containerName cmd" -Shortcuts $shortcuts
|
||||
New-DesktopShortcut -Name "$containerName PowerShell Prompt" -TargetPath "CMD.EXE" -IconLocation "C:\Program Files\Docker\docker.exe, 0" -Arguments "/C docker.exe exec -it $containerName powershell -noexit c:\run\prompt.ps1" -Shortcuts $shortcuts
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<#
|
||||
.Synopsis
|
||||
Get the Event log from a Nav 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
|
||||
Name of the container for which you want to get the Event log
|
||||
.Parameter logName
|
||||
Name of the log you want to get (default is Application)
|
||||
.Parameter doNotOpen
|
||||
Obtain a copy of the event log, but do not open the event log in the event viewer
|
||||
.Example
|
||||
Get-NavContainerEventLog -containerName navserver
|
||||
.Example
|
||||
Get-NavContainerEventLog -containerName navserver -logname Security -doNotOpen
|
||||
#>
|
||||
function Get-NavContainerEventLog {
|
||||
[CmdletBinding()]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$containerName,
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$logname = "Application",
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$doNotOpen
|
||||
)
|
||||
|
||||
Process {
|
||||
Write-Host "Getting event log for $containername"
|
||||
|
||||
$containerFolder = Join-Path $ExtensionsFolder $containerName
|
||||
$myFolder = Join-Path $containerFolder "my"
|
||||
$folder = Get-NavContainerPath -containerName $containerName -Path $myFolder
|
||||
$name = $containerName + ' ' + [DateTime]::Now.ToString("yyyy-mm-dd hh.mm.ss") + ".evtx"
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { Param([string]$path, [string]$logname)
|
||||
wevtutil epl $logname "$path"
|
||||
} -ArgumentList (Join-Path $folder $name), $logname
|
||||
|
||||
if (!$doNotOpen) {
|
||||
[Diagnostics.Process]::Start((Join-Path -Path $myFolder $name)) | Out-Null
|
||||
}
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -function Get-NavContainerEventLog
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Generated by: Freddy Kristiansen
|
||||
#
|
||||
# Generated on: 08-01-2018
|
||||
# Generated on: 24-01-2018
|
||||
#
|
||||
|
||||
@{
|
||||
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'NavContainerHelper.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '0.2.2.4'
|
||||
ModuleVersion = '0.2.5.0'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
@ -76,20 +76,23 @@ FunctionsToExport = 'Compile-ObjectsInNavContainer', 'Convert-ModifiedObjectsToA
|
|||
'Export-ModifiedObjectsAsDeltas', 'Export-NavContainerObjects',
|
||||
'Get-LocaleFromCountry', 'Get-NavContainerAppInfo',
|
||||
'Get-NavContainerCountry', 'Get-NavContainerDebugInfo',
|
||||
'Get-NavContainerEula', 'Get-NavContainerGenericTag',
|
||||
'Get-NavContainerId', 'Get-NavContainerImageName',
|
||||
'Get-NavContainerIpAddress', 'Get-NavContainerLegal',
|
||||
'Get-NavContainerName', 'Get-NavContainerNavVersion',
|
||||
'Get-NavContainerOsVersion', 'Get-NavContainerPath',
|
||||
'Get-NavContainers', 'Get-NavContainerSession',
|
||||
'Get-NavContainerSharedFolders', 'Get-NavVersionFromVersionInfo',
|
||||
'Import-DeltasToNavContainer', 'Import-ObjectsToNavContainer',
|
||||
'Import-TestToolkitToNavContainer', 'Install-NavContainerApp',
|
||||
'Get-NavContainerEula', 'Get-NavContainerEventLog',
|
||||
'Get-NavContainerGenericTag', 'Get-NavContainerId',
|
||||
'Get-NavContainerImageName', 'Get-NavContainerIpAddress',
|
||||
'Get-NavContainerLegal', 'Get-NavContainerName',
|
||||
'Get-NavContainerNavVersion', 'Get-NavContainerOsVersion',
|
||||
'Get-NavContainerPath', 'Get-NavContainers',
|
||||
'Get-NavContainerSession', 'Get-NavContainerSharedFolders',
|
||||
'Get-NavVersionFromVersionInfo', 'Import-DeltasToNavContainer',
|
||||
'Import-ObjectsToNavContainer', 'Import-TestToolkitToNavContainer',
|
||||
'Install-NavContainerApp',
|
||||
'Install-NAVSipCryptoProviderFromNavContainer',
|
||||
'New-CSideDevContainer', 'New-DesktopShortcut', 'New-NavContainer',
|
||||
'Open-NavContainer', 'Publish-NavContainerApp',
|
||||
'Remove-DesktopShortcut', 'Remove-NavContainer',
|
||||
'Remove-NavContainerSession', 'Replace-NavServerContainer',
|
||||
'New-NavContainerNavUser', 'New-NavContainerTenant',
|
||||
'New-NavContainerWindowsUser', 'Open-NavContainer',
|
||||
'Publish-NavContainerApp', 'Remove-DesktopShortcut',
|
||||
'Remove-NavContainer', 'Remove-NavContainerSession',
|
||||
'Remove-NavContainerTenant', 'Replace-NavServerContainer',
|
||||
'Start-NavContainerAppDataUpgrade', 'Sync-NavContainerApp',
|
||||
'Test-NavContainer', 'UnInstall-NavContainerApp',
|
||||
'UnPublish-NavContainerApp', 'Wait-NavContainerReady',
|
||||
|
@ -131,7 +134,18 @@ PrivateData = @{
|
|||
# IconUri = ''
|
||||
|
||||
# ReleaseNotes of this module
|
||||
ReleaseNotes = '0.2.2.4
|
||||
ReleaseNotes = '0.2.2.5
|
||||
Add support for multitenancy
|
||||
Add switch -multitenant to new-navcontainer
|
||||
Add function New-NavContainerTenant
|
||||
Add function Remove-NavContainerTenant
|
||||
Add function New-NavContainerNavUser
|
||||
Add function New-NavContainerWindowsUser
|
||||
Add function Get-NavContainerEventLog
|
||||
Change default filter in Compile-ObjectsInNavContainer to compiled=No
|
||||
Add Shortcut for opening WebClient with Test Tool page if TestToolKit is included
|
||||
|
||||
0.2.2.4
|
||||
Updated Readme
|
||||
|
||||
0.2.2.3
|
||||
|
|
|
@ -31,6 +31,7 @@ $sessions = @{}
|
|||
. (Join-Path $PSScriptRoot "ContainerInfo\Test-NavContainer.ps1")
|
||||
. (Join-Path $PSScriptRoot "ContainerInfo\Get-NavContainerId.ps1")
|
||||
. (Join-Path $PSScriptRoot "ContainerInfo\Get-NavContainers.ps1")
|
||||
. (Join-Path $PSScriptRoot "ContainerInfo\Get-NavContainerEventLog.ps1")
|
||||
|
||||
# Container Handling Functions
|
||||
. (Join-Path $PSScriptRoot "ContainerHandling\Get-NavContainerSession.ps1")
|
||||
|
@ -64,6 +65,14 @@ $sessions = @{}
|
|||
. (Join-Path $PSScriptRoot "AppHandling\Get-NavContainerAppInfo.ps1")
|
||||
. (Join-Path $PSScriptRoot "AppHandling\Install-NAVSipCryptoProviderFromNavContainer.ps1")
|
||||
|
||||
# Tenant Handling functions
|
||||
. (Join-Path $PSScriptRoot "TenantHandling\New-NavContainerTenant.ps1")
|
||||
. (Join-Path $PSScriptRoot "TenantHandling\Remove-NavContainerTenant.ps1")
|
||||
|
||||
# User Handling functions
|
||||
. (Join-Path $PSScriptRoot "UserHandling\New-NavContainerNavUser.ps1")
|
||||
. (Join-Path $PSScriptRoot "UserHandling\New-NavContainerWindowsUser.ps1")
|
||||
|
||||
# Azure VM specific functions
|
||||
. (Join-Path $PSScriptRoot "AzureVM\Replace-NavServerContainer.ps1")
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ function Compile-ObjectsInNavContainer {
|
|||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$containerName,
|
||||
[string]$filter = "modified=Yes",
|
||||
[string]$filter = "compiled=No",
|
||||
[System.Management.Automation.PSCredential]$sqlCredential = $null
|
||||
)
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ function Import-DeltasToNavContainer {
|
|||
$containerMergeResultFile = Get-NavContainerPath -containerName $containerName -path $mergeResultFile -throw
|
||||
$containerMergedObjectsFile = Get-NavContainerPath -containerName $containerName -path $mergedObjectsFile -throw
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($deltaFolder, $originalFolder, $mergedObjectsFile, $mergeResultFile)
|
||||
|
||||
Write-Host "Merging Deltas from $deltaFolder (container path)"
|
||||
|
|
|
@ -20,7 +20,7 @@ function Import-TestToolkitToNavContainer {
|
|||
|
||||
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($sqlCredential)
|
||||
|
||||
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
0.2.2.5
|
||||
Add support for multitenancy
|
||||
Add switch -multitenant to new-navcontainer
|
||||
Add function New-NavContainerTenant
|
||||
Add function Remove-NavContainerTenant
|
||||
Add function New-NavContainerNavUser
|
||||
Add function New-NavContainerWindowsUser
|
||||
Add function Get-NavContainerEventLog
|
||||
Change default filter in Compile-ObjectsInNavContainer to compiled=No
|
||||
Add Shortcut for opening WebClient with Test Tool page if TestToolKit is included
|
||||
|
||||
0.2.2.4
|
||||
Updated Readme
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<#
|
||||
.Synopsis
|
||||
Creates a new Tenant in a multitenant Nav container
|
||||
.Description
|
||||
Creates a tenant database in the Nav container and mounts it as a new tenant
|
||||
.Parameter containerName
|
||||
Name of the container in which you want to install the app (default navserver)
|
||||
.Parameter tenantId
|
||||
Name of tenant you want to create in the container
|
||||
.Example
|
||||
New-NavContainerTenant -containerName test2 -tenantId mytenant
|
||||
#>
|
||||
function New-NavContainerTenant {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$tenantId
|
||||
)
|
||||
|
||||
if ($tenantId -eq "tenant") {
|
||||
throw "You cannot add a tenant called tenant"
|
||||
}
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($tenantId)
|
||||
|
||||
$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"
|
||||
}
|
||||
|
||||
Write-Host "Creating Tenant $tenantId"
|
||||
|
||||
# Setup tenant
|
||||
Copy-NavDatabase -SourceDatabaseName "tenant" -DestinationDatabaseName $TenantId
|
||||
Mount-NavDatabase -TenantId $TenantId -DatabaseName $TenantId
|
||||
|
||||
} -ArgumentList $tenantId
|
||||
Write-Host -ForegroundColor Green "Tenant successfully created"
|
||||
}
|
||||
Export-ModuleMember -Function New-NavContainerTenant
|
|
@ -0,0 +1,43 @@
|
|||
<#
|
||||
.Synopsis
|
||||
Removes a Tenant in a multitenant Nav container
|
||||
.Description
|
||||
Unmounts and removes a tenant database in the Nav container
|
||||
.Parameter containerName
|
||||
Name of the container in which you want to install the app (default navserver)
|
||||
.Parameter tenantId
|
||||
Name of tenant you want to remove in the container
|
||||
.Example
|
||||
Remove-NavContainerTenant -containerName test2 -tenantId mytenant
|
||||
#>
|
||||
function Remove-NavContainerTenant {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$tenantId
|
||||
)
|
||||
|
||||
if ($tenantId -eq "tenant") {
|
||||
throw "You cannot remove a tenant called tenant"
|
||||
}
|
||||
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { Param($tenantId)
|
||||
|
||||
$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"
|
||||
}
|
||||
|
||||
Write-Host "Removing Tenant $tenantId"
|
||||
|
||||
# Remove tenant
|
||||
Dismount-NavTenant -ServerInstance NAV -Tenant $TenantId -force | Out-null
|
||||
|
||||
} -ArgumentList $tenantId
|
||||
Write-Host -ForegroundColor Green "Tenant successfully removed"
|
||||
}
|
||||
Export-ModuleMember -Function Remove-NavContainerTenant
|
Двоичный файл не отображается.
|
@ -11,8 +11,8 @@ $txtPath = (Join-Path $PSScriptRoot "test.txt")
|
|||
$deltaPath = (Join-Path $PSScriptRoot "delta")
|
||||
$v1AppPath = (Join-Path $PSScriptRoot "test.navx")
|
||||
$v1AppName = "Test"
|
||||
$v2AppPath = (Join-Path $PSScriptRoot "test.app")
|
||||
$v2AppName = "Test"
|
||||
$v2AppPath = (Join-Path $PSScriptRoot "Freddy Kristiansen_mytestapp_1.0.0.0.app")
|
||||
$v2AppName = "mytestapp"
|
||||
|
||||
# New-CSideDevContainer
|
||||
New-CSideDevContainer -accept_eula `
|
||||
|
@ -123,9 +123,9 @@ if (Test-Path $v1AppPath) {
|
|||
Get-NavContainerAppInfo -containerName $containerName
|
||||
}
|
||||
|
||||
if (Test-Path $v2AppPath) {
|
||||
if (Test-Path "$v2AppPath") {
|
||||
# App Handling functions v2 extensions
|
||||
Publish-NavContainerApp -containerName $containerName -appFile $v2AppPath
|
||||
Publish-NavContainerApp -containerName $containerName -appFile "$v2AppPath" -skipVerification
|
||||
Get-NavContainerAppInfo -containerName $containerName
|
||||
Sync-NavContainerApp -containerName $containerName -appName $v2AppName
|
||||
Install-NavContainerApp -containerName $containerName -appName $v2AppName
|
||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -0,0 +1,255 @@
|
|||
# This script performs a simple happy-path test of most navcontainerhelper functions
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
. (Join-Path $PSScriptRoot "..\..\NavContainerHelper.ps1")
|
||||
. (Join-Path $PSScriptRoot "..\settings.ps1")
|
||||
|
||||
$imageName = "navdocker.azurecr.io/dynamics-nav:mt-11.0.20258.0"
|
||||
$imageName2 = "navdocker.azurecr.io/dynamics-nav:mt-11.0.20258.0-finus"
|
||||
$imageName = "microsoft/dynamics-nav:2016"
|
||||
$imageName2 = "microsoft/dynamics-nav:2016-dk"
|
||||
|
||||
$containerName = "test"
|
||||
|
||||
$fobPath = (Join-Path $PSScriptRoot "test.fob")
|
||||
$txtPath = (Join-Path $PSScriptRoot "test.txt")
|
||||
$deltaPath = (Join-Path $PSScriptRoot "delta")
|
||||
$v1AppPath = (Join-Path $PSScriptRoot "test.navx")
|
||||
$v1AppName = "Test"
|
||||
$v2AppPath = (Join-Path $PSScriptRoot "xFreddy Kristiansen_mytestapp_1.0.0.0.app")
|
||||
$v2AppName = "mytestapp"
|
||||
|
||||
# New-CSideDevContainer
|
||||
New-NavContainer -accept_eula `
|
||||
-includeCSide `
|
||||
-containerName $containerName `
|
||||
-imageName $imageName `
|
||||
-licenseFile $licenseFile `
|
||||
-credential $credential `
|
||||
-UpdateHosts `
|
||||
-multitenant `
|
||||
-Auth Windows `
|
||||
-additionalParameters @("--volume ""${deltaPath}:c:\deltas""")
|
||||
|
||||
# Test-NavContainer
|
||||
if (Test-NavContainer -containerName $containerName) {
|
||||
Write-Host "$containerName is running!"
|
||||
}
|
||||
|
||||
# Create Extra tenant
|
||||
New-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
|
||||
# Remove tenant
|
||||
Remove-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
|
||||
# Get-NavContainerNavVersion
|
||||
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName
|
||||
Write-Host "Nav Version of $imageName is $navVersion"
|
||||
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
|
||||
Write-Host "Nav Version of $containerName is $navVersion"
|
||||
|
||||
# Get-NavContainerImageName
|
||||
$imageName = Get-NavContainerImageName -containerName $containerName
|
||||
Write-Host "ImageName of $containerName is $imageName"
|
||||
|
||||
# Get-NavContainerGenericTag
|
||||
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName
|
||||
Write-Host "Generic tag of $imageName is $tag"
|
||||
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
|
||||
Write-Host "Generic tag of $containerName is $tag"
|
||||
|
||||
# Get-NavContainerOsVersion
|
||||
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName
|
||||
Write-Host "OS Version of $imageName is $osversion"
|
||||
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
|
||||
Write-Host "OS Version of $containerName is $osversion"
|
||||
|
||||
# Get-NavContainerLegal
|
||||
$legal = Get-NavContainerLegal -containerOrImageName $imageName
|
||||
Write-Host "Legal link of $imageName is $legal"
|
||||
$legal = Get-NavContainerLegal -containerOrImageName $containerName
|
||||
Write-Host "Legal link of $containerName is $legal"
|
||||
|
||||
# Get-NavContainerCountry
|
||||
$country = Get-NavContainerCountry -containerOrImageName $imageName
|
||||
Write-Host "Country of $imageName is $country"
|
||||
$country = Get-NavContainerCountry -containerOrImageName $containerName
|
||||
Write-Host "Country of $containerName is $country"
|
||||
|
||||
# Get-NavContainerIpAddress
|
||||
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
|
||||
Write-Host "IP Address of $containerName is $ipAddress"
|
||||
|
||||
# Get-NavContainerSharedFolders
|
||||
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
|
||||
Write-Host "Shared Folders with $containerName are:"
|
||||
$sharedFolders.GetEnumerator() | % { Write-Host ($_.Name + " -> " + $_.Value) }
|
||||
|
||||
# Get-NavContainerPath
|
||||
$path = "c:\programdata\navcontainerhelper\extensions\$containerName\my\AdditionalSetup.ps1"
|
||||
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
|
||||
Write-Host "Container Path of $path in $containerName is $containerPath"
|
||||
|
||||
# Get-NavContainerId
|
||||
$containerId = Get-NavcontainerId -containerName $containerName
|
||||
Write-Host "Id of $containerName is $containerId"
|
||||
|
||||
# Get-NavContainerName
|
||||
$containerName = Get-NavcontainerName -containerId $containerId
|
||||
Write-Host "Name of $containerId is $containerName"
|
||||
|
||||
# Import-ObjectsToNavContainer (.fob)
|
||||
Import-ObjectsToNavContainer -containerName $containerName `
|
||||
-objectsFile $fobPath
|
||||
|
||||
# Compile-ObjectsToNavContainer
|
||||
Compile-ObjectsInNavContainer -containerName $containerName
|
||||
|
||||
# Import-ObjectsToNavContainer (.txt)
|
||||
Import-ObjectsToNavContainer -containerName $containerName `
|
||||
-objectsFile $txtPath
|
||||
|
||||
# Compile-ObjectsToNavContainer
|
||||
Compile-ObjectsInNavContainer -containerName $containerName
|
||||
|
||||
# Import-ObjectsToNavContainer (.txt)
|
||||
Import-DeltasToNavContainer -containerName $containerName `
|
||||
-deltaFolder $deltaPath
|
||||
|
||||
# Compile-ObjectsToNavContainer
|
||||
Compile-ObjectsInNavContainer -containerName $containerName
|
||||
|
||||
# Convert-ModifiedObjectsToAl
|
||||
#Convert-ModifiedObjectsToAl -containerName $containerName `
|
||||
# -startId 50100
|
||||
|
||||
# Install NavSip
|
||||
Install-NAVSipCryptoProviderFromNavContainer -containerName $containerName
|
||||
|
||||
# Create Extra tenant
|
||||
New-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
|
||||
# App Handling functions v1 extensions
|
||||
if (Test-Path $v1AppPath) {
|
||||
Publish-NavContainerApp -containerName $containerName -appFile $v1AppPath
|
||||
Get-NavContainerAppInfo -containerName $containerName
|
||||
Install-NavContainerApp -containerName $containerName -appName $v1AppName
|
||||
Uninstall-NavContainerApp -containerName $containerName -appName $v1AppName
|
||||
Unpublish-NavContainerApp -containerName $containerName -appName $v1AppName
|
||||
Get-NavContainerAppInfo -containerName $containerName
|
||||
}
|
||||
|
||||
if (Test-Path $v2AppPath) {
|
||||
# App Handling functions v2 extensions
|
||||
Publish-NavContainerApp -containerName $containerName -appFile $v2AppPath -skipVerification
|
||||
Get-NavContainerAppInfo -containerName $containerName
|
||||
Sync-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
|
||||
Install-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
|
||||
Uninstall-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
|
||||
Unpublish-NavContainerApp -containerName $containerName -appName $v2AppName
|
||||
Get-NavContainerAppInfo -containerName $containerName
|
||||
}
|
||||
|
||||
# Remove tenant
|
||||
Remove-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
|
||||
# Remove-NavContainer
|
||||
Remove-NavContainer -containerName $containerName
|
||||
|
||||
# New-CSideDevContainer
|
||||
New-NavContainer -accept_eula `
|
||||
-includeCSide `
|
||||
-containerName $containerName `
|
||||
-imageName $imageName2 `
|
||||
-licenseFile $licenseFile `
|
||||
-credential $credential `
|
||||
-UpdateHosts `
|
||||
-multitenant `
|
||||
-Auth NavUserPassword
|
||||
|
||||
# Test-NavContainer
|
||||
if (Test-NavContainer -containerName $containerName) {
|
||||
Write-Host "$containerName is running!"
|
||||
}
|
||||
|
||||
# Get-NavContainerNavVersion
|
||||
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName2
|
||||
Write-Host "Nav Version of $imageName2 is $navVersion"
|
||||
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
|
||||
Write-Host "Nav Version of $containerName is $navVersion"
|
||||
|
||||
# Get-NavContainerImageName
|
||||
$imageName2 = Get-NavContainerImageName -containerName $containerName
|
||||
Write-Host "ImageName of $containerName is $imageName2"
|
||||
|
||||
# Get-NavContainerGenericTag
|
||||
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName2
|
||||
Write-Host "Generic tag of $imageName2 is $tag"
|
||||
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
|
||||
Write-Host "Generic tag of $containerName is $tag"
|
||||
|
||||
# Get-NavContainerOsVersion
|
||||
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName2
|
||||
Write-Host "OS Version of $imageName2 is $osversion"
|
||||
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
|
||||
Write-Host "OS Version of $containerName is $osversion"
|
||||
|
||||
# Get-NavContainerLegal
|
||||
$legal = Get-NavContainerLegal -containerOrImageName $imageName2
|
||||
Write-Host "Legal link of $imageName2 is $legal"
|
||||
$legal = Get-NavContainerLegal -containerOrImageName $containerName
|
||||
Write-Host "Legal link of $containerName is $legal"
|
||||
|
||||
# Get-NavContainerCountry
|
||||
$country = Get-NavContainerCountry -containerOrImageName $imageName2
|
||||
Write-Host "Country of $imageName2 is $country"
|
||||
$country = Get-NavContainerCountry -containerOrImageName $containerName
|
||||
Write-Host "Country of $containerName is $country"
|
||||
|
||||
# Get-NavContainerIpAddress
|
||||
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
|
||||
Write-Host "IP Address of $containerName is $ipAddress"
|
||||
|
||||
# Get-NavContainerSharedFolders
|
||||
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
|
||||
Write-Host "Shared Folders with $containerName are:"
|
||||
$sharedFolders.GetEnumerator() | % { Write-Host ($_.Name + " -> " + $_.Value) }
|
||||
|
||||
# Get-NavContainerPath
|
||||
$path = "c:\programdata\navcontainerhelper\extensions\$containerName\my\AdditionalSetup.ps1"
|
||||
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
|
||||
Write-Host "Container Path of $path in $containerName is $containerPath"
|
||||
|
||||
# Get-NavContainerId
|
||||
$containerId = Get-NavcontainerId -containerName $containerName
|
||||
Write-Host "Id of $containerName is $containerId"
|
||||
|
||||
# Get-NavContainerName
|
||||
$containerName = Get-NavcontainerName -containerId $containerId
|
||||
Write-Host "Name of $containerId is $containerName"
|
||||
|
||||
# Import-ObjectsToNavContainer (.fob)
|
||||
Import-ObjectsToNavContainer -containerName $containerName `
|
||||
-objectsFile $fobPath `
|
||||
-sqlCredential $sqlCredential
|
||||
|
||||
# Compile-ObjectsToNavContainer
|
||||
Compile-ObjectsInNavContainer -containerName $containerName `
|
||||
-sqlCredential $sqlCredential
|
||||
|
||||
# Import-ObjectsToNavContainer (.txt)
|
||||
Import-ObjectsToNavContainer -containerName $containerName `
|
||||
-objectsFile $txtPath `
|
||||
-sqlCredential $sqlCredential
|
||||
|
||||
# Compile-ObjectsToNavContainer
|
||||
Compile-ObjectsInNavContainer -containerName $containerName `
|
||||
-sqlCredential $sqlCredential
|
||||
|
||||
# Convert-ModifiedObjectsToAl
|
||||
#Convert-ModifiedObjectsToAl -containerName $containerName `
|
||||
# -sqlCredential $sqlCredential `
|
||||
# -startId 50100
|
||||
|
||||
# Remove-NavContainer
|
||||
Remove-NavContainer -containerName $containerName
|
|
@ -0,0 +1,59 @@
|
|||
OBJECT Codeunit 50100 Test
|
||||
{
|
||||
OBJECT-PROPERTIES
|
||||
{
|
||||
Modified=Yes;
|
||||
Version List=;
|
||||
}
|
||||
PROPERTIES
|
||||
{
|
||||
TableNo=18;
|
||||
OnRun=BEGIN
|
||||
MESSAGE(Rec.Name);
|
||||
END;
|
||||
|
||||
}
|
||||
CODE
|
||||
{
|
||||
|
||||
BEGIN
|
||||
END.
|
||||
}
|
||||
}
|
||||
|
||||
OBJECT Page 50101 Test
|
||||
{
|
||||
OBJECT-PROPERTIES
|
||||
{
|
||||
Modified=Yes;
|
||||
Version List=;
|
||||
}
|
||||
PROPERTIES
|
||||
{
|
||||
SourceTable=Table18;
|
||||
PageType=Card;
|
||||
}
|
||||
CONTROLS
|
||||
{
|
||||
{ 1 ;0 ;Container ;
|
||||
ContainerType=ContentArea }
|
||||
|
||||
{ 2 ;1 ;Group ;
|
||||
Name=General;
|
||||
GroupType=Group }
|
||||
|
||||
{ 3 ;2 ;Field ;
|
||||
SourceExpr="No." }
|
||||
|
||||
{ 4 ;2 ;Field ;
|
||||
SourceExpr=Name }
|
||||
|
||||
}
|
||||
CODE
|
||||
{
|
||||
|
||||
BEGIN
|
||||
END.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
OBJECT Codeunit 50000 DeltaTest
|
||||
{
|
||||
OBJECT-PROPERTIES
|
||||
{
|
||||
Date=11/02/17;
|
||||
Time=12:38:30 PM;
|
||||
Modified=Yes;
|
||||
Version List=;
|
||||
}
|
||||
PROPERTIES
|
||||
{
|
||||
OnRun=BEGIN
|
||||
MESSAGE('Hello world');
|
||||
END;
|
||||
|
||||
}
|
||||
CODE
|
||||
{
|
||||
|
||||
BEGIN
|
||||
END.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
OBJECT Modification "Customer Card"(Page 21)
|
||||
{
|
||||
OBJECT-PROPERTIES
|
||||
{
|
||||
Date=11/02/17;
|
||||
Time=12:38:52 PM;
|
||||
Modified=Yes;
|
||||
Version List=NAVW111.0;
|
||||
}
|
||||
PROPERTIES
|
||||
{
|
||||
Target="Customer Card"(Page 21);
|
||||
TargetPageType=Card;
|
||||
}
|
||||
CHANGES
|
||||
{
|
||||
{ Insertion ;InsertAfter=Action 74;
|
||||
ChangedElements=ActionCollection
|
||||
{
|
||||
{ 50100 ;2 ;Action ;
|
||||
Name=Test;
|
||||
RunObject=Codeunit 50000 }
|
||||
}
|
||||
}
|
||||
{ Insertion ;InsertAfter=Control 69;
|
||||
ChangedElements=ControlCollection
|
||||
{
|
||||
{ 50101 ;2 ;Field ;
|
||||
SourceExpr=test }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
CODE
|
||||
{
|
||||
|
||||
BEGIN
|
||||
END.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
OBJECT Modification Customer(Table 18)
|
||||
{
|
||||
OBJECT-PROPERTIES
|
||||
{
|
||||
Date=11/02/17;
|
||||
Time=12:37:31 PM;
|
||||
Modified=Yes;
|
||||
Version List=NAVW111.0;
|
||||
}
|
||||
PROPERTIES
|
||||
{
|
||||
Target=Customer(Table 18);
|
||||
}
|
||||
CHANGES
|
||||
{
|
||||
{ Insertion ;InsertAfter="Contact Graph Id"(Field 9006);
|
||||
ChangedElements=FieldCollection
|
||||
{
|
||||
{ 50000; ;test ;Text30 }
|
||||
}
|
||||
}
|
||||
}
|
||||
CODE
|
||||
{
|
||||
|
||||
BEGIN
|
||||
END.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# This script performs a simple happy-path test of most navcontainerhelper functions
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
. (Join-Path $PSScriptRoot "..\..\NavContainerHelper.ps1")
|
||||
. (Join-Path $PSScriptRoot "..\settings.ps1")
|
||||
|
||||
"2016", "2017", "2018", "devpreview" | % {
|
||||
|
||||
$imageName = "microsoft/dynamics-nav:$_"
|
||||
|
||||
$containerName = "test"
|
||||
|
||||
Write-Host "$imagename"
|
||||
|
||||
# New-NavContainer single tenant
|
||||
New-NavContainer -accept_eula `
|
||||
-includeCSide `
|
||||
-doNotExportObjectsToText `
|
||||
-containerName $containerName `
|
||||
-imageName $imageName `
|
||||
-credential $credential `
|
||||
-UpdateHosts `
|
||||
-Auth Windows `
|
||||
|
||||
# Add user
|
||||
New-NavContainerNavUser -containerName $containerName -Credential $Credential -PermissionSetId SUPER
|
||||
|
||||
# # New-NavContainer single tenant
|
||||
# New-NavContainer -accept_eula `
|
||||
# -includeCSide `
|
||||
# -doNotExportObjectsToText `
|
||||
# -containerName $containerName `
|
||||
# -imageName $imageName `
|
||||
# -credential $credential `
|
||||
# -UpdateHosts `
|
||||
# -multitenant `
|
||||
# -Auth Windows `
|
||||
#
|
||||
# # Create Extra tenant
|
||||
# New-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
#
|
||||
# # Add user
|
||||
# New-NavContainerUser -containerName $containerName -tenant mytenant -Credential $Credential -PermissionSetId SUPER
|
||||
#
|
||||
# # Remove tenant
|
||||
# Remove-NavContainerTenant -containerName $containerName -tenantId mytenant
|
||||
}
|
||||
|
||||
# Remove-NavContainer
|
||||
Remove-NavContainer -containerName $containerName
|
|
@ -45,5 +45,5 @@ if ($credential -eq $null -or $credential -eq [System.Management.Automation.PSCr
|
|||
}
|
||||
$sqlCredential = New-Object System.Management.Automation.PSCredential ('sa', $credential.Password)
|
||||
|
||||
docker pull $imageName
|
||||
docker pull $imageName2
|
||||
#docker pull $imageName
|
||||
#docker pull $imageName2
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<#
|
||||
.Synopsis
|
||||
Creates a new NAV User in a Nav 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
|
||||
.Parameter containerName
|
||||
Name of the container in which you want to install the app (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)
|
||||
.Parameter WindowsAccount
|
||||
WindowsAccount of the new user (if using Windows authentication)
|
||||
.Parameter AuthenticationEmail
|
||||
AuthenticationEmail of the new user
|
||||
.Parameter ChangePasswordAtNextLogOn
|
||||
Switch to indicate that the user needs to change password at next login (if using NavUserPassword authentication)
|
||||
.Parameter PermissionSetId
|
||||
Name of the permissionSetId to assign to the user (default is SUPER)
|
||||
.Example
|
||||
New-NavContainerNavUser -containerName test -tenantId mytenant -credential $credential
|
||||
.Example
|
||||
New-NavContainerNavUser -containerName test -tenantId mytenant -WindowsAccount freddyk -PermissionSetId SUPER
|
||||
#>
|
||||
function New-NavContainerNavUser {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$tenant = "default",
|
||||
[parameter(Mandatory=$true, ParameterSetName="NavUserPassword")]
|
||||
[System.Management.Automation.PSCredential]$Credential,
|
||||
[parameter(Mandatory=$true, ParameterSetName="Windows")]
|
||||
[string]$WindowsAccount,
|
||||
[parameter(Mandatory=$false)]
|
||||
[string]$AuthenticationEmail,
|
||||
[parameter(Mandatory=$false, ParameterSetName="NavUserPassword")]
|
||||
[bool]$ChangePasswordAtNextLogOn = $true,
|
||||
[parameter(Mandatory=$false)]
|
||||
[string]$PermissionSetId = "SUPER"
|
||||
)
|
||||
|
||||
PROCESS
|
||||
{
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { param([System.Management.Automation.PSCredential]$Credential, [string]$Tenant, [string]$WindowsAccount, [string]$AuthenticationEMail, [bool]$ChangePasswordAtNextLogOn, [string]$PermissionSetId)
|
||||
|
||||
$TenantParam = @{}
|
||||
if ($Tenant) {
|
||||
$TenantParam.Add('Tenant', $Tenant)
|
||||
}
|
||||
$Parameters = @{}
|
||||
if ($AuthenticationEMail) {
|
||||
$Parameters.Add('AuthenticationEmail',$AuthenticationEmail)
|
||||
}
|
||||
if($WindowsAccount) {
|
||||
Write-Host "Creating NAV User for WindowsAccount $WindowsAccount"
|
||||
New-NAVServerUser -ServerInstance NAV @TenantParam -WindowsAccount $WindowsAccount @Parameters
|
||||
Write-Host "Assigning Permission Set $PermissionSetId to $WindowsAccount"
|
||||
New-NavServerUserPermissionSet -ServerInstance NAV @tenantParam -WindowsAccount $WindowsAccount -PermissionSetId $PermissionSetId
|
||||
} else {
|
||||
Write-Host "Creating NAV User $($Credential.UserName)"
|
||||
if ($ChangePasswordAtNextLogOn) {
|
||||
New-NAVServerUser -ServerInstance NAV @TenantParam -Username $Credential.UserName -Password $Credential.Password -ChangePasswordAtNextLogon @Parameters
|
||||
} else {
|
||||
New-NAVServerUser -ServerInstance NAV @TenantParam -Username $Credential.UserName -Password $Credential.Password @Parameters
|
||||
}
|
||||
Write-Host "Assigning Permission Set $PermissionSetId to $($Credential.Username)"
|
||||
New-NavServerUserPermissionSet -ServerInstance NAV @tenantParam -username $Credential.username -PermissionSetId $PermissionSetId
|
||||
}
|
||||
} `
|
||||
-ArgumentList $Credential, $Tenant, $WindowsAccount, $AuthenticationEMail, $ChangePasswordAtNextLogOn, $PermissionSetId
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function New-NavContainerNavUser
|
|
@ -0,0 +1,40 @@
|
|||
<#
|
||||
.Synopsis
|
||||
Creates a new Winodws User in a Nav container
|
||||
.Description
|
||||
Creates a new Windows user in a Nav container.
|
||||
.Parameter containerName
|
||||
Name of the container in which you want to install the app (default navserver)
|
||||
.Parameter Credential
|
||||
Credentials of the new Winodws user
|
||||
.Parameter group
|
||||
Name of the local group to add the user to (default is administrators)
|
||||
.Example
|
||||
New-NavContainerWindowsUser -containerName test -tenantId mytenant -username freddyk -password $password
|
||||
#>
|
||||
function New-NavContainerWindowsUser {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$containerName = "navserver",
|
||||
[Parameter(Mandatory=$true)]
|
||||
[System.Management.Automation.PSCredential]$Credential,
|
||||
[parameter(Mandatory=$false)]
|
||||
[string]$group = "administrators"
|
||||
)
|
||||
|
||||
PROCESS
|
||||
{
|
||||
$session = Get-NavContainerSession -containerName $containerName -silent
|
||||
Invoke-Command -Session $session -ScriptBlock { param([System.Management.Automation.PSCredential]$Credential, [string]$group)
|
||||
|
||||
Write-Host "Creating Windows user $($Credential.username)"
|
||||
New-LocalUser -AccountNeverExpires -FullName $Credential.username -Name $Credential.username -Password $Credential.Password | Out-Null
|
||||
Write-Host "Adding Windows user $($Credential.username) to $group"
|
||||
Add-LocalGroupMember -Group $group -Member $Credential.username -ErrorAction Ignore
|
||||
|
||||
} `
|
||||
-ArgumentList $Credential, $group
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function New-NavContainerWindowsUser
|
Загрузка…
Ссылка в новой задаче