小编给大家分享一下如何部署自动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 unrestricted import-module "C:\Program Files\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1" Push-Location #jump back to standard prompt with pop-location import-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 $AddServiceAccountAsDbo pop-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 status Set-NAVServerConfiguration $MyNAVServerName -KeyName DatabaseName -KeyValue $MyNewDatabaseName Set-NAVServerInstance $MyNAVServerName -restart Get-NAVServerInstance $MyNAVServerName
以上是“如何部署自动Microsoft Dynamics NAV”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。