Compartir a través de


Add-CrmDatabase

Restores or attaches to SQL Server the specified Dynamics 365 database from a Microsoft SQL Server MDF (raw database file) or a SQL Server backup file.

Syntax

Add-CrmDatabase
   [-SqlServerName] <String>
   [-DatabaseName] <String>
   [-DatabaseMdfFileName] <String>
   [[-DatabaseLdfFileName] <String>]
   [-Timeout <Int32>]
   [-Diag]
   [-Credential <PSCredential>]
   [-DwsServerUrl <String>]
   [-WhatIf]
   [-Confirm]
Add-CrmDatabase
   [-SqlServerName] <String>
   [-DatabaseName] <String>
   [-DatabaseBackupFileName] <String>
   [-Timeout <Int32>]
   [-Diag]
   [-Credential <PSCredential>]
   [-DwsServerUrl <String>]
   [-WhatIf]
   [-Confirm]

Description

The Add-CrmDatabase cmdlet restores or attaches to SQL Server the specified Dynamics 365 organization database from a backup of an organization database or from a detached organization database.

Examples

Example 1

PS C:\> Add-CrmDatabase -SqlServerName sqlserver -DatabaseName contoso_MSCRM -DatabaseBackupFileName contoso_MSCRM.bak -Credential $Cred -DwsServerUrl https://contoso

Restores the specified SQL backup contoso_MSCRM.BAK file of a Dynamics 365 organization database to the SQL Server named sqlserver.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Credential

Variable that contains the user credentials used for signing in to Dynamics 365 on-premises organization. To establish this variable, run the PowerShell command $Cred = Get-Credential.

Type:PSCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DatabaseBackupFileName

Specifies the name of the SQL Server backup file. This should be a full backup file of the source Dynamics 365 organization database. This file must be accessible from the computer that’s running SQL Server.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DatabaseLdfFileName

The name of the SQL Server database LDF file. This file must be accessible from the computer that’s running SQL Server.

Type:String
Position:3
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DatabaseMdfFileName

Specifies the name of the SQL Server Database MDF file. This file must be accessible from the computer that’s running SQL Server.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DatabaseName

Specifies the name of the organization database to import.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Diag

Turns on stack traces for error reports returned from Dynamics 365 service calls. Enabling this emits a detailed error message, including a stack trace, when an error is encountered by the Dynamics 365 PowerShell command.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DwsServerUrl

The URL of the Deployment Web Service. This should be in the format: https://, for example, https://contoso.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SqlServerName

Specifies a string that contains the name of the Microsoft SQL Server or SQL Server instance on which to restore or attach the organization database.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Timeout

For internal use only.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

System.String

System.Int32 System.Management.Automation.SwitchParameter System.Management.Automation.PSCredential

Outputs

System.Object