-
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 #114 from BrianFarnhill/merge-pr96
Fixes to release v0.8
- Loading branch information
Showing
28 changed files
with
756 additions
and
567 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
88 changes: 88 additions & 0 deletions
88
...harePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.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,88 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $Url, | ||
[parameter(Mandatory = $false)] [System.String[]] $Blocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Getting web application '$url' blocked file types" | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { | ||
$params = $args[0] | ||
$ScriptRoot = $args[1] | ||
|
||
|
||
$wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue | ||
if ($null -eq $wa) { return $null } | ||
|
||
Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) | ||
|
||
$result = Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa | ||
$result.Add("Url", $params.Url) | ||
$result.Add("InstallAccount", $params.InstallAccount) | ||
return $result | ||
} | ||
return $result | ||
} | ||
|
||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $Url, | ||
[parameter(Mandatory = $false)] [System.String[]] $Blocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Setting web application '$Url' blocked file types" | ||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments @($PSBoundParameters,$PSScriptRoot) -ScriptBlock { | ||
$params = $args[0] | ||
$ScriptRoot = $args[1] | ||
|
||
$wa = Get-SPWebApplication -Identity $params.Url -ErrorAction SilentlyContinue | ||
if ($null -eq $wa) { | ||
throw "Web application $($params.Url) was not found" | ||
return | ||
} | ||
|
||
Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) | ||
Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params | ||
$wa.Update() | ||
} | ||
} | ||
|
||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $Url, | ||
[parameter(Mandatory = $false)] [System.String[]] $Blocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureBlocked, | ||
[parameter(Mandatory = $false)] [System.String[]] $EnsureAllowed, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
Write-Verbose -Message "Testing for web application '$Url' blocked file types" | ||
if ($null -eq $CurrentValues) { return $false } | ||
|
||
Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) | ||
return Test-xSPWebApplicationBlockedFileTypes -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters | ||
} | ||
|
||
|
||
Export-ModuleMember -Function *-TargetResource | ||
|
30 changes: 30 additions & 0 deletions
30
...int/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.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,30 @@ | ||
/* | ||
**Description** | ||
|
||
This resource is responsible for controlling the blocked file type setting on a specific web application. | ||
It has two modes of operation, the first is to use the 'blocked' property, where you are able to define a specific list of file types that will be blocked. | ||
In this mode when it is detected that the list does not match the local farm, it is set to match this list exactly. | ||
The second mode is to use the 'EnsureBlocked' and 'EnsureAllowed' properties. | ||
EnsureBlocked will check to make sure that the specified file types are on the list, and if not they will be added. | ||
EnsureAllowed checks to make sure that a file type is not on the list, and if it is it will be removed. | ||
Both of these properties will only make changes to the file types in their list and will leave the full list as it is otherwise, whereas the blocked property resets the list in full. | ||
|
||
**Example** | ||
|
||
xSPBlockedFileTypes PrimaryWebAppBlockedFileTypes | ||
{ | ||
Url = "Shttp://exmaple.contoso.local" | ||
EnsureBlocked = @("exe", "dll", "msi") | ||
EnsureAllowed = @("pdf", "docx", "xlsx") | ||
PsDscRunAsCredential = $InstallAccount | ||
} | ||
*/ | ||
[ClassVersion("1.0.0"), FriendlyName("xSPWebAppBlockedFileTypes")] | ||
Class MSFT_xSPWebAppBlockedFileTypes : OMI_BaseResource | ||
{ | ||
[Key] string Url; | ||
[write] string Blocked[]; | ||
[write] string EnsureBlocked[]; | ||
[write] string EnsureAllowed[]; | ||
[Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; | ||
}; |
Oops, something went wrong.