forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-SetDatabaseOwner.ps1
39 lines (36 loc) · 1.1 KB
/
1-SetDatabaseOwner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.EXAMPLE
This example shows how to ensure that the user account CONTOSO\SQLAdmin
is "Owner" of SQL database "AdventureWorks".
#>
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$SysAdminAccount
)
Import-DscResource -ModuleName xSqlServer
node localhost
{
xSQLServerLogin Add_SqlServerLogin_SQLAdmin
{
Ensure = 'Present'
Name = 'CONTOSO\SQLAdmin'
LoginType = 'WindowsUser'
SQLServer = 'SQLServer'
SQLInstanceName = 'DSC'
PsDscRunAsCredential = $SysAdminAccount
}
xSQLServerDatabaseOwner Set_SqlDatabaseOwner_SQLAdmin
{
Name = 'CONTOSO\SQLAdmin'
Database = 'AdventureWorks'
SQLServer = 'SQLServer'
SQLInstanceName = 'DSC'
PsDscRunAsCredential = $SysAdminAccount
}
}
}