diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 index 088d1b7ad..46fcce03f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPInstallPrereqs/MSFT_xSPInstallPrereqs.psm1 @@ -37,10 +37,10 @@ function Get-TargetResource Write-Verbose -Message "Getting installed windows features" if ($majorVersion -eq 15) { - $WindowsFeatures = Get-WindowsFeature -Name Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer + $WindowsFeatures = Get-WindowsFeature -Name Application-Server, AS-NET-Framework, AS-TCP-Port-Sharing, AS-Web-Support, AS-WAS-Support, AS-HTTP-Activation, AS-Named-Pipes, AS-TCP-Activation, Web-Server, Web-WebServer, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Static-Content, Web-Http-Redirect, Web-Health, Web-Http-Logging, Web-Log-Libraries, Web-Request-Monitor, Web-Http-Tracing, Web-Performance, Web-Stat-Compression, Web-Dyn-Compression, Web-Security, Web-Filtering, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Cert-Auth, Web-IP-Security, Web-Url-Auth, Web-Windows-Auth, Web-App-Dev, Web-Net-Ext, Web-Net-Ext45, Web-Asp-Net, Web-Asp-Net45, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Mgmt-Tools, Web-Mgmt-Console, Web-Mgmt-Compat, Web-Metabase, Web-Lgcy-Scripting, Web-WMI, Web-Scripting-Tools, NET-Framework-Features, NET-Framework-Core, NET-Framework-45-ASPNET, NET-WCF-HTTP-Activation45, NET-WCF-Pipe-Activation45, NET-WCF-TCP-Activation45, Server-Media-Foundation, Windows-Identity-Foundation, PowerShell-V2, WAS, WAS-Process-Model, WAS-NET-Environment, WAS-Config-APIs, XPS-Viewer } if ($majorVersion -eq 16) { - $WindowsFeatures = Get-WindowsFeature -Name Application-Server,AS-NET-Framework,AS-Web-Support,Web-Server,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Static-Content,Web-Http-Redirect,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Basic-Auth,Web-Client-Auth,Web-Digest-Auth,Web-Cert-Auth,Web-IP-Security,Web-Url-Auth,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Web-Lgcy-Mgmt-Console,Web-Lgcy-Scripting,Web-WMI,Web-Scripting-Tools,NET-Framework-Features,NET-Framework-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-Framework-45-ASPNET,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,PowerShell-V2,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs + $WindowsFeatures = Get-WindowsFeature -Name Application-Server, AS-NET-Framework, AS-Web-Support, Web-Server, Web-WebServer, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Static-Content, Web-Http-Redirect, Web-Health, Web-Http-Logging, Web-Log-Libraries, Web-Request-Monitor, Web-Performance, Web-Stat-Compression, Web-Dyn-Compression, Web-Security, Web-Filtering, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Cert-Auth, Web-IP-Security, Web-Url-Auth, Web-Windows-Auth, Web-App-Dev, Web-Net-Ext, Web-Net-Ext45, Web-Asp-Net45, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Mgmt-Tools, Web-Mgmt-Console, Web-Mgmt-Compat, Web-Metabase, Web-Lgcy-Mgmt-Console, Web-Lgcy-Scripting, Web-WMI, Web-Scripting-Tools, NET-Framework-Features, NET-Framework-Core, NET-HTTP-Activation, NET-Non-HTTP-Activ, NET-Framework-45-ASPNET, NET-WCF-HTTP-Activation45, Windows-Identity-Foundation, PowerShell-V2, WAS, WAS-Process-Model, WAS-NET-Environment, WAS-Config-APIs } foreach ($feature in $WindowsFeatures) { @@ -51,26 +51,28 @@ function Get-TargetResource $installedItems = Get-CimInstance -ClassName Win32_Product #Common prereqs - $returnValue.Add("Microsoft Identity Extensions", (@(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ -Recurse | ? {$_.GetValue("DisplayName") -eq "Microsoft Identity Extensions" }).Count -gt 0)) + $returnValue.Add("AppFabric 1.1 for Windows Server", (($installedItems | ? {$_.Name -eq "AppFabric 1.1 for Windows Server"}) -ne $null)) $returnValue.Add("Microsoft CCR and DSS Runtime 2008 R3", (($installedItems | ? {$_.Name -eq "Microsoft CCR and DSS Runtime 2008 R3"}) -ne $null)) + $returnValue.Add("Microsoft Identity Extensions", (@(Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ -Recurse | ? {$_.GetValue("DisplayName") -eq "Microsoft Identity Extensions" }).Count -gt 0)) $returnValue.Add("Microsoft Sync Framework Runtime v1.0 SP1 (x64)", (($installedItems | ? {$_.Name -eq "Microsoft Sync Framework Runtime v1.0 SP1 (x64)"}) -ne $null)) - $returnValue.Add("AppFabric 1.1 for Windows Server", (($installedItems | ? {$_.Name -eq "AppFabric 1.1 for Windows Server"}) -ne $null)) $returnValue.Add("WCF Data Services 5.6.0 Runtime", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.6.0 Runtime"}) -ne $null)) #SP2013 prereqs if ($majorVersion -eq 15) { - $returnValue.Add("WCF Data Services 5.0 (for OData v3) Primary Components", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.0 (for OData v3) Primary Components"}) -ne $null)) - $returnValue.Add("Microsoft SQL Server 2008 R2 Native Client", (($installedItems | ? {$_.Name -eq "Microsoft SQL Server 2008 R2 Native Client"}) -ne $null)) $returnValue.Add("Active Directory Rights Management Services Client 2.0", (($installedItems | ? {$_.Name -eq "Active Directory Rights Management Services Client 2.0"}) -ne $null)) + $returnValue.Add("Microsoft SQL Server 2008 R2 Native Client", (($installedItems | ? {$_.Name -eq "Microsoft SQL Server 2008 R2 Native Client"}) -ne $null)) + $returnValue.Add("WCF Data Services 5.0 (for OData v3) Primary Components", (($installedItems | ? {$_.Name -eq "WCF Data Services 5.0 (for OData v3) Primary Components"}) -ne $null)) } #SP2016 prereqs if ($majorVersion -eq 16) { - $returnValue.Add("Microsoft ODBC Driver 11 for SQL Server", (($installedItems | ? {$_.Name -eq "Microsoft ODBC Driver 11 for SQL Server"}) -ne $null)) - $returnValue.Add("Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005"}) -ne $null)) - $returnValue.Add("Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005"}) -ne $null)) - $returnValue.Add("Microsoft SQL Server 2012 Native Client", (($installedItems | ? {$_.Name -ne $null -and $_.Name.Trim() -eq "Microsoft SQL Server 2012 Native Client"}) -ne $null)) $returnValue.Add("Active Directory Rights Management Services Client 2.1", (($installedItems | ? {$_.Name -eq "Active Directory Rights Management Services Client 2.1"}) -ne $null)) + $returnValue.Add("Microsoft SQL Server 2012 Native Client", (($installedItems | ? {$_.Name -ne $null -and $_.Name.Trim() -eq "Microsoft SQL Server 2012 Native Client"}) -ne $null)) + $returnValue.Add("Microsoft ODBC Driver 11 for SQL Server", (($installedItems | ? {$_.Name -eq "Microsoft ODBC Driver 11 for SQL Server"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026"}) -ne $null)) + $returnValue.Add("Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026", (($installedItems | ? {$_.Name -eq "Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026"}) -ne $null)) } $results = $PSBoundParameters @@ -145,8 +147,7 @@ function Set-TargetResource switch ($process.ExitCode) { 0 { - Write-Verbose -Message "Prerequisite installer completed successfully. Rebooting to finalise installations" - $global:DSCMachineStatus = 1 + Write-Verbose -Message "Prerequisite installer completed successfully." } 1 { throw "Another instance of the prerequisite installer is already running" diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof index ac95787f2..292799962 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPOutgoingEmailSettings/MSFT_xSPOutgoingEmailSettings.schema.mof @@ -20,10 +20,10 @@ It is possible to set the outgoing server, from address, reply to address and th class MSFT_xSPOutgoingEmailSettings : OMI_BaseResource { [key] string WebAppUrl; - [Write] string SMTPServer; - [Write] string FromAddress; - [Write] string ReplyToAddress; - [Write] string CharacterSet; + [Required] string SMTPServer; + [Required] string FromAddress; + [Required] string ReplyToAddress; + [Required] string CharacterSet; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 new file mode 100644 index 000000000..d18569e3b --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.psm1 @@ -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 + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof new file mode 100644 index 000000000..123a88276 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppBlockedFileTypes/MSFT_xSPWebAppBlockedFileTypes.schema.mof @@ -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; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 new file mode 100644 index 000000000..167a00d21 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 @@ -0,0 +1,124 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' general settings" + + $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.GeneralSettings.psm1" -Resolve) + + $result = Get-xSPWebApplicationGeneralSettings -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.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Applying general settings '$Url'" + $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.GeneralSettings.psm1" -Resolve) + Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params + $wa.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $TimeZone, + [parameter(Mandatory = $false)] [System.Boolean] $Alerts, + [parameter(Mandatory = $false)] [System.UInt32] $AlertsLimit, + [parameter(Mandatory = $false)] [System.Boolean] $RSS, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPI, + [parameter(Mandatory = $false)] [System.Boolean] $BlogAPIAuthenticated, + [parameter(Mandatory = $false)] [ValidateSet("Stric","Permissive")] [System.String] $BrowserFileHandling, + [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $RecycleBinRetentionPeriod, + [parameter(Mandatory = $false)] [System.UInt32] $SecondStageRecycleBinQuota, + [parameter(Mandatory = $false)] [System.UInt32] $MaximumUploadSize, + [parameter(Mandatory = $false)] [System.Boolean] $CustomerExperienceProgram, + [parameter(Mandatory = $false)] [System.Boolean] $PresenceEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application general settings '$Url'" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) + return Test-xSPWebApplicationGeneralSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof new file mode 100644 index 000000000..f6e535682 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.schema.mof @@ -0,0 +1,39 @@ +/* +**Description** + +This resource is responsible for setting web application settings that are found under the "general settings" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). + +**Example** + + xSPWebAppGeneralSettings PrimaryWebAppGeneralSettings + { + Url = "Shttp://exmaple.contoso.local" + TimeZone = 76 + Alerts = $true + RSS = $false + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppGeneralSettings")] +Class MSFT_xSPWebAppGeneralSettings : OMI_BaseResource +{ + [Key] string Url; + [write] uint32 TimeZone; + [write] boolean Alerts; + [write] uint32 AlertsLimit; + [write] boolean RSS; + [write] boolean BlogAPI; + [write] boolean BlogAPIAuthenticated; + [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; + [write] boolean SecurityValidation; + [write] boolean RecycleBinEnabled; + [write] boolean RecycleBinCleanupEnabled; + [write] uint32 RecycleBinRetentionPeriod; + [write] uint32 SecondStageRecycleBinQuota; + [write] uint32 MaximumUploadSize; + [write] boolean CustomerExperienceProgram; + [write] boolean PresenceEnabled; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 new file mode 100644 index 000000000..9484b4ecc --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.psm1 @@ -0,0 +1,118 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' throttling settings" + + $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.Throttling.psm1" -Resolve) + + $result = Get-xSPWebApplicationThrottlingSettings -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.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting web application '$Url' throttling settings" + $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.Throttling.psm1" -Resolve) + Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params + $wa.Update() + + # Happy hour settings + if ($params.ContainsKey("HappyHour") -eq $true) { + # Happy hour settins use separate update method so use a fresh web app to update these + $wa2 = Get-SPWebApplication -Identity $params.Url + Set-xSPWebApplicationHappyHourSettings -WebApplication $wa2 -Settings $params.HappyHour + } + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $AllowObjectModelOverride, + [parameter(Mandatory = $false)] [System.UInt32] $AdminThreshold, + [parameter(Mandatory = $false)] [System.UInt32] $ListViewLookupThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $HappyHourEnabled, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $HappyHour, + [parameter(Mandatory = $false)] [System.UInt32] $UniquePermissionThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $RequestThrottling, + [parameter(Mandatory = $false)] [System.Boolean] $ChangeLogEnabled, + [parameter(Mandatory = $false)] [System.UInt32] $ChangeLogExpiryDays, + [parameter(Mandatory = $false)] [System.Boolean] $EventHandlersEnabled, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application '$Url' throttling settings" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) + return Test-xSPWebApplicationThrottlingSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof new file mode 100644 index 000000000..e7673af15 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppThrottlingSettings/MSFT_xSPWebAppThrottlingSettings.schema.mof @@ -0,0 +1,50 @@ +[ClassVersion("1.0.0")] +Class MSFT_xSPWebApplicationHappyHour +{ + [write] uint32 Hour; + [write] uint32 Minute; + [write] uint32 Duration; + +}; +/* +**Description** + +This resource is responsible for setting web application settings that are found under the "resource throttling" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). +Happy hour is the setting used to control the window where threshold do not apply throughout the day. +You can specify the start time of this window as well as how many hours it will last. + +**Example** + + xSPWebAppThrottlingSettings PrimaryWebAppThrottlingSettings + { + Url = "Shttp://exmaple.contoso.local" + ListViewThreshold = 5000 + AllowObjectModelOverride = $false + HappyHourEnabled = $true + HappyHour = MSFT_xSPWebApplicationHappyHour { + Hour = 3 + Minute = 0 + Duration = 1 + } + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppThrottlingSettings")] +Class MSFT_xSPWebAppThrottlingSettings : OMI_BaseResource +{ + [Key] string Url; + [write] uint32 ListViewThreshold; + [write] boolean AllowObjectModelOverride; + [write] uint32 AdminThreshold; + [write] uint32 ListViewLookupThreshold; + [write] boolean HappyHourEnabled; + [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] string HappyHour; + [write] uint32 UniquePermissionThreshold; + [write] boolean RequestThrottling; + [write] boolean ChangeLogEnabled; + [write] uint32 ChangeLogExpiryDays; + [write] boolean EventHandlersEnabled; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 new file mode 100644 index 000000000..c5841a5d6 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.psm1 @@ -0,0 +1,87 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting web application '$url' workflow settings" + + $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.Workflow.psm1" -Resolve) + + $result = Get-xSPWebApplicationWorkflowSettings -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.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting web application '$Url' workflow settings" + $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.Workflow.psm1" -Resolve) + Set-xSPWebApplicationWorkflowSettings -WebApplication $wa -Settings $params + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Url, + [parameter(Mandatory = $false)] [System.Boolean] $ExternalWorkflowParticipantsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $UserDefinedWorkflowsEnabled, + [parameter(Mandatory = $false)] [System.Boolean] $EmailToNoPermissionWorkflowParticipantsEnable, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for web application '$Url' workflow settings" + if ($null -eq $CurrentValues) { return $false } + + Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) + return Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof new file mode 100644 index 000000000..4dfa86c7f --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppWorkflowSettings/MSFT_xSPWebAppWorkflowSettings.schema.mof @@ -0,0 +1,26 @@ +/* +**Description** + +This resource is responsible for setting web application settings that are found under the "workflow settings" screen in central admin. +The web application is specified through the URL property, and then any combination of settings can be applied. +Any settings not included will be left as the default (or whatever they have been manually changed to within SharePoint). + +**Example** + + xSPWebAppWorkflowSettings PrimaryWebAppWorkflowSettings + { + Url = "Shttp://exmaple.contoso.local" + ExternalWorkflowParticipantsEnabled = $false + EmailToNoPermissionWorkflowParticipantsEnable = $false + PsDscRunAsCredential = $InstallAccount + } +*/ +[ClassVersion("1.0.0"), FriendlyName("xSPWebAppWorkflowSettings")] +Class MSFT_xSPWebAppWorkflowSettings : OMI_BaseResource +{ + [Key] string Url; + [write] boolean ExternalWorkflowParticipantsEnabled; + [write] boolean UserDefinedWorkflowsEnabled; + [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; +}; \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 deleted file mode 100644 index c3af6e4d3..000000000 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.Set.ps1 +++ /dev/null @@ -1,188 +0,0 @@ -function Set-BlockedFiles($blockedFiles, $wa) -{ - - if($blockedFiles -eq $null){return;} - if($blockedFiles.Blocked -ne $null ){ - $wa.BlockedFileExtensions.Clear(); - $blockedFiles.Blocked| % { - $wa.BlockedFileExtensions.Add($_) ; - - } - } - if($blockedFiles.EnsureBlocked -ne $null){ - $blockedFiles.EnsureBlocked| % { - if(!$wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Add($_) ; - } - } - } - if($blockedFiles.EnsureAllowed -ne $null){ - $blockedFiles.EnsureAllowed | % { - if($wa.BlockedFileExtensions.ContainExtension($_)){ - $wa.BlockedFileExtensions.Remove($_) - } - } - } - -} -function Get-ValueOrDefault($input, $attribute, $defaultValue) -{ - try{ - if($input."$attribute" -ne $null) - { - return $input."$attribute" - }else { - return $defaultValue - } - }catch - { - return $defaultValue - } -} -function Set-GeneralSettings($generalSettings, $wa) -{ - if($generalSettings -eq $null){ return;} - - #TODO: Quota Template - $wa.DefaultTimeZone =Get-ValueOrDefault $generalSettings "TimeZone" $wa.DefaultTimeZone - $wa.AlertsEnabled = Get-ValueOrDefault $generalSettings "Alerts" $wa.AlertsEnabled - $wa.AlertsMaximum = Get-ValueOrDefault $generalSettings "AlertsLimit" $wa.AlertsMaximum - $wa.SyndicationEnabled = Get-ValueOrDefault $generalSettings "RSS" $wa.RSS - $wa.MetaWeblogEnabled = Get-ValueOrDefault $generalSettings "BlogAPI" $wa.BlogAPI - $wa.MetaWeblogAuthenticationEnabled = Get-ValueOrDefault $generalSettings "BlogAPIAuthenticated" $wa.BlogAPIAuthenticated - $wa.BrowserFileHandling = Get-ValueOrDefault $generalSettings "BrowserFileHandling" $wa.BrowserFileHandling - $wa.FormDigestSettings.Enabled = Get-ValueOrDefault $generalSettings "SecurityValidation" $wa.FormDigestSettings.Enabled - $wa.MaximumFileSize = Get-ValueOrDefault $generalSettings "MaximumUploadSize" $wa.MaximumUploadSize - $wa.RecycleBinEnabled = Get-ValueOrDefault $generalSettings "RecycleBinEnabled" $wa.RecycleBinEnabled - $wa.RecycleBinCleanupEnabled = Get-ValueOrDefault $generalSettings "RecycleBinCleanupEnabled" $wa.RecycleBinCleanupEnabled - $wa.RecycleBinRetentionPeriod = Get-ValueOrDefault $generalSettings "RecycleBinRetentionPeriod" $wa.RecycleBinRetentionPeriod - $wa.SecondStageRecycleBinQuota = Get-ValueOrDefault $generalSettings "SecondStageRecycleBinEnabled" $wa.SecondStageRecycleBinQuota - $wa.BrowserCEIPEnabled = Get-ValueOrDefault $generalSettings "CustomerExperienceProgram" $wa.BrowserCEIPEnabled - $wa.PresenceEnabled = Get-ValueOrDefault $generalSettings "Presence" $wa.BrowserCEIPEnabled - $wa.Update(); -} -function Set-WorkflowSettings ($workflowSettings, $wa) -{ - if($workflowSettings -eq $null ){ return;} - if($workflowSettings.UserDefinedWorkflowsEnabled -ne $null){ - $wa.UserDefinedWorkflowsEnabled = $workflowSettings.UserDefinedWorkflowsEnabled; - } - if($workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable -ne $null){ - $wa.EmailToNoPermissionWorkflowParticipantsEnabled = $workflowSettings.EmailToNoPermissionWorkflowParticipantsEnable; - } - if($workflowSettings.ExternalWorkflowParticipantsEnabled -ne $null){ - $wa.ExternalWorkflowParticipantsEnabled = $workflowSettings.ExternalWorkflowParticipantsEnabled; - } - - $wa.UpdateWorkflowConfigurationSettings(); - $wa.Update(); -} - -function Set-ThrottlingSettings ($throttlingSettings, $wa) -{ - if($throttlingSettings -eq $null){ return;} - if($throttlingSettings.ListViewThreshold -ne $null ){ - $wa.MaxItemsPerThrottledOperation = $throttlingSettings.ListViewThreshold - } - if($throttlingSettings.AllowObjectModelOverride -ne $null){ - $wa.AllowOMCodeOverrideThrottleSettings = $throttlingSettings.AllowObjectModelOverride - } - if($throttlingSettings.AdminThreshold -ne $null){ - $wa.MaxItemsPerThrottledOperationOverride = $throttlingSettings.AdminThreshold - } - if($throttlingSettings.ListViewLookupThreshold -ne $null){ - $wa.MaxQueryLookupFields = $throttlingSettings.ListViewLookupThreshold - } - if($throttlingSettings.HappyHourEnabled -ne $null){ - $wa.UnthrottledPrivilegedOperationWindowEnabled =$throttlingSettings.HappyHourEnabled - } - if($throttlingSettings.HappyHour -ne $null){ - $happyHour =$throttlingSettings.HappyHour; - if(($happyHour.Hour -ne $null) -and ($happyHour.Minute -ne $null) -and ($happyHour.Duration -ne $null)){ - if(($happyHour.Hour -le 24) -and ($happyHour.Minute -le 24) -and ($happyHour.Duration -le 24)){ - $wa.DailyStartUnthrottledPrivilegedOperationsHour = $happyHour.Hour - $wa.DailyStartUnthrottledPrivilegedOperationsMinute = $happyHour.Minute - $wa.DailyUnthrottledPrivilegedOperationsDuration = $happyHour.Duration - }else{ - throw "the valid range hour, minute and duration is 0-24"; - } - - }else { - throw "You need to Provide Hour, Minute and Duration when providing HappyHour settings"; - } - } - if($throttlingSettings.UniquePermissionThreshold){ - $wa.MaxUniquePermScopesPerList = $throttlingSettings.UniquePermissionThreshold - } - if($throttlingSettings.EventHandlersEnabled){ - $wa.EventHandlersEnabled = $throttlingSettings.EventHandlersEnabled - } - if($throttlingSettings.RequestThrottling){ - $wa.HttpThrottleSettings.PerformThrottle = $throttlingSettings.RequestThrottling - } - if($throttlingSettings.ChangeLogEnabled){ - $wa.ChangeLogExpirationEnabled = $throttlingSettings.ChangeLogEnabled - } - if($throttlingSettings.ChangeLogExpiryDays){ - $wa.ChangeLogRetentionPeriod = New-TimeSpan -Days $throttlingSettings.ChangeLogExpiryDays - } - $wa.Update(); -} - -function GetAndRemove-Parameter($params, $name){ - $result =$null - if($params.ContainsKey($name)) - { - $result = $params.$name - $params.Remove( $name) - } - return $result; -} -function Sanitize-ComplexTypes{ - param( - [Parameter(Position = 0)] - - $params - ) - -$blocked =GetAndRemove-Parameter $params "BlockedFileTypes" - return @{ - GeneralSettings = GetAndRemove-Parameter $params "GeneralSettings" - WorkflowSettings = GetAndRemove-Parameter $params "WorkflowSettings" - Extensions = GetAndRemove-Parameter $params "Extensions" - ThrottlingSettings = GetAndRemove-Parameter $params "ThrottlingSettings" - BlockedFileTypes = $blocked - } -} - - -$params = $args[0] - -$settings = Sanitize-ComplexTypes $params - -$wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue -if ($null -eq $wa) { - if ($params.ContainsKey("AuthenticationMethod") -eq $true) { - if ($params.AuthenticationMethod -eq "NTLM") { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos - } else { - $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication - } - $params.Remove("AuthenticationMethod") - $params.Add("AuthenticationProvider", $ap) - } - - if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } - if ($params.ContainsKey("AllowAnonymous")) { - $params.Remove("AllowAnonymous") | Out-Null - $params.Add("AllowAnonymousAccess", $true) - } - - $wa = New-SPWebApplication @params -} - -Set-ThrottlingSettings $settings.ThrottlingSettings $wa -Set-WorkflowSettings $settings.WorkflowSettings $wa -Set-BlockedFiles $settings.BlockedFileTypes $wa -Set-GeneralSettings $settings.GeneralSettings $wa - \ No newline at end of file diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 index b7b829558..1aaffa8cc 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.psm1 @@ -15,11 +15,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Getting web application '$Name'" @@ -28,18 +24,12 @@ function Get-TargetResource $params = $args[0] $ScriptRoot = $args[1] - $wa = Get-SPWebApplication -Identity $params.Name -ErrorAction SilentlyContinue if ($null -eq $wa) { return $null } $authProvider = Get-SPAuthenticationProvider -WebApplication $wa.Url -Zone "Default" if ($authProvider.DisableKerberos -eq $true) { $localAuthMode = "NTLM" } else { $localAuthMode = "Kerberos" } - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - return @{ Name = $wa.DisplayName ApplicationPool = $wa.ApplicationPool.Name @@ -53,10 +43,6 @@ function Get-TargetResource Port = (New-Object System.Uri $wa.Url).Port AuthenticationMethod = $localAuthMode InstallAccount = $params.InstallAccount - ThrottlingSettings = (Get-xSPWebApplicationThrottlingSettings -WebApplication $wa) - WorkflowSettings = (Get-xSPWebApplicationWorkflowSettings -WebApplication $wa) - BlockedFileTypes = (Get-xSPWebApplicationBlockedFileTypes -WebApplication $wa) - GeneralSettings = (Get-xSPWebApplicationGeneralSettings -WebApplication $wa) } } return $result @@ -79,11 +65,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Creating web application '$Name'" @@ -118,48 +100,6 @@ function Set-TargetResource $wa = New-SPWebApplication @newWebAppParams } - - # Resource throttling settings - if ($params.ContainsKey("ThrottlingSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - Set-xSPWebApplicationThrottlingSettings -WebApplication $wa -Settings $params.ThrottlingSettings - } - - # Blocked file types - if ($params.ContainsKey("BlockedFileTypes") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - Set-xSPWebApplicationBlockedFileTypes -WebApplication $wa -Settings $params.BlockedFileTypes - } - - # General Settings - if ($params.ContainsKey("GeneralSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - Set-xSPWebApplicationGeneralSettings -WebApplication $wa -Settings $params.GeneralSettings - } - - if( ($params.GeneralSettings -ne $null) -or - ($params.ThrottlingSettings -ne $null) -or - ($params.BlockedFileTypes -ne $null) ) { - $wa.Update() - } - - # Workflow settings - if ($params.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - # Workflow uses a seperate update method, to avoid update conflicts get a fresh web app object - $wa2 = Get-SPWebApplication -Identity $params.Name - Set-xSPWebApplicationWorkflowSettings -WebApplication $wa2 -Settings $params.WorkflowSettings - } - - # Happy hour settings - if ($params.ContainsKey("ThrottlingSettings") -eq $true) { - if ((Test-xSharePointObjectHasProperty $params.ThrottlingSettings "HappyHour") -eq $true) { - Import-Module (Join-Path $ScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - # Happy hour settins use separate update method so use a fresh web app to update these - $wa3 = Get-SPWebApplication -Identity $params.Name - Set-xSPWebApplicationHappyHourSettings -WebApplication $wa3 -Settings $params.ThrottlingSettings.HappyHour - } - } } } @@ -181,11 +121,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Path, [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [ValidateSet("NTLM","Kerberos")] [System.String] $AuthenticationMethod, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $GeneralSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $WorkflowSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ThrottlingSettings, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $BlockedFileTypes + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) $CurrentValues = Get-TargetResource @PSBoundParameters @@ -195,37 +131,6 @@ function Test-TargetResource $testReturn = Test-xSharePointSpecificParameters -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool") - - if ($testReturn -eq $false) { return $false } - - # Resource throttling settings - if ($PSBoundParameters.ContainsKey("ThrottlingSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Throttling.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationThrottlingSettings -CurrentSettings $CurrentValues.ThrottlingSettings -DesiredSettings $ThrottlingSettings - } - if ($testReturn -eq $false) { return $false } - - # Workflow settings - if ($PSBoundParameters.ContainsKey("WorkflowSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.Workflow.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationWorkflowSettings -CurrentSettings $CurrentValues.WorkflowSettings -DesiredSettings $WorkflowSettings - } - if ($testReturn -eq $false) { return $false } - - # Blocked file types - if ($PSBoundParameters.ContainsKey("BlockedFileTypes") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.BlockedFileTypes.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationBlockedFileTypes -CurrentSettings $CurrentValues.BlockedFileTypes -DesiredSettings $BlockedFileTypes - } - if ($testReturn -eq $false) { return $false } - - # General settings - if ($PSBoundParameters.ContainsKey("GeneralSettings") -eq $true) { - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.WebApplication\xSPWebApplication.GeneralSettings.psm1" -Resolve) - $testReturn = Test-xSPWebApplicationGeneralSettings -CurrentSettings $CurrentValues.GeneralSettings -DesiredSettings $GeneralSettings - } - if ($testReturn -eq $false) { return $false } - return $testReturn } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof index a407d5d93..fff10e1a3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplication/MSFT_xSPWebApplication.schema.mof @@ -1,65 +1,4 @@ -[ClassVersion("1.0.0")] -Class MSFT_xSPFilesTypes -{ - [write] string Blocked[]; - [write] string EnsureBlocked[]; - [write] string EnsureAllowed[]; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationHappyHour -{ - [write] uint32 Hour; - [write] uint32 Minute; - [write] uint32 Duration; - -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationThrottling -{ - [write] uint32 ListViewThreshold; - [write] boolean AllowObjectModelOverride; - [write] uint32 AdminThreshold; - [write] uint32 ListViewLookupThreshold; - [write] boolean HappyHourEnabled; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationHappyHour")] string HappyHour; - [write] uint32 UniquePermissionThreshold; - [write] boolean RequestThrottling; - [write] boolean ChangeLogEnabled; - [write] uint32 ChangeLogExpiryDays; - [write] boolean EventHandlersEnabled; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationWorkflowSettings -{ - [write] boolean ExternalWorkflowParticipantsEnabled; - [write] boolean UserDefinedWorkflowsEnabled; - [write] boolean EmailToNoPermissionWorkflowParticipantsEnable; -}; - -[ClassVersion("1.0.0")] -Class MSFT_xSPWebApplicationSettings -{ - [write] uint32 TimeZone; - [write] boolean Alerts; - [write] uint32 AlertsLimit; - [write] boolean RSS; - [write] boolean BlogAPI; - [write] boolean BlogAPIAuthenticated; - [write, ValueMap{"Strict","Permissive"}, Values{"Stric","Permissive"}] String BrowserFileHandling; - [write] boolean SecurityValidation; - [write] boolean RecycleBinEnabled; - [write] boolean RecycleBinCleanupEnabled; - [write] uint32 RecycleBinRetentionPeriod; - [write] uint32 SecondStageRecycleBinQuota; - [write] uint32 MaximumUploadSize; - [write] boolean CustomerExperienceProgram; - [write] boolean PresenceEnabled; -}; - -/* +/* **Description** This resource is responsible for creating a web application within the local SharePoint farm. @@ -96,9 +35,5 @@ class MSFT_xSPWebApplication : OMI_BaseResource [Write] string Path; [Write] string Port; [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationSettings")] string GeneralSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationWorkflowSettings")] string WorkflowSettings; - [Write, EmbeddedInstance("MSFT_xSPWebApplicationThrottling")] string ThrottlingSettings; - [Write, EmbeddedInstance("MSFT_xSPFilesTypes")] string BlockedFileTypes; }; diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 901d8cc51..c858f01d0 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -148,7 +148,12 @@ function Test-xSharePointObjectHasProperty() { [parameter(Mandatory = $true,Position=1)] [Object] $Object, [parameter(Mandatory = $true,Position=2)] [String] $PropertyName ) - return [bool]($Object.PSobject.Properties.name -contains $PropertyName) + if (([bool]($Object.PSobject.Properties.name -contains $PropertyName)) -eq $true) { + if ($Object.$PropertyName -ne $null) { + return $true + } + } + return $false } function Test-xSharePointSpecificParameters() { @@ -245,8 +250,7 @@ function Set-xSharePointObjectPropertyIfValueExists() { [parameter(Mandatory = $true,Position=1)] [object] $ParamsValue, [parameter(Mandatory = $true,Position=1)] [string] $ParamKey ) - - if ($ParamsValue.GetType().Name -eq "Hashtable") { + if ($ParamsValue.PSobject.Methods.name -contains "ContainsKey") { if ($ParamsValue.ContainsKey($ParamKey) -eq $true) { $ObjectToSet.$PropertyToSet = $ParamsValue.$ParamKey } diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 index 137401e5b..3adb153eb 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.BlockedFileTypes.psm1 @@ -15,25 +15,25 @@ function Set-xSPWebApplicationBlockedFileTypes { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) - if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true)) { + if (($Settings.ContainsKey("Blocked") -eq $true) -and (($Settings.ContainsKey("EnsureBlocked") -eq $true) -or ($Settings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $false) { + if (($Settings.ContainsKey("Blocked") -eq $false) -and ($Settings.ContainsKey("EnsureBlocked") -eq $false) -and ($Settings.ContainsKey("EnsureAllowed") -eq $false)) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if((Test-xSharePointObjectHasProperty $Settings "Blocked") -eq $true) { + if($Settings.ContainsKey("Blocked") -eq $true) { $WebApplication.BlockedFileExtensions.Clear(); $Settings.Blocked | ForEach-Object { $WebApplication.BlockedFileExtensions.Add($_.ToLower()); } } - if((Test-xSharePointObjectHasProperty $Settings "EnsureBlocked") -eq $true) { + if($Settings.ContainsKey("EnsureBlocked") -eq $true) { $Settings.EnsureBlocked | ForEach-Object { if(!$WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Add($_.ToLower()); @@ -41,7 +41,7 @@ function Set-xSPWebApplicationBlockedFileTypes { } } - if((Test-xSharePointObjectHasProperty $Settings "EnsureAllowed") -eq $true) { + if($Settings.ContainsKey("EnsureAllowed") -eq $true) { $Settings.EnsureAllowed | ForEach-Object { if($WebApplication.BlockedFileExtensions.Contains($_.ToLower())){ $WebApplication.BlockedFileExtensions.Remove($_.ToLower()); @@ -55,35 +55,29 @@ function Test-xSPWebApplicationBlockedFileTypes { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) - Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) - if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true -and ((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true -or (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true)) { + if (($DesiredSettings.ContainsKey("Blocked") -eq $true) -and (($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) -or ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true))) { throw "Blocked file types must use either the 'blocked' property or the 'EnsureBlocked' and/or 'EnsureAllowed' properties, but not both." } - if ((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $false -and (Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $false) { + if (($DesiredSettings.ContainsKey("Blocked") -eq $false) -and ($DesiredSettings.ContainsKey("EnsureBlocked") -eq $false) -and ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $false)) { throw "Blocked file types must specify at least one property (either 'Blocked, 'EnsureBlocked' or 'EnsureAllowed')" } - if((Test-xSharePointObjectHasProperty $DesiredSettings "Blocked") -eq $true) { + if($DesiredSettings.ContainsKey("Blocked") -eq $true) { $compareResult = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.Blocked if ($compareResult -eq $null) { return $true } else { return $false } } - if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureBlocked") -eq $true) { - $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked -ExcludeDifferent - if ($itemsToRemove -ne $null) { return $false } + if($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) { + $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureBlocked | Where-Object { $_.SideIndicator -eq "=>"} + if ($itemsToAdd -ne $null) { return $false } } - if((Test-xSharePointObjectHasProperty $DesiredSettings "EnsureAllowed") -eq $true) { - $itemsToAdd = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed | Where-Object { $_.SideIndicator -eq "=>"} - if ($itemsToAdd -ne $null) { - $compareResult = Compare-Object -ReferenceObject $DesiredSettings.EnsureAllowed -DifferenceObject $itemsToAdd.InputObject - if ($compareResult -ne $null) { return $false } - } else { - return $false - } + if($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true) { + $itemsToRemove = Compare-Object -ReferenceObject $CurrentSettings.Blocked -DifferenceObject $DesiredSettings.EnsureAllowed -ExcludeDifferent -IncludeEqual + if ($itemsToRemove -ne $null) { return $false } } return $true diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 index 81c37ac6e..feb2197c3 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.GeneralSettings.psm1 @@ -28,7 +28,7 @@ function Set-xSPWebApplicationGeneralSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) # Format here is SPWebApplication property = Custom settings property @@ -67,7 +67,7 @@ function Test-xSPWebApplicationGeneralSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 index d6149ddd8..cf6dff20f 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Throttling.psm1 @@ -27,7 +27,7 @@ function Set-xSPWebApplicationThrottlingSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) # Format here is SPWebApplication property = Custom settings property @@ -55,13 +55,9 @@ function Set-xSPWebApplicationThrottlingSettings { -ParamKey "RequestThrottling" # Create time span object separately - if (Test-xSharePointObjectHasProperty $Settings "ChangeLogExpiryDays") { + if ((Test-xSharePointObjectHasProperty $Settings "ChangeLogExpiryDays") -eq $true) { $WebApplication.ChangeLogRetentionPeriod = New-TimeSpan -Days $Settings.ChangeLogExpiryDays } - - - - } @@ -69,7 +65,7 @@ function Set-xSPWebApplicationHappyHourSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) if ((Test-xSharePointObjectHasProperty $Settings "Hour") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Minute") -eq $false -or (Test-xSharePointObjectHasProperty $Settings "Duration") -eq $false) { @@ -93,7 +89,7 @@ function Test-xSPWebApplicationThrottlingSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) diff --git a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 index aa3a80634..8a6485c3c 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.WebApplication/xSPWebApplication.Workflow.psm1 @@ -15,15 +15,15 @@ function Set-xSPWebApplicationWorkflowSettings { [CmdletBinding()] param( [parameter(Mandatory = $true)] $WebApplication, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $Settings + [parameter(Mandatory = $true)] $Settings ) - if((Test-xSharePointObjectHasProperty $Settings "UserDefinedWorkflowsEnabled") -eq $true) { + if($Settings.ContainsKey("UserDefinedWorkflowsEnabled") -eq $true) { $WebApplication.UserDefinedWorkflowsEnabled = $Settings.UserDefinedWorkflowsEnabled; } - if((Test-xSharePointObjectHasProperty $Settings "EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { + if($Settings.ContainsKey("EmailToNoPermissionWorkflowParticipantsEnable") -eq $true) { $WebApplication.EmailToNoPermissionWorkflowParticipantsEnabled = $Settings.EmailToNoPermissionWorkflowParticipantsEnable; } - if((Test-xSharePointObjectHasProperty $Settings "ExternalWorkflowParticipantsEnabled") -eq $true) { + if($Settings.ContainsKey("ExternalWorkflowParticipantsEnabled") -eq $true) { $WebApplication.ExternalWorkflowParticipantsEnabled = $Settings.ExternalWorkflowParticipantsEnabled; } $WebApplication.UpdateWorkflowConfigurationSettings(); @@ -34,7 +34,7 @@ function Test-xSPWebApplicationWorkflowSettings { [OutputType([System.Boolean])] param( [parameter(Mandatory = $true)] $CurrentSettings, - [parameter(Mandatory = $true)] [Microsoft.Management.Infrastructure.CimInstance] $DesiredSettings + [parameter(Mandatory = $true)] $DesiredSettings ) Import-Module (Join-Path $PSScriptRoot "..\..\Modules\xSharePoint.Util\xSharePoint.Util.psm1" -Resolve) diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index ad0476b0d..ed8503211 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -12,7 +12,7 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '0.7.0.0' +ModuleVersion = '0.8.0.0' # ID used to uniquely identify this module GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index d0d73181d..340a110cd 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -76,6 +76,10 @@ + + + + @@ -133,8 +137,12 @@ + + + + @@ -147,6 +155,10 @@ + + + + diff --git a/README.md b/README.md index 7c6199a20..2b80689fc 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,13 @@ Please read the installation instructions that are present on both the download Below is a list of DSC resource types that are currently provided by xSharePoint: + - xSPAntivirusSettings - xBCSServiceApp - xSPCacheAccounts - - xSPClearRemoteSessions - xSPCreateFarm - xSPDiagnosticLoggingSettings - xSPDistributedCacheService + - xSPFarmAdministrators - xSPFeature - xSPInstall - xSPInstallPreReqs @@ -45,6 +46,8 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPManagedAccount - xSPManagedMetadataServiceApp - xSPManagedPath + - xSPOutgoingEmailSettings + - xSPPasswordChangeSettings - xSPSearchServiceApp - xSPSecureStoreServiceApp - xSPServiceAppPool @@ -54,7 +57,11 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPUsageApplication - xSPUserProfileServiceApp - xSPUserProfileSyncService + - xSPWebAppBlockedFileTypes + - xSPWebAppGeneralSettings - xSPWebApplication + - xSPWebAppThrottlingSettings + - xSPWebAppWorkflowSettings ## Preview status @@ -68,6 +75,13 @@ Additional detailed documentation is included on the wiki on GitHub. ## Version History +### 0.8.0.0 + * Added xSPAntivirusSettings, xSPFarmAdministrators, xSPOutgoingEmailSettings, xSPPasswordChangeSettings, xSPWebAppBlockedFileTypes, xSPWebAppGeneralSettings, xSPWebAppThrottlingSettings and xSPWebAppWorkflowSettings + * Fixed issue with xSPInstallPrereqs using wrong parameters in offline install mode + * Fixed issue with xSPInstallPrereqs where it would not validate that installer paths exist + * Fixed xSPSecureStoreServiceApp and xSPUsageApplication to use PSCredentials instead of plain text username/password for database credentials + * Added built in PowerShell help (for calling "Get-Help about_[resource]", such as "Get-Help about_xSPCreateFarm") + ### 0.7.0.0 * Support for MinRole options in SharePoint 2016 diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 7d475469d..1ab144884 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -72,10 +72,10 @@ - - - - + + + + diff --git a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 index 2a63a77fc..4c1aeb030 100644 --- a/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPInstallPrereqs.Tests.ps1 @@ -117,8 +117,10 @@ Describe "xSPInstallPrereqs" { @{ Name = "AppFabric 1.1 for Windows Server"} @{ Name = "WCF Data Services 5.6.0 Runtime"} @{ Name = "Microsoft ODBC Driver 11 for SQL Server"} - @{ Name = "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005"} - @{ Name = "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005"} + @{ Name = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030"} + @{ Name = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030"} + @{ Name = "Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026"} + @{ Name = "Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23026"} @{ Name = "Microsoft SQL Server 2012 Native Client"} @{ Name = "Active Directory Rights Management Services Client 2.1"} )} diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 similarity index 87% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 index ebe4eecb5..81d906782 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.BlockedFileTypes.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppBlockedFileTypes.Tests.ps1 @@ -9,20 +9,14 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppBlockedFileTypes" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Blocked file types)" { +Describe "xSPWebAppBlockedFileTypes" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ - Blocked = @("exe", "dll", "ps1") - } -ClientOnly) + Blocked = @("exe", "dll", "ps1") } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -116,15 +110,9 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ - EnsureBlocked = @("exe") - EnsureAllowed = @("pdf") - } -ClientOnly) + EnsureBlocked = @("exe") + EnsureAllowed = @("pdf") } Context "The web appliation exists and a list of types to include and exclude both match" { @@ -233,16 +221,10 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ - Blocked = @("exe", "dll", "ps1") - EnsureBlocked = @("exe", "dll") - EnsureAllowed = @("ps1") - } -ClientOnly) + Blocked = @("exe", "dll", "ps1") + EnsureBlocked = @("exe", "dll") + EnsureAllowed = @("ps1") } It "throws an exception on the test method" { @@ -282,13 +264,7 @@ Describe "xSPWebApplication (Blocked file types)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - BlockedFileTypes = (New-CimInstance -ClassName MSFT_xSPFilesTypes -Property @{ - } -ClientOnly) } It "throws an exception on the test method" { diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 similarity index 67% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 index 48063a362..154fc4bc2 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.GeneralSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppGeneralSettings.Tests.ps1 @@ -9,35 +9,29 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppGeneralSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (General Settings)" { +Describe "xSPWebAppGeneralSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - GeneralSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationSettings -Property @{ - TimeZone = 3081 - Alerts = $true - AlertsLimit = 10 - RSS = $true - BlogAPI = $true - BlogAPIAuthenticated = $true - BrowserFileHandling = "Permissive" - SecurityValidation = $true - RecycleBinEnabled = $true - RecycleBinCleanupEnabled = $true - RecycleBinRetentionPeriod = 30 - SecondStageRecycleBinQuota = 30 - MaximumUploadSize = 100 - CustomerExperienceProgram = $true - PresenceEnabled = $true - } -ClientOnly) + TimeZone = 3081 + Alerts = $true + AlertsLimit = 10 + RSS = $true + BlogAPI = $true + BlogAPIAuthenticated = $true + BrowserFileHandling = "Permissive" + SecurityValidation = $true + RecycleBinEnabled = $true + RecycleBinCleanupEnabled = $true + RecycleBinRetentionPeriod = 30 + SecondStageRecycleBinQuota = 30 + MaximumUploadSize = 100 + CustomerExperienceProgram = $true + PresenceEnabled = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -70,23 +64,23 @@ Describe "xSPWebApplication (General Settings)" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url - DefaultTimeZone = $testParams.GeneralSettings.TimeZone - AlertsEnabled = $testParams.GeneralSettings.Alerts - AlertsMaximum = $testParams.GeneralSettings.AlertsLimit - SyndicationEnabled = $testParams.GeneralSettings.RSS - MetaWeblogEnabled = $testParams.GeneralSettings.BlogAPI - MetaWeblogAuthenticationEnabled = $testParams.GeneralSettings.BlogAPIAuthenticated - BrowserFileHandling = $testParams.GeneralSettings.BrowserFileHandling + DefaultTimeZone = $testParams.TimeZone + AlertsEnabled = $testParams.Alerts + AlertsMaximum = $testParams.AlertsLimit + SyndicationEnabled = $testParams.RSS + MetaWeblogEnabled = $testParams.BlogAPI + MetaWeblogAuthenticationEnabled = $testParams.BlogAPIAuthenticated + BrowserFileHandling = $testParams.BrowserFileHandling FormDigestSettings = @{ - Enabled = $testParams.GeneralSettings.SecurityValidation + Enabled = $testParams.SecurityValidation } - RecycleBinEnabled = $testParams.GeneralSettings.RecycleBinEnabled - RecycleBinCleanupEnabled = $testParams.GeneralSettings.RecycleBinCleanupEnabled - RecycleBinRetentionPeriod = $testParams.GeneralSettings.RecycleBinRetentionPeriod - SecondStageRecycleBinQuota = $testParams.GeneralSettings.SecondStageRecycleBinQuota - MaximumFileSize = $testParams.GeneralSettings.MaximumUploadSize - BrowserCEIPEnabled = $testParams.GeneralSettings.CustomerExperienceProgram - PresenceEnabled = $testParams.GeneralSettings.PresenceEnabled + RecycleBinEnabled = $testParams.RecycleBinEnabled + RecycleBinCleanupEnabled = $testParams.RecycleBinCleanupEnabled + RecycleBinRetentionPeriod = $testParams.RecycleBinRetentionPeriod + SecondStageRecycleBinQuota = $testParams.SecondStageRecycleBinQuota + MaximumFileSize = $testParams.MaximumUploadSize + BrowserCEIPEnabled = $testParams.CustomerExperienceProgram + PresenceEnabled = $testParams.PresenceEnabled } $webApp = $webApp | Add-Member ScriptMethod Update { $Global:xSPWebApplicationUpdateCalled = $true @@ -154,7 +148,7 @@ Describe "xSPWebApplication (General Settings)" { } $Global:xSPWebApplicationUpdateCalled = $false - It "updates the workflow settings" { + It "updates the general settings" { Set-TargetResource @testParams $Global:xSPWebApplicationUpdateCalled | Should Be $true } diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 similarity index 73% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 index d11984155..22dff8dfd 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Throttling.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppThrottlingSettings.Tests.ps1 @@ -9,34 +9,28 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppThrottlingSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Throttling)" { +Describe "xSPWebAppThrottlingSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ - ListViewThreshold = 1000 - AllowObjectModelOverride = $true - AdminThreshold = 2000 - ListViewLookupThreshold = 12 - HappyHourEnabled = $true - HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ - Hour = 2 - Minute = 0 - Duration = 1 - } -ClientOnly) - UniquePermissionThreshold = 100 - RequestThrottling = $true - ChangeLogEnabled = $true - ChangeLogExpiryDays = 30 - EventHandlersEnabled = $true + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ + Hour = 2 + Minute = 0 + Duration = 1 } -ClientOnly) + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -68,23 +62,23 @@ Describe "xSPWebApplication (Throttling)" { @{ Path = "C:\inetpub\wwwroot\something" } ) Url = $testParams.Url - MaxItemsPerThrottledOperation = $testParams.ThrottlingSettings.ListViewThreshold - AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride - MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold - MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold - UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled - DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour - DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute - DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration - MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + MaxItemsPerThrottledOperation = $testParams.ListViewThreshold + AllowOMCodeOverrideThrottleSettings = $testParams.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.AdminThreshold + MaxQueryLookupFields = $testParams.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.UniquePermissionThreshold HttpThrottleSettings = @{ - PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + PerformThrottle = $testParams.RequestThrottling } - ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogExpirationEnabled = $testParams.ChangeLogEnabled ChangeLogRetentionPeriod = @{ - Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + Days = $testParams.ChangeLogExpiryDays } - EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + EventHandlersEnabled = $testParams.EventHandlersEnabled })} It "returns the current data from the get method" { @@ -115,22 +109,22 @@ Describe "xSPWebApplication (Throttling)" { ) Url = $testParams.Url MaxItemsPerThrottledOperation = 1 - AllowOMCodeOverrideThrottleSettings = $testParams.ThrottlingSettings.AllowObjectModelOverride - MaxItemsPerThrottledOperationOverride = $testParams.ThrottlingSettings.AdminThreshold - MaxQueryLookupFields = $testParams.ThrottlingSettings.ListViewLookupThreshold - UnthrottledPrivilegedOperationWindowEnabled = $testParams.ThrottlingSettings.HappyHourEnabled - DailyStartUnthrottledPrivilegedOperationsHour = $testParams.ThrottlingSettings.HappyHour.Hour - DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.ThrottlingSettings.HappyHour.Minute - DailyUnthrottledPrivilegedOperationsDuration = $testParams.ThrottlingSettings.HappyHour.Duration - MaxUniquePermScopesPerList = $testParams.ThrottlingSettings.UniquePermissionThreshold + AllowOMCodeOverrideThrottleSettings = $testParams.AllowObjectModelOverride + MaxItemsPerThrottledOperationOverride = $testParams.AdminThreshold + MaxQueryLookupFields = $testParams.ListViewLookupThreshold + UnthrottledPrivilegedOperationWindowEnabled = $testParams.HappyHourEnabled + DailyStartUnthrottledPrivilegedOperationsHour = $testParams.HappyHour.Hour + DailyStartUnthrottledPrivilegedOperationsMinute = $testParams.HappyHour.Minute + DailyUnthrottledPrivilegedOperationsDuration = $testParams.HappyHour.Duration + MaxUniquePermScopesPerList = $testParams.UniquePermissionThreshold HttpThrottleSettings = @{ - PerformThrottle = $testParams.ThrottlingSettings.RequestThrottling + PerformThrottle = $testParams.RequestThrottling } - ChangeLogExpirationEnabled = $testParams.ThrottlingSettings.ChangeLogEnabled + ChangeLogExpirationEnabled = $testParams.ChangeLogEnabled ChangeLogRetentionPeriod = @{ - Days = $testParams.ThrottlingSettings.ChangeLogExpiryDays + Days = $testParams.ChangeLogExpiryDays } - EventHandlersEnabled = $testParams.ThrottlingSettings.EventHandlersEnabled + EventHandlersEnabled = $testParams.EventHandlersEnabled } $webApp = $webApp | Add-Member ScriptMethod Update { $Global:xSPWebApplicationUpdateCalled = $true @@ -156,28 +150,22 @@ Describe "xSPWebApplication (Throttling)" { } $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - ThrottlingSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationThrottling -Property @{ - ListViewThreshold = 1000 - AllowObjectModelOverride = $true - AdminThreshold = 2000 - ListViewLookupThreshold = 12 - HappyHourEnabled = $true - HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ - Hour = 5 - Minute = 0 - Duration = 1 - } -ClientOnly) - UniquePermissionThreshold = 100 - RequestThrottling = $true - ChangeLogEnabled = $true - ChangeLogExpiryDays = 30 - EventHandlersEnabled = $true + ListViewThreshold = 1000 + AllowObjectModelOverride = $true + AdminThreshold = 2000 + ListViewLookupThreshold = 12 + HappyHourEnabled = $true + HappyHour = (New-CimInstance -ClassName MSFT_xSPWebApplicationHappyHour -Property @{ + Hour = 5 + Minute = 0 + Duration = 1 } -ClientOnly) + UniquePermissionThreshold = 100 + RequestThrottling = $true + ChangeLogEnabled = $true + ChangeLogExpiryDays = 30 + EventHandlersEnabled = $true } $Global:xSPWebApplicationUpdateCalled = $false $Global:xSPWebApplicationUpdateHappyHourCalled = $false diff --git a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 similarity index 88% rename from Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 rename to Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 index 9f346519d..78695e312 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWebApplication.Workflow.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWebAppWorkflowSettings.Tests.ps1 @@ -9,22 +9,16 @@ Set-StrictMode -Version latest $RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path $Global:CurrentSharePointStubModule = $SharePointCmdletModule -$ModuleName = "MSFT_xSPWebApplication" +$ModuleName = "MSFT_xSPWebAppWorkflowSettings" Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") -Describe "xSPWebApplication (Workflow)" { +Describe "xSPWebAppWorkflowSettings" { InModuleScope $ModuleName { $testParams = @{ - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Web Apps" - ApplicationPoolAccount = "DEMO\ServiceAccount" Url = "http://sites.sharepoint.com" - AuthenticationMethod = "NTLM" - WorkflowSettings = (New-CimInstance -ClassName MSFT_xSPWebApplicationWorkflowSettings -Property @{ - ExternalWorkflowParticipantsEnabled = $true - UserDefinedWorkflowsEnabled = $true - EmailToNoPermissionWorkflowParticipantsEnable = $true - } -ClientOnly) + ExternalWorkflowParticipantsEnabled = $true + UserDefinedWorkflowsEnabled = $true + EmailToNoPermissionWorkflowParticipantsEnable = $true } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") diff --git a/appveyor.yml b/appveyor.yml index 689433c22..d8879089c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.7.{build}.0 +version: 0.8.{build}.0 install: - cinst -y pester @@ -27,7 +27,7 @@ after_test: Remove-Item (Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.pssproj") $manifest = Join-Path "$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint" "xSharePoint.psd1" - (Get-Content $manifest -Raw).Replace("0.7.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest + (Get-Content $manifest -Raw).Replace("0.8.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest Add-Type -assemblyname System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::CreateFromDirectory("$env:APPVEYOR_BUILD_FOLDER\modules\xSharePoint", "$env:APPVEYOR_BUILD_FOLDER\xSharePoint.zip") Get-ChildItem "$env:APPVEYOR_BUILD_FOLDER\xSharePoint.zip" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }