forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
256 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
Examples/Resources/SqlServerDatabaseMail/2-EnableDatabaseMailWithSsl.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<# | ||
.EXAMPLE | ||
This example will enable Database Mail on a SQL Server instance and | ||
create a mail account with a default public profile. | ||
#> | ||
$ConfigurationData = @{ | ||
AllNodes = @( | ||
@{ | ||
NodeName = 'localhost' | ||
ServerName = $env:COMPUTERNAME | ||
InstanceName = 'DSCSQLTEST' | ||
|
||
MailServerName = 'mail.company.local' | ||
AccountName = 'MyMail' | ||
ProfileName = 'MyMailProfile' | ||
EmailAddress = '[email protected]' | ||
Description = 'Default mail account and profile.' | ||
LoggingLevel = 'Normal' | ||
TcpPort = 25 | ||
EnableSsl = $true | ||
} | ||
) | ||
} | ||
|
||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[System.Management.Automation.PSCredential] | ||
$SqlInstallCredential | ||
) | ||
|
||
Import-DscResource -ModuleName 'SqlServerDsc' | ||
|
||
node localhost { | ||
|
||
SqlServerConfiguration 'EnableDatabaseMailXPs' | ||
{ | ||
ServerName = $Node.ServerName | ||
InstanceName = $Node.InstanceName | ||
OptionName = 'Database Mail XPs' | ||
OptionValue = 1 | ||
RestartService = $false | ||
} | ||
|
||
SqlServerDatabaseMail 'EnableDatabaseMail' | ||
{ | ||
Ensure = 'Present' | ||
ServerName = $Node.ServerName | ||
InstanceName = $Node.InstanceName | ||
AccountName = $Node.AccountName | ||
ProfileName = $Node.ProfileName | ||
EmailAddress = $Node.EmailAddress | ||
ReplyToAddress = $Node.EmailAddress | ||
DisplayName = $Node.MailServerName | ||
MailServerName = $Node.MailServerName | ||
Description = $Node.Description | ||
LoggingLevel = $Node.LoggingLevel | ||
TcpPort = $Node.TcpPort | ||
EnableSsl = $Node.EnableSsl | ||
|
||
PsDscRunAsCredential = $SqlInstallCredential | ||
} | ||
} | ||
} | ||
|
75 changes: 75 additions & 0 deletions
75
Examples/Resources/SqlServerDatabaseMail/3-EnableDatabaseMailWithAuthentication.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<# | ||
.EXAMPLE | ||
This example will enable Database Mail on a SQL Server instance and | ||
create a mail account with a default public profile. | ||
#> | ||
$ConfigurationData = @{ | ||
AllNodes = @( | ||
@{ | ||
NodeName = 'localhost' | ||
ServerName = $env:COMPUTERNAME | ||
InstanceName = 'DSCSQLTEST' | ||
|
||
MailServerName = 'mail.company.local' | ||
AccountName = 'MyMail' | ||
ProfileName = 'MyMailProfile' | ||
EmailAddress = '[email protected]' | ||
Description = 'Default mail account and profile.' | ||
LoggingLevel = 'Normal' | ||
TcpPort = 25 | ||
Authentication = 'Basic' | ||
} | ||
) | ||
} | ||
|
||
Configuration Example | ||
{ | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[System.Management.Automation.PSCredential] | ||
$SqlInstallCredential, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[System.Management.Automation.PSCredential] | ||
$SMTPAccountCredential | ||
) | ||
|
||
Import-DscResource -ModuleName 'SqlServerDsc' | ||
|
||
node localhost { | ||
|
||
SqlServerConfiguration 'EnableDatabaseMailXPs' | ||
{ | ||
ServerName = $Node.ServerName | ||
InstanceName = $Node.InstanceName | ||
OptionName = 'Database Mail XPs' | ||
OptionValue = 1 | ||
RestartService = $false | ||
} | ||
|
||
SqlServerDatabaseMail 'EnableDatabaseMail' | ||
{ | ||
Ensure = 'Present' | ||
ServerName = $Node.ServerName | ||
InstanceName = $Node.InstanceName | ||
AccountName = $Node.AccountName | ||
ProfileName = $Node.ProfileName | ||
EmailAddress = $Node.EmailAddress | ||
ReplyToAddress = $Node.EmailAddress | ||
DisplayName = $Node.MailServerName | ||
MailServerName = $Node.MailServerName | ||
Description = $Node.Description | ||
LoggingLevel = $Node.LoggingLevel | ||
TcpPort = $Node.TcpPort | ||
Authentication = $Node.Authentication | ||
SMTPAccount = $SMTPAccountCredential | ||
|
||
PsDscRunAsCredential = $SqlInstallCredential | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,6 @@ $ConfigurationData = @{ | |
AccountName = 'MyMail' | ||
ProfileName = 'MyMailProfile' | ||
EmailAddress = '[email protected]' | ||
Description = 'Default mail account and profile.' | ||
LoggingLevel = 'Normal' | ||
TcpPort = 25 | ||
} | ||
) | ||
} | ||
|
@@ -34,7 +31,8 @@ Configuration Example | |
|
||
Import-DscResource -ModuleName 'SqlServerDsc' | ||
|
||
node localhost { | ||
Node localhost { | ||
|
||
SqlServerDatabaseMail 'DisableDatabaseMail' | ||
{ | ||
Ensure = 'Absent' | ||
|
@@ -54,7 +52,6 @@ Configuration Example | |
#> | ||
SqlServerConfiguration 'DisableDatabaseMailXPs' | ||
{ | ||
|
||
ServerName = $Node.ServerName | ||
InstanceName = $Node.InstanceName | ||
OptionName = 'Database Mail XPs' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.