forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-DisableDatabaseMail.ps1
47 lines (41 loc) · 1.29 KB
/
2-DisableDatabaseMail.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
40
41
42
43
44
45
46
47
<#
.DESCRIPTION
This example will remove the mail profile and the mail account and
disable Database Mail on a SQL Server instance.
#>
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlInstallCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost {
SqlDatabaseMail 'DisableDatabaseMail'
{
Ensure = 'Absent'
ServerName = $Node.NodeName
InstanceName = 'DSCSQLTEST'
AccountName = 'MyMail'
ProfileName = 'MyMailProfile'
EmailAddress = '[email protected]'
MailServerName = 'mail.company.local'
PsDscRunAsCredential = $SqlInstallCredential
}
<#
Don't disable the Database Mail XPs if there are still mail accounts
left configured.
#>
SqlConfiguration 'DisableDatabaseMailXPs'
{
ServerName = $Node.NodeName
InstanceName = 'DSCSQLTEST'
OptionName = 'Database Mail XPs'
OptionValue = 0
RestartService = $false
}
}
}