-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateDatabaseApp.ps1
52 lines (36 loc) · 2.46 KB
/
CreateDatabaseApp.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
$DataBaseServer = "localhost"
$AppDatabaseName = "Tenant2"
$NewCompanyName = "My Company"
$PathLicenseFile = "C:\VengoVision\BC\hwm-bc22ru-7732379.bclicense"
$PathSystemApp = "C:\VengoVision\BC\BC-V22\BC-V22\Dynamics.365.BC.46853.RU.DVD\Applications\system application\source\Microsoft_System Application.app"
$PathBasicApp = "C:\VengoVision\BC\BC-V22\BC-V22\Dynamics.365.BC.46853.RU.DVD\Applications\BaseApp\Source\Microsoft_Base Application.app"
$TempServerInstance = "SingleIns"
$TempServerInstancePort = 12345
# Создаём instance на котором будем создавать базу
New-NAVServerInstance -ServerInstance $TempServerInstance -ManagementServicesPort $TempServerInstancePort -ClientServicesCredentialType Windows -Force
Set-NAVServerInstance -ServerInstance $TempServerInstance -Start
# Создаём базу
New-NAVApplicationDatabase -DatabaseName $AppDatabaseName -DatabaseServer $DataBaseServer -Force
# Перенастраиваем instance
Set-NAVServerConfiguration -ServerInstance $TempServerInstance -Keyname Multitenant -KeyValue "false"
Set-NAVServerConfiguration -ServerInstance $TempServerInstance -Keyname DatabaseName -KeyValue $AppDatabaseName
Restart-NAVServerInstance -ServerInstance $TempServerInstance -Force
# Импортируем лицензию
Import-NAVServerLicense -ServerInstance $TempServerInstance -LicenseFile $PathLicenseFile -Force
Restart-NAVServerInstance -ServerInstance $TempServerInstance -Force
# Синхронизируем базу с instance
Sync-NAVTenant -ServerInstance $TempServerInstance -Force
# Публикуем, синхронизируем и устанавливаем базовые приложения
Publish-NAVApp -ServerInstance $TempServerInstance -Path $PathSystemApp -Force -SkipVerification
Publish-NAVApp -ServerInstance $TempServerInstance -Path $PathBasicApp -Force -SkipVerification
$AppList = Get-NAVAppInfo -ServerInstance $TempServerInstance
foreach ($App in $AppList)
{
Sync-NAVApp -ServerInstance $TempServerInstance -AppId $App.AppId -Force
Install-NAVApp -ServerInstance $TempServerInstance -AppId $App.AppId -Force
}
# Создаём компанию
New-NAVCompany -ServerInstance $TempServerInstance -CompanyName $NewCompanyName -Force
# Удаляем ранее созданный instance
Set-NAVServerInstance -ServerInstance $TempServerInstance -Stop
Remove-NAVServerInstance -ServerInstance $TempServerInstance -Force