-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from camiloborges/dev
adding xSPPasswordChangeSettings, xSPOutgoingEmailSettings, and adding blocked file types.
- Loading branch information
Showing
24 changed files
with
2,051 additions
and
27 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.psm1
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,87 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [System.String] $SMTPServer, | ||
[parameter(Mandatory = $true)] [System.String] $FromAddress, | ||
[parameter(Mandatory = $true)] [System.String] $ReplyToAddress, | ||
[parameter(Mandatory = $true)] [System.String] $CharacterSet, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
|
||
) | ||
|
||
Write-Verbose -Message "Retrieving outgoing email settings configuration " | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
$webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration -ErrorAction SilentlyContinue | ||
|
||
if ($null -eq $webApp) { | ||
return $null | ||
} | ||
return @{ | ||
WebAppUrl = $webApp.Url | ||
SMTPServer= $webApp.OutboundMailServiceInstance | ||
FromAddress= $webApp.OutboundMailSenderAddress | ||
ReplyToAddress= $webApp.OutboundMailReplyToAddress | ||
CharacterSet = $webApp.OutboundMailCodePage | ||
} | ||
} | ||
return $result | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [System.String] $SMTPServer, | ||
[parameter(Mandatory = $true)] [System.String] $FromAddress, | ||
[parameter(Mandatory = $true)] [System.String] $ReplyToAddress, | ||
[parameter(Mandatory = $true)] [System.String] $CharacterSet, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Updating outgoing email settings configuration for $WebAppUrl" | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
$webApp = $null | ||
Write-Verbose -Message "retrieving $($params.WebAppUrl) settings" | ||
$webApp = Get-SPWebApplication $params.WebAppUrl -IncludeCentralAdministration | ||
if($null -eq $webApp) | ||
{ | ||
throw "Web Application $webAppUrl not found" | ||
} | ||
$webApp.UpdateMailSettings($params.SMTPServer, $params.FromAddress, $params.ReplyToAddress, $params.CharacterSet) | ||
} | ||
} | ||
|
||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [System.String] $SMTPServer, | ||
[parameter(Mandatory = $true)] [System.String] $FromAddress, | ||
[parameter(Mandatory = $true)] [System.String] $ReplyToAddress, | ||
[parameter(Mandatory = $true)] [System.String] $CharacterSet, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
Write-Verbose -Message "Comparing Current and Target Outgoing email settings" | ||
if ($null -eq $CurrentValues) { return $false } | ||
|
||
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("SMTPServer","FromAddress","ReplyToAddress","CharacterSet") | ||
} | ||
|
||
|
||
Export-ModuleMember -Function *-TargetResource | ||
|
29 changes: 29 additions & 0 deletions
29
...Point/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof
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,29 @@ | ||
/* | ||
**Description** | ||
|
||
This resource is used to set the outgoing email settings for either a single web application, or the whole farm. | ||
To configure the resource for a specific web app, use the URL of the web application for the WebAppUrl property, to change the settings for the whole farm use the URL of the central admin website instead. | ||
It is possible to set the outgoing server, from address, reply to address and the character set to be used for emails. | ||
|
||
**Example** | ||
|
||
xSPOutgoingEmailSettings FarmWideEmailSettings | ||
{ | ||
WebAppUrl = "http://sharepoint1:2013" | ||
SMTPServer = "smtp.contoso.com" | ||
FromAddress = "[email protected]" | ||
ReplyToAddress = "[email protected]" | ||
PsDscRunAsCredential = $InstallAccount | ||
} | ||
*/ | ||
[ClassVersion("1.0.0.0"), FriendlyName("xSPOutgoingEmailSettings")] | ||
class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource | ||
{ | ||
[key] string WebAppUrl; | ||
[Write] string SMTPServer; | ||
[Write] string FromAddress; | ||
[Write] string ReplyToAddress; | ||
[Write] string CharacterSet; | ||
[Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; | ||
}; | ||
|
87 changes: 87 additions & 0 deletions
87
...harePoint/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.psm1
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,87 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $MailAddress, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Retrieving farm wide automatic password change settings" | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
$farm = Get-SPFarm | ||
if ($null -eq $farm ) { return $null } | ||
return @{ | ||
MailAddress = $farm.PasswordChangeEmailAddress | ||
PasswordChangeWaitTimeSeconds= $farm.PasswordChangeGuardTime | ||
NumberOfRetries= $farm.PasswordChangeMaximumTries | ||
DaysBeforeExpiry = $farm.DaysBeforePasswordExpirationToSendEmail | ||
} | ||
} | ||
return $result | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $MailAddress, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Updating farm wide automatic password change settings" | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
$farm = Get-SPFarm -ErrorAction Continue | ||
|
||
if ($null -eq $farm ) { return $null } | ||
|
||
$farm.PasswordChangeEmailAddress = $params.MailAddress; | ||
if($params.PasswordChangeWaitTimeSeconds -ne $null) { | ||
$farm.PasswordChangeGuardTime = $params.PasswordChangeWaitTimeSeconds | ||
} | ||
if($params.NumberOfRetries -ne $null) { | ||
$farm.PasswordChangeMaximumTries = $params.NumberOfRetries | ||
} | ||
if($params.DaysBeforeExpiry -ne $null) { | ||
$farm.DaysBeforePasswordExpirationToSendEmail = $params.DaysBeforeExpiry | ||
} | ||
$farm.Update(); | ||
} | ||
} | ||
|
||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $MailAddress, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,356)] [System.UInt32] $DaysBeforeExpiry, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,36000)][System.UInt32] $PasswordChangeWaitTimeSeconds, | ||
[parameter(Mandatory = $false)] [ValidateRange(0,99)] [System.UInt32] $NumberOfRetries, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
Write-Verbose -Message "Testing retrieving farm wide automatic password change settings" | ||
if ($null -eq $CurrentValues) { return $false } | ||
|
||
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("MailAddress", "DaysBeforeExpiry","PasswordChangeWaitTimeSeconds","NumberOfRetries") | ||
} | ||
|
||
|
||
Export-ModuleMember -Function *-TargetResource | ||
|
27 changes: 27 additions & 0 deletions
27
...int/DSCResources/MSFT_xSPPasswordChangeSettings/MSFT_xSPPasswordChangeSettings.schema.mof
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,27 @@ | ||
/* | ||
**Description** | ||
|
||
This resource is used to control settings that relate to the automatic changing of passwords for managed accounts (where they opt-in to be managed by SharePoint). | ||
These settings can be manually controlled through central administration, or configured in this resource. | ||
The settings relate to email notifications of when passwords are reset, as well as behavior when a reset occurs such as a time out and number of retries. | ||
|
||
**Example** | ||
|
||
xSPPasswordChangeSettings ManagedAccountPasswordResetSettings | ||
{ | ||
MailAddress = "[email protected]" | ||
DaysBeforeExpiry = "14" | ||
PasswordChangeWaitTimeSeconds = "60" | ||
NumberOfRetries = "3" | ||
PsDscRunAsCredential = $InstallAccount | ||
} | ||
*/ | ||
[ClassVersion("1.0.0.0"), FriendlyName("xSPPasswordChangeSettings")] | ||
class MSFT_xSPPasswordChangeSettings : OMI_BaseResource | ||
{ | ||
[key] string MailAddress; | ||
[Write] Uint32 DaysBeforeExpiry; | ||
[Write] Uint32 PasswordChangeWaitTimeSeconds; | ||
[Write] Uint32 NumberOfRetries; | ||
[Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; | ||
}; |
Oops, something went wrong.