-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathSetupWebClient.ps1
60 lines (52 loc) · 2.93 KB
/
SetupWebClient.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Remove Default Web Site
Get-WebSite | Remove-WebSite
Get-WebBinding | Remove-WebBinding
$certparam = @{}
if ($servicesUseSSL) {
$certparam += @{CertificateThumbprint = $certificateThumbprint}
}
Write-Host "Registering event sources"
"MicrosoftDynamicsNAVClientWebClient","MicrosoftDynamicsNAVClientClientService" | % {
if (-not [System.Diagnostics.EventLog]::SourceExists($_)) {
$frameworkDir = (Get-Item "HKLM:\SOFTWARE\Microsoft\.NETFramework").GetValue("InstallRoot")
New-EventLog -LogName Application -Source $_ -MessageResourceFile (get-item (Join-Path $frameworkDir "*\EventLogMessages.dll")).FullName
}
}
Write-Host "Creating DotNetCore Web Server Instance"
$publishFolder = "$webClientFolder\WebPublish"
$NAVWebClientManagementModule = "$webClientFolder\Modules\NAVWebClientManagement\NAVWebClientManagement.psm1"
if (!(Test-Path $NAVWebClientManagementModule)) {
$NAVWebClientManagementModule = "$webClientFolder\Scripts\NAVWebClientManagement.psm1"
}
Import-Module $NAVWebClientManagementModule
New-NAVWebServerInstance -PublishFolder $publishFolder `
-WebServerInstance "$WebServerInstance" `
-Server "localhost" `
-ServerInstance "$ServerInstance" `
-ClientServicesCredentialType $Auth `
-ClientServicesPort "$clientServicesPort" `
-WebSitePort $webClientPort @certparam
$navsettingsFile = Join-Path $wwwRootPath "$WebServerInstance\navsettings.json"
$config = Get-Content $navSettingsFile | ConvertFrom-Json
Add-Member -InputObject $config.NAVWebSettings -NotePropertyName "RequireSSL" -NotePropertyValue "true" -ErrorAction SilentlyContinue
$config.NAVWebSettings.RequireSSL = $false
Add-Member -InputObject $config.NAVWebSettings -NotePropertyName "PersonalizationEnabled" -NotePropertyValue "true" -ErrorAction SilentlyContinue
$config.NAVWebSettings.PersonalizationEnabled = $true
$config.NAVWebSettings.ManagementServicesPort = $ManagementServicesPort
if ($customWebSettings -ne "") {
Write-Host "Modifying Web Client config with settings from environment variable"
$customWebSettingsArray = $customWebSettings -split ","
foreach ($customWebSetting in $customWebSettingsArray) {
$customWebSettingArray = $customWebSetting -split "="
$customWebSettingKey = $customWebSettingArray[0]
$customWebSettingValue = $customWebSettingArray[1]
if ($config.NAVWebSettings.$customWebSettingKey -eq $null) {
Write-Host "Creating $customWebSettingKey and setting it to $customWebSettingValue"
$config.NAVWebSettings | Add-Member $customWebSettingKey $customWebSettingValue
} else {
Write-Host "Setting $customWebSettingKey to $customWebSettingValue"
$config.NAVWebSettings.$customWebSettingKey = $customWebSettingValue
}
}
}
$config | ConvertTo-Json | set-content $navSettingsFile