千家信息网

如何部署自动Microsoft Dynamics NAV

发表于:2025-01-19 作者:千家信息网编辑
千家信息网最后更新 2025年01月19日,小编给大家分享一下如何部署自动Microsoft Dynamics NAV,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!背
千家信息网最后更新 2025年01月19日如何部署自动Microsoft Dynamics NAV

小编给大家分享一下如何部署自动Microsoft Dynamics NAV,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

背景:

客户在以下情况下会增加一个新的Microsoft Dynamics NAV系统

--新建一个分支机构

--新建一系列测试

--开始一个新的财务年度

--等等

在实践阶段一个"新的Microsoft Dynamics NAV系统"可以使一个新的Microsoft Dynamics NAV 实例,一个database,一个company或者是一个tenant。为了简化介绍我们重用现有的Microsoft Dynamics NAV Service创建我们的新的database。

准备工作:

我们使用import-module sqlps.来导入SQLServer的PowerShell。安装SQLServer的时候提供了SQLPS,但是不安装SQL也可以获得该module。

如果在运行PS的机器上没有安装SQLSever,可以按照下面的地址安装Microsoft SQL Server 2012Feature Pack:

http://www.microsoft.com/en-us/download/details.aspx?id=29065

以下是代码

#准备工作$MyNAVServerName = "DynamicsNAV80"$MySQLServerName = "."$MyNewCustomerName = "NewCustomer"$MyNewDatabaseName = "NewCustomerDatabase"Set-ExecutionPolicy unrestrictedimport-module "C:\Program Files\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"Push-Location #jump back to standard prompt with pop-locationimport-module sqlps #ignore any warnings you may get#Restore SQL db (NAV demo db)#Relocate database files http://stackoverflow.com/questions/26400752/cannot-bind-relocatefile-when-using-restore-sqldatabase-cmdlet $mdf = New-Object Microsoft.SqlServer.Management.Smo.RelocateFile("Demo Database NAV (8-0)_Data", "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\DB_Data_$MyNewCustomerName.mdf")$ldf = New-Object Microsoft.SqlServer.Management.Smo.RelocateFile("Demo Database NAV (8-0)_Log", "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\DB_Log_$MyNewCustomerName.ldf")restore-SqlDatabase -ServerInstance $MySQLServerName `                                       -Database $MyNewDatabaseName `                                        -BackupFile "C:\NAVDVD\SQLDemoDatabase\CommonAppData\Microsoft\Microsoft Dynamics NAV\80\Database\Demo Database NAV (8-0).bak" `                                        -ReplaceDatabase `                                        -RelocateFile @($mdf,$ldf)                                       #Set network service as dbo$CreateServiceAccountUser = "CREATE USER [NT AUTHORITY\NETWORK SERVICE] FOR LOGIN [NT AUTHORITY\NETWORK SERVICE]"Invoke-Sqlcmd -ServerInstance $MySQLServerName -Database $MyNewDatabaseName -Query $CreateServiceAccountUser$AddServiceAccountAsDbo = "exec sp_addrolemember 'db_owner', 'NT AUTHORITY\NETWORK SERVICE'"Invoke-Sqlcmd -ServerInstance $MySQLServerName -Database $MyNewDatabaseName -Query $AddServiceAccountAsDbopop-location # Finished with SQL commands so popping back to normal PS prompt#For NAV 2013(R2), to convert the database to latest executable version.#For NAV 2015 we don't need this (in fact we don't have the Invoke-DatabaseConversion cmdlet).import-module "C:\PSscripts\Upgrade\Cmdlets\NAVUpgradeCmdlets.psm1"Invoke-NAVDatabaseConversion -DatabaseServer localhost -DatabaseName "Demo Database NAV (7-1)" -FinSqlExeFile "C:\Program Files\Microsoft Dynamics NAV\71\Service\finsql.exe"#At this point the next steps depend on whether we want a new NAV Service, connect to an existing one, etc. Here we just reuse existing NAV Service#Configure then restart the service and get statusSet-NAVServerConfiguration $MyNAVServerName -KeyName DatabaseName -KeyValue $MyNewDatabaseName Set-NAVServerInstance $MyNAVServerName -restartGet-NAVServerInstance $MyNAVServerName

以上是"如何部署自动Microsoft Dynamics NAV"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

0