New Management Admin Cmdlets

Windows PowerShell is becoming ever more used in the professional IT organization, and in Microsoft Dynamics NAV we are continuously extending and improving the set of administration management PowerShell cmdlets.

With hotfix 2791548, we introduce these additions and updates, all fully backward compatible with cmdlets shipped with Microsoft Dynamics NAV 2013:

  • New-NAVServerInstance
    • Creates a new Microsoft Dynamics NAV Server instance – new parameters
  • New-NAVWebServerInstance
    • Creates a new Microsoft Dynamics NAV Web Server instance and binds this instance to a Microsoft Dynamics NAV Server instance – new
  • New-NAVDatabase
    • Creates a new Microsoft Dynamics NAV database from a backup file – new
  • Rename-NAVCompany
    • Renames a company in a Microsoft Dynamics NAV database – new

Note

To use the new and changed cmdlets, you must obtain the relevant hotfix through your Microsoft Dynamics NAV support contact. For more information, see the KnowledgeBase article for the hotfix (requires access to PartnerSource/CustomerSource).

The rest of this blog post describes the cmdlets at a summary level. The full documentation is available on the MSDN Library. Additional documentation is available at Microsoft Dynamics NAV Windows PowerShell Cmdlets.

New-NAVServerInstance

Creates a new Microsoft Dynamics NAV Server instance.

Syntax

Parameter Set: __AllParameterSets

New-NAVServerInstance [-ServerInstance] <String> -ManagementServicesPort <ServicePort> [-ClientServicesCertificateThumbprint <String> ] [-ClientServicesCredentialType <String> ] [-ClientServicesPort <ServicePort> ] [-DatabaseInstance <String> ] [-DatabaseName <String> ] [-DatabaseServer <String> ] [-ODataServicesPort <ServicePort> ] [-ServiceAccount {<LocalService> | <NetworkService> | <LocalSystem> | <User>} ] [-ServiceAccountCredential <PSCredential> ] [-SOAPServicesPort <ServicePort> ] [ <CommonParameters>]

Detailed Description

Use the New-NAVServerInstance cmdlet to create a new Microsoft Dynamics NAV Server instance. You must specify a name for the instance, in addition to values for the four port parameters. All other configuration values for the new instance are based on default values. Make sure that you verify the DatabaseServer and DatabaseName values after the instance is created, to ensure that the instance can accept client requests.
All permissions that are required for the instance to start are configured automatically.

See Also

 For more information, see New-NAVServerInstance on the MSDN Library.

Examples

Example 1

This example creates a new Microsoft Dynamics NAV Server instance. It configures the necessary firewall exceptions and performs the necessary Access Control List registrations.

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

 

C:\PS>New-NAVServerInstance NewInstance -ManagementServicesPort 8099 -ClientServicesPort 8100 -SOAPServicesPort 8101 -ODataServicesPort 8102 –verbose

 

VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Creating Instance directory C:\Program Files (x86)\Microsoft Dynamics NAV\70\Service\Instances\NewInstance

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: NavCommand.EndProcessing

Example 2

This example prompts for ServiceAccount credentials and then creates a new Microsoft Dynamics NAV Server instance.

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

 

C:\PS>Get-Credential | New-NAVServerInstance NewInstance -ServiceAccount User -ManagementServicesPort 8099 -ClientServicesPort 8100 -SOAPServicesPort 8101 -ODataServicesPort 8102 –verbose

 

VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Creating Instance directory C:\Program Files (x86)\Microsoft Dynamics NAV\70\Service\Instances\NewInstance

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: Adding Windows Firewall (and UrlAcl) rules for Server Instance MicrosoftDynamicsNavServer$NewNAVServer

VERBOSE: NavCommand.EndProcessing

 

New-NAVWebServerInstance

Creates a new Microsoft Dynamics NAV Web Server instance and binds this instance to a Microsoft Dynamics NAV Server instance.

Syntax

Parameter Set: Default

New-NAVWebServerInstance -Server <String> -ServerInstance <String> -WebServerInstance <String> [-ClientServicesCredentialType <String> ] [-ClientServicesPort <String> ] [-DnsIdentity <String> ] [ <CommonParameters>]

Detailed Description

Use the New-NAVWebServerInstance cmdlet to create a new Microsoft Dynamics NAV Web Server instance and bind this instance to a Microsoft Dynamics NAV Server instance on the same computer or on a remote
computer. If you call this cmdlet multiple times then multiple instances of the Microsoft Dynamics NAV Web Server are created. Each instance of the Microsoft Dynamics NAV Web Server is created as an IIS Web application under a generic Microsoft Dynamics NAV Web Server web site.

See Also

For more information, see New-NAVWebServerInstance on the MSDN Library.

 

New-NAVDatabase

Creates a new Microsoft Dynamics NAV database from a backup file.

Syntax

Parameter Set: __AllParameterSets

New-NAVDatabase [-FilePath] <String> -DatabaseName <String> [-DatabaseInstance <String> ] [-DatabaseServer <String> ] [-Force] [-ServiceAccount <String> ] [ <CommonParameters>]

 

Parameter Set: MultipleDestinations

New-NAVDatabase [-FilePath] <String> -DatabaseName <String> -DataFilesDestinationPath <String> -LogFilesDestinationPath <String> [-DatabaseInstance <String> ] [-DatabaseServer <String> ] [-Force] [-ServiceAccount <String> ] [ <CommonParameters>]

 

Parameter Set: SingleDestination

New-NAVDatabase [-FilePath] <String> -DatabaseName <String> -DestinationPath <String> [-DatabaseInstance <String> ] [-DatabaseServer <String> ] [-Force] [-ServiceAccount <String> ] [ <CommonParameters>]

Detailed Description

Use the New-NAVDatabase cmdlet to restore a database from a backup file. You can specify the location of transaction log files and data files.

You can use this cmdlet to restore a database to a remote SQL Server instance or to a SQL Server instance that is running on the same computer on which you run the cmdlet.

See Also

For more information, see New-NAVDatabase on the MSDN Library.

Examples

Example 1

This example restores a database and preserves the original file names and locations.

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

 

New-NAVDatabase C:\Backups\backup1.bak –DatabaseName NewDatabase –Verbose | fl

 

VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Restoring database ‘NewDatabase’ from backup file: ‘C:\Backups\backup1.bak’…

VERBOSE: Restore of database ‘NewDatabase’ from file ‘C:\Backups\backup1.bak’ has been completed successfully.

DatabaseName : NewDatabase

DatabaseInstance : MSSQLSERVER

DatabaseServer : server1.cronus.com

VERBOSE: NavCommand.EndProcessing

Example 2

This example restores a database, moves transaction log files and data files to the new location ‘C:\newdestination’, and preserves the original file names.

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

 

New-NAVDatabase C:\Backups\backup.bak -DestinationPath c:\newdestination -DatabaseName NewDatabase –Verbose

 

VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Restoring database ‘NewDatabase’ from backup file: ‘C:\Backups\backup.bak’…

VERBOSE: Restore of database ‘NewDatabase’ from file ‘C:\Backups\backup.bak’ has been completed successfully.

DatabaseName DatabaseInstance DatabaseServer

———— —————- ————–

NewDatabase MSSQLSERVER server1.cronus.com

VERBOSE: NavCommand.EndProcessing 

 

Rename-NAVCompany

Renames a company in a Microsoft Dynamics NAV database.

Syntax

Parameter Set: Default

Rename-NAVCompany -CompanyName <String> -DatabaseName <String> -NewCompanyName <String> [-DatabaseInstance <String> ] [-DatabaseServer <String> ] [-ErrorLogFileName <String> ] [ <CommonParameters>]

Detailed Description

Use the Rename-NAVCompany cmdlet to rename a company in a Microsoft Dynamics NAV database.

See Also

For more information, see Rename-NAVCompany on the MSDN Library.

Examples

Example 1

This example renames the company Cronus Ltd. in the Cronus database to MyCompany.

// Copyright © Microsoft Corporation. All Rights Reserved.

// This code released under the terms of the

// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

 

Rename-NAVCompany -DatabaseName Cronus -CompanyName “Cronus Ltd.” -NewCompanyName MyCompany –Verbose

 

VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Renaming company ‘Cronus Ltd.’ to ‘MyCompany’ …

VERBOSE: Renaming of company ‘Cronus Ltd.’ to ‘MyCompany’ has completed successfully.

VERBOSE: NavCommand.EndProcessing

Example 2

This example renames the company Cronus Ltd. in the Cronus database to MyCompany. Errors are logged to the file C:\NavDatabases\ErrorLog.txt.

Rename-NAVCompany -DatabaseName Cronus -CompanyName “Cronus Ltd.” -NewCompanyName MyCompany -ErrorLogFileName C:\NavDatabases\ErrorLog.txt

 

– Morten Jensen and the rest of the Microsoft Dynamics NAV Management Tools team