New-MasterDataServicesDatabase (PowerShell)

创建 Master Data Services 数据库。

语法

New-MasterDataServicesDatabase [-Server] <Microsoft.MasterDataServices.Configuration.DatabaseServerInformation>
      [-DatabaseName] <String> [-AdminAccount] <String> [-Collation <String>]

说明

New-MasterDataServicesDatabase 创建 Master Data Services 数据库。它验证指定的 SQL Server 实例是否是可承载 Master Data Services 数据库的受支持版本和版本类别,并且验证指定帐户是否有权在该实例上创建数据库。

参数

-Server

Server 参数是 Get-MasterDataServicesDatabaseServerInformation 中的一个数据库服务器信息对象。此对象用于连接要创建 Master Data Services 数据库的 SQL Server 实例。

必需?

true

位置?

0

默认值

接受管道输入

true (ByValue)

接受通配符?

false

-DatabaseName

DatabaseName 参数是一个用于指定新的 Master Data Services 数据库名称的字符串。

必需?

true

位置?

1

默认值

接受管道输入

false

接受通配符?

false

-AdminAccount

AdminAccount 参数是一个字符串,该字符串指定域和 Windows 帐户,以便向新的 Master Data Services 数据库授权。

必需?

true

位置?

2

默认值

接受管道输入

false

接受通配符?

false

-Collation

Collation 参数是一个字符串,该字符串可为新的 Master Data Services 数据库指定排序规则。

必需?

false

位置?

所指定位置

默认值

服务器的默认排序规则。

接受管道输入

false

接受通配符?

false

输入和输出

输入类型是可以传送到 cmdlet 的对象的类型。返回类型是 cmdlet 所返回的对象的类型。

输入

Microsoft.MasterDataServices.Configuration.DatabaseServerInformation

来自 Get-MasterDataServicesDatabaseServerInformation 的数据库服务器信息对象。

输出

示例

输出

下例是在使用此 cmdlet 时所返回的输出的示例。

Name             : MyDatabase
HasAccess        : True
Collation        : SQL_Latin1_General_CP1_CI_AS
ServiceAccount   :
MdsAdministrator : MyDomain\AccountName
Server           : Microsoft.MasterDataServices.Configuration.DatabaseServerInformation
IsDatabaseOwner  : True

使用变量和命名参数

此示例使用 Get-MasterDataServicesDatabaseServerInformation cmdlet 设置了一个变量 $server,以用于 New-MasterDataServicesDatabase cmdlet 中的 Server 参数。这些参数是命名参数,而且由于未指定排序规则,所以对新数据库使用了默认排序规则。

C:\PS> $server = Get-MasterDataServicesDatabaseServerInformation 
    -ConnectionString 'Data Source=MyServer\MyInstance;Initial catalog=;Integrated Security=True;User ID=;Password='; 
    New-MasterDataServicesDatabase -Server $server 
    -DatabaseName 'MyDatabase' -AdminAccount 'MyDomain\AccountName';

传送输出和使用命名参数

此示例针对 New-MasterDataServicesDatabase 中的 Server 参数,将 Get-MasterDataServicesDatabaseServerInformation 的输出传送到 New-MasterDataServicesDatabase。这些参数是命名参数。

C:\PS> Get-MasterDataServicesDatabaseServerInformation 
    -ConnectionString 'Data Source=MyServer\MyInstance;Initial catalog=;Integrated Security=True;User ID=;Password=' | 
    New-MasterDataServicesDatabase -DatabaseName 'MyDatabase' 
    -AdminAccount 'MyDomain\AccountName' -Collation 'SQL_Latin1_General_CP1_CI_AS';

使用变量和位置参数

此示例使用 Get-MasterDataServicesDatabaseServerInformation cmdlet 设置了一个变量 $server,以用于 New-MasterDataServicesDatabase cmdlet 中的 Server 参数。这些参数是位置参数,而且由于未指定排序规则,所以对新数据库使用了默认排序规则。

C:\PS> $server = Get-MasterDataServicesDatabaseServerInformation 
    -ConnectionString 'Data Source=MyServer\MyInstance;Initial catalog=;Integrated Security=True;User ID=;Password='; 
    New-MasterDataServicesDatabase $server 'MyDatabase' 'MyDomain\AccountName';