From 0ec9c8cf0f46a7538e965cc2de1dd00514dea78b Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 17 Dec 2015 21:28:48 +0100 Subject: [PATCH 01/91] Initial version xSPHealthAnalyzerRuleState resource --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 118 ++++++++++++++++++ ...MSFT_xSPHealthAnalyzerRuleState.schema.mof | 31 +++++ Modules/xSharePoint/xSharePoint.pssproj | 3 + README.md | 2 +- 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 new file mode 100644 index 000000000..2c9944e80 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -0,0 +1,118 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting antivirus configuration settings" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + try { + $spFarm = Get-SPFarm + } catch { + Write-Verbose -Verbose "No local SharePoint farm was detected. Antivirus settings will not be applied" + return $null + } + + # Get a reference to the Administration WebService + $admService = Get-xSharePointContentService + + return @{ + # Set the antivirus settings + AllowDownloadInfected = $admService.AntivirusSettings.AllowDownload + ScanOnDownload = $admService.AntivirusSettings.DownloadScanEnabled + ScanOnUpload = $admService.AntivirusSettings.UploadScanEnabled + AttemptToClean = $admService.AntivirusSettings.CleaningEnabled + NumberOfThreads = $admService.AntivirusSettings.NumberOfThreads + TimeoutDuration = $admService.AntivirusSettings.Timeout.TotalSeconds + InstallAccount = $params.InstallAccount + } + } + + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting antivirus configuration settings" + + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + try { + $spFarm = Get-SPFarm + } catch { + throw "No local SharePoint farm was detected. Antivirus settings will not be applied" + return + } + + Write-Verbose -Message "Start update" + $admService = Get-xSharePointContentService + + # Set the antivirus settings + if ($params.ContainsKey("AllowDownloadInfected")) { + Write-Verbose -Message "Setting Allow Download" + $admService.AntivirusSettings.AllowDownload = $params.AllowDownloadInfected + } + if ($params.ContainsKey("ScanOnDownload")) { $admService.AntivirusSettings.DownloadScanEnabled = $params.ScanOnDownload } + if ($params.ContainsKey("ScanOnUpload")) { $admService.AntivirusSettings.UploadScanEnabled = $params.ScanOnUpload } + if ($params.ContainsKey("AttemptToClean")) { $admService.AntivirusSettings.CleaningEnabled = $params.AttemptToClean } + if ($params.ContainsKey("NumberOfThreads")) { $admService.AntivirusSettings.NumberOfThreads = $params.NumberOfThreads } + if ($params.ContainsKey("TimeoutDuration")) { + $timespan = New-TimeSpan -Seconds $params.TimeoutDuration + $admService.AntivirusSettings.Timeout = $timespan + } + + $admService.Update() + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, + [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, + [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, + [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, + [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, + [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing antivirus configuration settings" + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters +} + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof new file mode 100644 index 000000000..8135dcf13 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof @@ -0,0 +1,31 @@ +/* +**Description** + +This resource is used to set the global antivirus settings for the local farm. +These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. +Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. + +**Example** + + xSPHealthAnalyzerRuleState DisableDiskSpaceRule + { + Name = "Drives are at risk of running out of free space." + Enabled = $true + Scope = "All Servers" + Schedule = "Daily" + FixAutomatically = $false + InstallAcount = $InstallAccount + } +*/ + +[ClassVersion("1.0.0.0"), FriendlyName("xSPHealthAnalyzerRuleState")] +class MSFT_xSPHealthAnalyzerRuleState : OMI_BaseResource +{ + [Key] String eName; + [Required] Boolean Enabled; + [Write, ValueMap{"Any Server","All Servers"}, Values{"Any Server","All Servers"}] String Scope; + [Write, ValueMap{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}, Values{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}] String Schedule; + [Write] Boolean FixAutomatically; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index d568b209e..1d5bd3b00 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -83,6 +83,7 @@ + @@ -108,6 +109,7 @@ + @@ -163,6 +165,7 @@ + diff --git a/README.md b/README.md index 5dcca6a3c..8c23e44c1 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Additional detailed documentation is included on the wiki on GitHub. ### Unreleased - * Added xSPStateServiceApp, xSPDesignerSettings and xSPQuotaTemplate resources + * Added xSPStateServiceApp, xSPDesignerSettings, xSPQuotaTemplate and xSPHealthAnalyzerRuleState resources ### 0.8.0.0 * Added xSPAntivirusSettings, xSPFarmAdministrators, xSPOutgoingEmailSettings, xSPPasswordChangeSettings, xSPWebAppBlockedFileTypes, xSPWebAppGeneralSettings, xSPWebAppThrottlingSettings and xSPWebAppWorkflowSettings From 87d06c1301947eb8e8263a186a183bbd2b8fd86f Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sat, 19 Dec 2015 14:15:47 +0100 Subject: [PATCH 02/91] Created tests and fixed some bugs --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 133 ++++++++----- ...MSFT_xSPHealthAnalyzerRuleState.schema.mof | 4 +- Tests/Tests.pssproj | 1 + ...Point.xSPHealthAnalyzerRuleState.Tests.ps1 | 185 ++++++++++++++++++ 4 files changed, 271 insertions(+), 52 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 index 2c9944e80..3b4382eca 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -4,16 +4,15 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, - [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, - [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, - [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, - [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, - [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.Boolean] $Enabled, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, + [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - Write-Verbose -Message "Getting antivirus configuration settings" + Write-Verbose -Message "Getting Health Rule configuration settings" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] @@ -21,23 +20,45 @@ function Get-TargetResource try { $spFarm = Get-SPFarm } catch { - Write-Verbose -Verbose "No local SharePoint farm was detected. Antivirus settings will not be applied" + Write-Verbose -Verbose "No local SharePoint farm was detected. Health Analyzer Rule settings will not be applied" return $null } - # Get a reference to the Administration WebService - $admService = Get-xSharePointContentService - - return @{ - # Set the antivirus settings - AllowDownloadInfected = $admService.AntivirusSettings.AllowDownload - ScanOnDownload = $admService.AntivirusSettings.DownloadScanEnabled - ScanOnUpload = $admService.AntivirusSettings.UploadScanEnabled - AttemptToClean = $admService.AntivirusSettings.CleaningEnabled - NumberOfThreads = $admService.AntivirusSettings.NumberOfThreads - TimeoutDuration = $admService.AntivirusSettings.Timeout.TotalSeconds - InstallAccount = $params.InstallAccount + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + if ($null -eq $caWebapp) { + Write-Verbose -Verbose "Unable to locate central administration website" + return $null } + + # Get CA SPWeb + $caWeb = Get-SPWeb($caWebapp.Url) + $healthRulesList = $caWeb.Lists | ? { $_.BaseTemplate -eq "HealthRules"} + + if ($healthRulesList -ne $null) { + $spQuery = New-Object Microsoft.SharePoint.SPQuery + $querytext = "$($params.Name)" + $spQuery.Query = $querytext + $results = $healthRulesList.GetItems($spQuery) + if ($results.Count -eq 1) { + $item = $results[0] + + return @{ + # Set the Health Analyzer Rule settings + Name = $params.Name + Enabled = $item["HealthRuleCheckEnabled"] + Scope = $item["HealthRuleScope"] + Schedule = $item["HealthRuleSchedule"] + FixAutomatically = $item["HealthRuleAutoRepairEnabled"] + InstallAccount = $params.InstallAccount + } + } else { + Write-Verbose -Verbose "Unable to find specified Health Analyzer Rule" + return $null + } + } else { + Write-Verbose -Verbose "Unable to locate Health Analyzer Rules list" + return $null + } } return $result @@ -49,12 +70,11 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, - [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, - [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, - [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, - [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, - [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.Boolean] $Enabled, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, + [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -66,28 +86,42 @@ function Set-TargetResource try { $spFarm = Get-SPFarm } catch { - throw "No local SharePoint farm was detected. Antivirus settings will not be applied" + throw "No local SharePoint farm was detected. Health Analyzer Rule settings will not be applied" return } - - Write-Verbose -Message "Start update" - $admService = Get-xSharePointContentService - # Set the antivirus settings - if ($params.ContainsKey("AllowDownloadInfected")) { - Write-Verbose -Message "Setting Allow Download" - $admService.AntivirusSettings.AllowDownload = $params.AllowDownloadInfected + $caWebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication} + if ($null -eq $caWebapp) { + throw "No Central Admin web application was found. Health Analyzer Rule settings will not be applied" + return } - if ($params.ContainsKey("ScanOnDownload")) { $admService.AntivirusSettings.DownloadScanEnabled = $params.ScanOnDownload } - if ($params.ContainsKey("ScanOnUpload")) { $admService.AntivirusSettings.UploadScanEnabled = $params.ScanOnUpload } - if ($params.ContainsKey("AttemptToClean")) { $admService.AntivirusSettings.CleaningEnabled = $params.AttemptToClean } - if ($params.ContainsKey("NumberOfThreads")) { $admService.AntivirusSettings.NumberOfThreads = $params.NumberOfThreads } - if ($params.ContainsKey("TimeoutDuration")) { - $timespan = New-TimeSpan -Seconds $params.TimeoutDuration - $admService.AntivirusSettings.Timeout = $timespan + + # Get Central Admin SPWeb + $caWeb = Get-SPWeb($caWebapp.Url) + $healthRulesList = $caWeb.Lists | ? { $_.BaseTemplate -eq "HealthRules"} + + if ($healthRulesList -ne $null) { + $spQuery = New-Object Microsoft.SharePoint.SPQuery + $querytext = "$($params.Name)" + $spQuery.Query = $querytext + $results = $healthRulesList.GetItems($spQuery) + if ($results.Count -eq 1) { + $item = $results[0] + + $item["HealthRuleCheckEnabled"] = $params.Enabled + if ($params.ContainsKey("Scope")) { $item["HealthRuleScope"] = $params.Scope } + if ($params.ContainsKey("Schedule")) { $item["HealthRuleSchedule"] = $params.Schedule } + if ($params.ContainsKey("FixAutomatically")) { $item["HealthRuleAutoRepairEnabled"] = $params.FixAutomatically } + + $item.Update() + } else { + throw "Could not find specified Health Analyzer Rule. Health Analyzer Rule settings will not be applied" + return + } + } else { + throw "Could not find Health Analyzer Rules list. Health Analyzer Rule settings will not be applied" + return } - - $admService.Update() } } @@ -98,16 +132,15 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, - [parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, - [parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, - [parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, - [parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, - [parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.Boolean] $Enabled, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, + [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - Write-Verbose -Message "Testing antivirus configuration settings" + Write-Verbose -Message "Testing Health Analyzer rule configuration settings" $CurrentValues = Get-TargetResource @PSBoundParameters if ($null -eq $CurrentValues) { return $false } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof index 8135dcf13..a77fef135 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof @@ -21,9 +21,9 @@ Note that this will not scan documents for viruses on it's own, an external tool [ClassVersion("1.0.0.0"), FriendlyName("xSPHealthAnalyzerRuleState")] class MSFT_xSPHealthAnalyzerRuleState : OMI_BaseResource { - [Key] String eName; + [Key] String Name; [Required] Boolean Enabled; - [Write, ValueMap{"Any Server","All Servers"}, Values{"Any Server","All Servers"}] String Scope; + [Write, ValueMap{"All Servers", "Any Server"}, Values{"All Servers", "Any Server"}] String Scope; [Write, ValueMap{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}, Values{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}] String Schedule; [Write] Boolean FixAutomatically; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index aa7d5ffc0..fcbf5565d 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -67,6 +67,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 new file mode 100644 index 000000000..741ccfc14 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 @@ -0,0 +1,185 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPHealthAnalyzerRuleState" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPHealthAnalyzerRuleState" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "Drives are at risk of running out of free space." + Enabled = $true + Scope = "All Servers" + Schedule = "Daily" + FixAutomatically = $false + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Add-Type -TypeDefinition "namespace Microsoft.SharePoint { public class SPQuery { public string Query { get; set; } } }" + + Context "The server is not part of SharePoint farm" { + Mock Get-SPFarm { throw "Unable to detect local farm" } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "throws an exception in the set method to say there is no local farm" { + { Set-TargetResource @testParams } | Should throw "No local SharePoint farm was detected" + } + } + + Context "The server is in a farm, but no central admin site is found" { + Mock Get-SPwebapplication { return $null } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "No Central Admin web application was found. Health Analyzer Rule settings will not be applied" + } + } + + Context "The server is in a farm, CA found, but no health analyzer rules list is found" { + Mock Get-SPwebapplication { return @{ Url = "";IsAdministrationWebApplication=$true } } + Mock Get-SPWeb { return @{ Lists = $null } } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "Could not find Health Analyzer Rules list. Health Analyzer Rule settings will not be applied" + } + } + + + Context "The server is in a farm, CA found, Health Rules list found, but no rules match the specified rule name" { + Mock Get-SPwebapplication { return @{ Url = "";IsAdministrationWebApplication=$true } } + Mock Get-SPWeb { + $web = @{ + Lists = @{ + BaseTemplate = "HealthRules" + } | Add-Member ScriptMethod GetItems { + return ,@() + } -PassThru + } + return $web + } + + Mock Get-SPFarm { return @{} } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "Could not find specified Health Analyzer Rule. Health Analyzer Rule settings will not be applied" + } + } + + Context "The server is in a farm, CA/Health Rules list/Health Rule found, but the incorrect settings have been applied" { + Mock Get-SPwebapplication { return @{ Url = "";IsAdministrationWebApplication=$true } } + Mock Get-SPWeb { + $web = @{ + Lists = @{ + BaseTemplate = "HealthRules" + } | Add-Member ScriptMethod GetItems { + $itemcol = @(@{ + HealthRuleCheckEnabled = $false; + HealthRuleScope = "Any Server"; + HealthRuleSchedule = "Weekly"; + HealthRuleAutoRepairEnabled = $true + } | Add-Member ScriptMethod Update { $Global:xSharePointHealthRulesUpdated = $true } -PassThru ) + return ,$itemcol + } -PassThru + } + return $web + } + Mock Get-SPFarm { return @{} } + + It "return values from the get method" { + $result = Get-TargetResource @testParams + $result.Enabled | Should Be $false + $result.Scope | Should Be 'Any Server' + $result.Schedule| Should Be 'Weekly' + $result.FixAutomatically | Should Be $true + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSharePointHealthRulesUpdated = $false + It "set the configured values for the specific Health Analyzer Rule" { + Set-TargetResource @testParams + $Global:xSharePointHealthRulesUpdated | Should Be $true + } + } + + Context "The server is in a farm and the correct settings have been applied" { + Mock Get-SPwebapplication { return @{ Url = "";IsAdministrationWebApplication=$true } } + Mock Get-SPWeb { + $web = @{ + Lists = @{ + BaseTemplate = "HealthRules" + } | Add-Member ScriptMethod GetItems { + $itemcol = @(@{ + HealthRuleCheckEnabled = $true; + HealthRuleScope = "All Servers"; + HealthRuleSchedule = "Daily"; + HealthRuleAutoRepairEnabled = $false + } | Add-Member ScriptMethod Update { $Global:xSharePointHealthRulesUpdated = $true } -PassThru ) + return ,$itemcol + } -PassThru + } + return $web + } + Mock Get-SPFarm { return @{} } + + It "return values from the get method" { + $result = Get-TargetResource @testParams + $result.Enabled | Should Be $true + $result.Scope | Should Be 'All Servers' + $result.Schedule| Should Be 'Daily' + $result.FixAutomatically | Should Be $false + } + + It "returns true from the test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + } +} From 73e173fa46ab9efd50a09fdb74a2b894b9eef755 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Tue, 22 Dec 2015 16:29:54 +0100 Subject: [PATCH 03/91] Changed scope parameter --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 12 ++++++------ .../MSFT_xSPHealthAnalyzerRuleState.schema.mof | 6 +++--- .../xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 index 3b4382eca..6249d3cfe 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -46,7 +46,7 @@ function Get-TargetResource # Set the Health Analyzer Rule settings Name = $params.Name Enabled = $item["HealthRuleCheckEnabled"] - Scope = $item["HealthRuleScope"] + RuleScope = $item["HealthRuleScope"] Schedule = $item["HealthRuleSchedule"] FixAutomatically = $item["HealthRuleAutoRepairEnabled"] InstallAccount = $params.InstallAccount @@ -72,13 +72,13 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - Write-Verbose -Message "Setting antivirus configuration settings" + Write-Verbose -Message "Setting Health Analyzer Rule configuration settings" Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] @@ -109,7 +109,7 @@ function Set-TargetResource $item = $results[0] $item["HealthRuleCheckEnabled"] = $params.Enabled - if ($params.ContainsKey("Scope")) { $item["HealthRuleScope"] = $params.Scope } + if ($params.ContainsKey("RuleScope")) { $item["HealthRuleScope"] = $params.RuleScope } if ($params.ContainsKey("Schedule")) { $item["HealthRuleSchedule"] = $params.Schedule } if ($params.ContainsKey("FixAutomatically")) { $item["HealthRuleAutoRepairEnabled"] = $params.FixAutomatically } @@ -134,7 +134,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $Scope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof index a77fef135..8cb7c5a7f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof @@ -11,10 +11,10 @@ Note that this will not scan documents for viruses on it's own, an external tool { Name = "Drives are at risk of running out of free space." Enabled = $true - Scope = "All Servers" + RuleScope = "All Servers" Schedule = "Daily" FixAutomatically = $false - InstallAcount = $InstallAccount + InstallAccount = $InstallAccount } */ @@ -23,7 +23,7 @@ class MSFT_xSPHealthAnalyzerRuleState : OMI_BaseResource { [Key] String Name; [Required] Boolean Enabled; - [Write, ValueMap{"All Servers", "Any Server"}, Values{"All Servers", "Any Server"}] String Scope; + [Write, ValueMap{"All Servers", "Any Server"}, Values{"All Servers", "Any Server"}] String RuleScope; [Write, ValueMap{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}, Values{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}] String Schedule; [Write] Boolean FixAutomatically; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; diff --git a/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 index 741ccfc14..e80069f42 100644 --- a/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 @@ -17,7 +17,7 @@ Describe "xSPHealthAnalyzerRuleState" { $testParams = @{ Name = "Drives are at risk of running out of free space." Enabled = $true - Scope = "All Servers" + RuleScope = "All Servers" Schedule = "Daily" FixAutomatically = $false } @@ -132,7 +132,7 @@ Describe "xSPHealthAnalyzerRuleState" { It "return values from the get method" { $result = Get-TargetResource @testParams $result.Enabled | Should Be $false - $result.Scope | Should Be 'Any Server' + $result.RuleScope | Should Be 'Any Server' $result.Schedule| Should Be 'Weekly' $result.FixAutomatically | Should Be $true } @@ -171,7 +171,7 @@ Describe "xSPHealthAnalyzerRuleState" { It "return values from the get method" { $result = Get-TargetResource @testParams $result.Enabled | Should Be $true - $result.Scope | Should Be 'All Servers' + $result.RuleScope | Should Be 'All Servers' $result.Schedule| Should Be 'Daily' $result.FixAutomatically | Should Be $false } From 837018743871af6ba8f7566a80f046cd422005fd Mon Sep 17 00:00:00 2001 From: Camilo Date: Wed, 23 Dec 2015 16:52:40 +0000 Subject: [PATCH 04/91] work management --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 93 +++++++++++++++ ...SFT_xSPWorkManagementServiceApp.schema.mof | 24 ++++ Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...oint.xSPWorkManagementServiceApp.Tests.ps1 | 107 ++++++++++++++++++ 5 files changed, 228 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 new file mode 100644 index 000000000..a7b441f40 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -0,0 +1,93 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + Write-Verbose -Message "Getting Work management service app '$Name'" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + if ($null -eq $serviceApps) { + return $null + } + $serviceApp = $serviceApps | Where-Object { $_.TypeName -eq "Work Management Service Application" } + + If ($null -eq $serviceApp) { + return $null + } else { + $returnVal = @{ + Name = $serviceApp.DisplayName + ApplicationPool = $serviceApp.ApplicationPool.Name + } + return $returnVal + } + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $result = Get-TargetResource @PSBoundParameters + + if ($result -eq $null) { + Write-Verbose -Message "Creating work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + + $appService = New-SPWorkManagementServiceApplication @params + New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null + } + } + else { + if ($ApplicationPool -ne $result.ApplicationPool) { + Write-Verbose -Message "Updating Work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + + $AppService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + $AppService.ApplicationPool = $appPool + $AppService.Update() + } + } + } +} + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing for App management Service Application '$Name'" + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") +} + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof new file mode 100644 index 000000000..1c086a6c0 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof @@ -0,0 +1,24 @@ +/* +**Description** + +This resource is used to provision and manage an instance of the Work Management Services Service Application. +It will identify an instance of the work management service application through the application display name. +Currently the resource will provision the app if it does not yet exist, and will change the application pool associated to the app if it does not match the configuration. + + +**Example** + + xSPWorkManagementServiceApp WorkManagementServiceApp + { + Name = "App Management Service Application" + AppPool = "SharePoint web services" +} +*/ +[ClassVersion("1.0.0.0"), FriendlyName("WorkManagementServiceApp")] +class MSFT_WorkManagementServiceApp : OMI_BaseResource +{ + [Key] string Name; + [Required] String ApplicationPool; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 60a700e88..d23123f9f 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -95,6 +95,7 @@ + @@ -178,6 +179,7 @@ + @@ -202,6 +204,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 8a52e8497..d85e0870c 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -90,6 +90,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 new file mode 100644 index 000000000..e7acac80d --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 @@ -0,0 +1,107 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWorkManagementServiceApp" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWorkManagement" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "Test Work Management App" + ApplicationPool = "Test App Pool" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context "When no service applications exist in the current farm" { + + Mock Get-SPServiceApplication { return $null } + Mock New-SPWorkManagementServiceApplication { } + Mock New-SPWorkManagementServiceApplicationProxy { } + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "creates a new service application in the set method" { + Set-TargetResource @testParams + Assert-MockCalled New-SPWorkManagementServiceApplication + } + } + + Context "When service applications exist in the current farm but the specific Work Management app does not" { + + Mock Get-SPServiceApplication { return @(@{ + TypeName = "Some other service app type" + }) } + + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + } + + Context "When a service application exists and is configured correctly" { + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParams.Name + ApplicationPool = @{ Name = $testParams.ApplicationPool } + }) + } + + It "returns values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "returns true when the Test method is called" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "When a service application exists and is not configured correctly" { + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParams.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + })| Add-Member ScriptMethod Update { + $Global:xSPServiceApplicationUpdateCalled = $true + } -PassThru + } + Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the update service app cmdlet from the set method" { + $Global:xSPServiceApplicationUpdateCalled = $false + Set-TargetResource @testParams + Assert-MockCalled Get-SPServiceApplicationPool + $Global:xSPServiceApplicationUpdateCalled | Should be $true + + } + } + } +} From 58768cc3a94b0675bc4f409c43dd53083443cfea Mon Sep 17 00:00:00 2001 From: Camilo Date: Wed, 23 Dec 2015 17:01:12 +0000 Subject: [PATCH 05/91] ups sync --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 231 +++++++++++++ ...FT_xSPUserProfileSyncConnection.schema.mof | 38 +++ Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...int.xSPUserProfileSyncConnection.Tests.ps1 | 321 ++++++++++++++++++ 5 files changed, 594 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 new file mode 100644 index 000000000..fc99dbd41 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -0,0 +1,231 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $Forest, + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $ConnectionCredentials, + [parameter(Mandatory = $true)] [System.String] $UserProfileService, + [parameter(Mandatory = $true)] [System.String[]] $IncludedOUs, + [parameter(Mandatory = $false)] [System.String[]] $ExcludedOUs, + [parameter(Mandatory = $false)] [System.String] $Server, + [parameter(Mandatory = $false)] [System.String] $Force, + [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, + [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting user profile service sync connection $ConnectionDomain" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + + $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue + + If ($null -eq $ups) + { + return $null + } + else + { + + #what if permission isn't granted ? + $context = Get-xSharePointServiceContext $ups.ServiceApplicationProxyGroup + $upcm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileConfigManager $context + + $connection = $upcm.ConnectionManager | Where-Object { $_.DisplayName -eq $params.Name} + if($connection -eq $null){ + return $null + } + $namingContext = $connection.NamingContexts | select -first 1 + if($namingContext -eq $null){ + return $null + } + $accountCredentials = "$($connection.AccountDomain)\$($connection.AccountUsername)" + $domainController = $namingContext.PreferredDomainControllers | select -First 1 + return @{ + UserProfileService = $UserProfileService + Forest = $connection.Server #"contoso.com" #TODO: GetCorrect Forest + Name = $namingContext.DisplayName + Credentials = $accountCredentials + IncludedOUs = $namingContext.ContainersIncluded + ExcludedOUs = $namingContext.ContainersExcluded + Server =$domainController + UseSSL = $connection.UseSSL + ConnectionType = $connection.Type.ToString() + Force = $params.Force + } + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $Forest, + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $ConnectionCredentials, + [parameter(Mandatory = $true)] [System.String] $UserProfileService, + [parameter(Mandatory = $true)] [System.String[]] $IncludedOUs, + [parameter(Mandatory = $false)] [System.String[]] $ExcludedOUs, + [parameter(Mandatory = $false)] [System.String] $Server, + [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, + [parameter(Mandatory = $false)] [System.Boolean] $Force, + [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Creating user profile service application $Name" + + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + + if ($params.ContainsKey("InstallAccount")) { $params.Remove("InstallAccount") | Out-Null } + $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue + + if ($null -eq $ups) { + throw "User Profile Service Application $($params.UserProfileService) not found" + } + $context = Get-xSharePointServiceContext $ups.ServiceApplicationProxyGroup + Write-Verbose -Message "retrieving UserProfileConfigManager " + $upcm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager $context + + if($upcm.IsSynchronizationRunning()) + { + throw "Synchronization is in Progress." + } + + $securePassword = ConvertTo-SecureString $params.ConnectionCredentials.GetNetworkCredential().password -AsPlainText -Force + $connection = $upcm.ConnectionManager | Where-Object { $_.DisplayName -eq $params.Name} | select -first 1 + if($connection -ne $null -and $params.Forest -ieq $connection.Server) + { + $domain = $params.ConnectionCredentials.UserName.Split("\")[0] + $userName= $params.ConnectionCredentials.UserName.Split("\")[1] + $connection.SetCredentials($domain, $userName, $securePassword); + + $connection.NamingContexts | %{ + $namingContext = $_ + if($params.ContainsKey("IncludedOUs")){ + $namingContext.ContainersIncluded.Clear() + $params.IncludedOUs| %{$namingContext.ContainersIncluded.Add($_) } + } + $namingContext.ContainersExcluded.Clear() + if($params.ContainsKey("ExcludedOUs")){ + $params.IncludedOUs| %{$namingContext.ContainersExcluded.Add($_) } + } + } + $connection.Update(); + $connection.RefreshSchema($securePassword); + + return; + + }else{ + Write-Verbose -Message "creating a new connection " + if($connection -ne $null -and $params.Forest -ine $connection.Server){ + if($params.ContainsKey("Force") -and $params.Force -eq $true){ + $connection.Delete(); + }else{ + throw "connection exists and forest is different. use force " + } + + } + + $servers = New-Object System.Collections.Generic.List[[System.String]] + if($params.ContainsKey("Server")){ + $servers.add($params.Server) + } + $listIncludedOUs = New-Object System.Collections.Generic.List[[System.String]] + $params.IncludedOUs | %{ + $listIncludedOUs.Add($_) + } + + $listExcludedOUs = New-Object System.Collections.Generic.List[[System.String]] + if($params.ContainsKey("ExcludedOus")){ + $params.ExcludedOus | %{$listExcludedOUs.Add($_) } + } + $list = New-Object System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]] + + $partition = [ADSI]("LDAP://" +("DC=" + $params.Forest.Replace(".", ",DC="))) + $list.Add((New-Object Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext ( + $partition.distinguishedName, + $params.Forest, + $false, + (New-Object Guid($partition.objectGUID)) , + $listIncludedOUs , + $listExcludedOUs , + $null , + $false))) + $partition = [ADSI]("LDAP://CN=Configuration," +("DC=" + $params.Forest.Replace(".", ",DC="))) + $list.Add((New-Object Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext ( + $partition.distinguishedName, + $params.Forest, + $true, + (New-Object Guid($partition.objectGUID)) , + $listIncludedOUs , + $listExcludedOUs , + $null , + $false))) + + $userDomain = $params.ConnectionCredentials.UserName.Split("\")[0] + $userName= $params.ConnectionCredentials.UserName.Split("\")[1] + + $newUPSADConnection = $upcm.ConnectionManager.AddActiveDirectoryConnection( [Microsoft.Office.Server.UserProfiles.ConnectionType]::ActiveDirectory, ` + $params.Name, ` + $params.Forest, ` + $params.UseSSL, ` + $userDomain, ` + $userName, ` + $securePassword, ` + $list, ` + $null,` + $null) + } + } +} + + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $Forest, + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $ConnectionCredentials, + [parameter(Mandatory = $true)] [System.String] $UserProfileService, + [parameter(Mandatory = $true)] [System.String[]] $IncludedOUs, + [parameter(Mandatory = $false)] [System.String[]] $ExcludedOUs, + [parameter(Mandatory = $false)] [System.String] $Server, + [parameter(Mandatory = $false)] [System.String] $Force, + [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, + [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for user profile service sync connection $Name" + if ($null -eq $CurrentValues) { return $false } + if( $Force -eq $true) + { + return $false + } + + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name", "Forest", "UserProfileService", "Server", "UseSSL","IncludedOUs", "ExcludedOUs" ) + + +} + + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.schema.mof new file mode 100644 index 000000000..f380273a9 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.schema.mof @@ -0,0 +1,38 @@ +/* +**Description** + +This resource will ensure a specifc user profile sync connection is in place and that it is configured accordingly to its definition + +This resource currently supports AD only. +**Example** + + xSPUserProfileSyncConnection MainDomain + { + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = $connectionCredential + Server = "server.contoso.com" + UseSSL = $false + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") + ExcludedOUs = @("OU=Notes Usersa,DC=Contoso,DC=com") + Force = $false + ConnectionType = "ActiveDirectory" +} +*/ +[ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileSyncConnection")] +class MSFT_xSPUserProfileSyncConnection : OMI_BaseResource +{ + [Key] string Name; + [Required] string Forest; + [Required] string UserProfileService; + [Required, EmbeddedInstance("MSFT_Credential")] string ConnectionCredentials; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; + [Required] string IncludedOUs[]; + [write] string ExcludedOUs[]; + [write] string Server; + [Write] boolean UseSSL; + [Write] boolean Force; + [Write, ValueMap{"ActiveDirectory","BusinessDataCatalog"}, Values{"ActiveDirectory","BusinessDataCatalog"}] string ConnectionType ; +}; + diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 60a700e88..5296e7109 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -51,6 +51,7 @@ + @@ -104,6 +105,7 @@ + @@ -190,6 +192,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 8a52e8497..c49709e13 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -70,6 +70,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 new file mode 100644 index 000000000..a9e9c9e9c --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 @@ -0,0 +1,321 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPUserProfileSyncConnection" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + + +Describe "xSPUserProfileSyncConnection" { + InModuleScope $ModuleName { + $testParams = @{ + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + Server = "server.contoso.com" + UseSSL = $false + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") + ConnectionType = "ActiveDirectory" + } + + try { [Microsoft.Office.Server.UserProfiles] } + catch { + Add-Type @" + namespace Microsoft.Office.Server.UserProfiles { + public enum ConnectionType { ActiveDirectory, BusinessDataCatalog }; + } +"@ + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Get-xSharePointServiceContext {return @{}} + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" + + $connection = @{ + DisplayName = "Contoso" + Server = "contoso.com" + NamingContexts= New-Object System.Collections.ArrayList + AccountDomain = "Contoso" + AccountUsername = "TestAccount" + Type= "ActiveDirectory" + } + $connection = $connection | Add-Member ScriptMethod RefreshSchema { + $Global:xSPUPSSyncConnectionRefreshSchemaCalled = $true + } -PassThru | Add-Member ScriptMethod Update { + $Global:xSPUPSSyncConnectionUpdateCalled = $true + } -PassThru | Add-Member ScriptMethod SetCredentials { + param($userAccount,$securePassword ) + $Global:xSPUPSSyncConnectionSetCredentialsCalled = $true + } -PassThru | Add-Member ScriptMethod Delete { + $Global:xSPUPSSyncConnectionDeleteCalled = $true + } -PassThru + + $namingContext =@{ + ContainersIncluded = New-Object System.Collections.ArrayList + ContainersExcluded = New-Object System.Collections.ArrayList + DisplayName="Contoso" + PreferredDomainControllers=$null; + } + $namingContext.ContainersIncluded.Add("OU=com, OU=Contoso, OU=Included") + $namingContext.ContainersExcluded.Add("OU=com, OU=Contoso, OU=Excluded") + $connection.NamingContexts.Add($namingContext); + + $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` + param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` + $name, ` + $forest, ` + $useSSL, ` + $userName, ` + $securePassword, ` + $namingContext, ` + $p1, $p2 ` + ) + + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$true + } -PassThru + + Mock New-Object -MockWith { + return (@{ + ConnectionManager = $ConnnectionManager + } | Add-Member ScriptMethod IsSynchronizationRunning { + $Global:UpsSyncIsSynchronizationRunning=$true; + return $false; + } -PassThru ) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + + $userProfileServiceValidConnection = @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnectionManager= New-Object System.Collections.ArrayList + } + $userProfileServiceValidConnection.ConnectionManager.Add($connection); + + Context "When connection doesn't exist" { + $userProfileServiceNoConnections = @{ + Name = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnnectionManager = @() + } + + Mock Get-SPServiceApplication { return $userProfileServiceNoConnections } + + Mock New-Object -MockWith {return @{} + + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext"} + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "creates a new service application in the set method" { + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$false + Set-TargetResource @testParams + $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $true + } + } + + Context "When connection exists and account is different" { + Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } + + $ConnnectionManager.Add($connection) + + It "returns service instance from the Get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "execute update credentials" { + $Global:xSPUPSSyncConnectionSetCredentialsCalled=$false + $Global:xSPUPSSyncConnectionRefreshSchemaCalled=$false + Set-TargetResource @testParams + $Global:xSPUPSSyncConnectionSetCredentialsCalled | Should be $true + $Global:xSPUPSSyncConnectionRefreshSchemaCalled | Should be $true + } + } + + Context "When connection exists and forest is different" { + $litWareconnection = @{ + DisplayName = "Contoso" + Server = "litware.net" + NamingContexts= New-Object System.Collections.ArrayList + AccountDomain = "Contoso" + AccountUsername = "TestAccount" + Type= "ActiveDirectory" + } + $litWareconnection.NamingContexts.Add($namingContext); + $litWareconnection = $litWareconnection | Add-Member ScriptMethod Delete { + $Global:xSPUPSSyncConnectionDeleteCalled = $true + } -PassThru + $userProfileServiceValidConnection = @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnectionManager= New-Object System.Collections.ArrayList + } + + $userProfileServiceValidConnection.ConnectionManager.Add($litWareconnection); + Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } + $litwareConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` + param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` + $name, ` + $forest, ` + $useSSL, ` + $userName, ` + $securePassword, ` + $namingContext, ` + $p1, $p2 ` + ) + + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$true + } -PassThru + $litwareConnnectionManager.Add($litWareconnection) + + Mock New-Object -MockWith { + return (@{} | Add-Member ScriptMethod IsSynchronizationRunning { + $Global:UpsSyncIsSynchronizationRunning=$true; + return $false; + } -PassThru | Add-Member ConnectionManager $litwareConnnectionManager -PassThru ) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + + Mock New-Object -MockWith {return @{} + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext"} + + It "returns service instance from the Get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "throws exception as force isn't specified" { + $Global:xSPUPSSyncConnectionDeleteCalled=$false + {Set-TargetResource @testParams} | should throw + $Global:xSPUPSSyncConnectionDeleteCalled | Should be $false + } + + $forceTestParams = @{ + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + Server = "server.contoso.com" + UseSSL = $false + Force = $true + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") + ConnectionType = "ActiveDirectory" + } + + It "delete and create as force is specified" { + $Global:xSPUPSSyncConnectionDeleteCalled=$false + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$false + Set-TargetResource @forceTestParams + $Global:xSPUPSSyncConnectionDeleteCalled | Should be $true + $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $true + } + } + + Context "When synchronization is running" { + Mock Get-SPServiceApplication { + return @( + New-Object Object|Add-Member NoteProperty ServiceApplicationProxyGroup "Proxy Group" -PassThru + ) + } + + Mock New-Object -MockWith { + return (@{} | Add-Member ScriptMethod IsSynchronizationRunning { + $Global:UpsSyncIsSynchronizationRunning=$true; + return $true; + } -PassThru) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + + It "attempts to execute method but synchronization is running" { + $Global:UpsSyncIsSynchronizationRunning=$false + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$false + {Set-TargetResource @testParams }| Should throw + Assert-MockCalled Get-SPServiceApplication + Assert-MockCalled New-Object -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + $Global:UpsSyncIsSynchronizationRunning| Should be $true; + $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $false; + } + + } + + Context "When connection exists and Excluded and Included OUs are different. force parameter provided" { + $userProfileServiceValidConnection = @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnectionManager= New-Object System.Collections.ArrayList + } + $userProfileServiceValidConnection.ConnectionManager.Add($connection); + Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } + + $difOUsTestParams = @{ + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + Server = "server.contoso.com" + UseSSL = $false + Force = $false + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com","OU=Notes Users,DC=Contoso,DC=com") + ExcludedOUs = @("OU=Excluded, OU=SharePoint Users,DC=Contoso,DC=com") + ConnectionType = "ActiveDirectory" + } + + It "returns values from the get method" { + Get-TargetResource @difOUsTestParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + } + + It "returns false when the Test method is called" { + Test-TargetResource @difOUsTestParams | Should Be $false + } + + It "updates OU lists" { + $Global:xSPUPSSyncConnectionUpdateCalled= $false + $Global:xSPUPSSyncConnectionSetCredentialsCalled = $false + $Global:xSPUPSSyncConnectionRefreshSchemaCalled =$false + Set-TargetResource @difOUsTestParams + $Global:xSPUPSSyncConnectionUpdateCalled | Should be $true + $Global:xSPUPSSyncConnectionSetCredentialsCalled | Should be $true + $Global:xSPUPSSyncConnectionRefreshSchemaCalled | Should be $true + } + } + } +} + From 9d5e2c7f6b723a6b8528307f027d961d26b5954f Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 23 Dec 2015 21:40:23 +0100 Subject: [PATCH 06/91] Changed check for count to check for type --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 index 6249d3cfe..0969d40d0 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -39,7 +39,7 @@ function Get-TargetResource $querytext = "$($params.Name)" $spQuery.Query = $querytext $results = $healthRulesList.GetItems($spQuery) - if ($results.Count -eq 1) { + if ($results.GetType().IsArray -eq $false) { $item = $results[0] return @{ @@ -105,7 +105,7 @@ function Set-TargetResource $querytext = "$($params.Name)" $spQuery.Query = $querytext $results = $healthRulesList.GetItems($spQuery) - if ($results.Count -eq 1) { + if ($results.GetType().IsArray -eq $false) { $item = $results[0] $item["HealthRuleCheckEnabled"] = $params.Enabled From 88550cfb0b1d6b2fb1ccf70cde7b5850c4eafd91 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 23 Dec 2015 22:06:33 +0100 Subject: [PATCH 07/91] First draft version of the xSPWordAutomationServiceApp resource --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 104 ++++++++++++++++++ ...SFT_xSPWordAutomationServiceApp.schema.mof | 25 +++++ Modules/xSharePoint/xSharePoint.pssproj | 3 + Tests/Tests.pssproj | 1 + ...oint.xSPWordAutomationServiceApp.Tests.ps1 | 103 +++++++++++++++++ 5 files changed, 236 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof create mode 100644 Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 new file mode 100644 index 000000000..0bbeef570 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -0,0 +1,104 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting Word Automation service app '$Name'" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + if ($null -eq $serviceApps) { + return $null + } + $serviceApp = $serviceApps | Where-Object { $_.TypeName -eq "Word Automation Services" } + + + If ($null -eq $serviceApp) { + return $null + } else { + $returnVal = @{ + Name = $serviceApp.DisplayName + ApplicationPool = $serviceApp.ApplicationPool.Name + DatabaseName = $serviceApp.Databases.Name + DatabaseServer = $serviceApp.Databases.Server.Name + } + return $returnVal + } + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + $result = Get-TargetResource @PSBoundParameters + + if ($result -eq $null) { + Write-Verbose -Message "Creating Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + if($params.ContainsKey("InstallAccount")){ $params.Remove("InstallAccount")} + + New-SPWordConversionServiceApplication @params + } + } + else { + if ($ApplicationPool -ne $result.ApplicationPool) { + Write-Verbose -Message "Updating Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + + Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Word Automation Services" } ` + | Set-SPWordConversionServiceApplication -ApplicationPool $appPool + } + } + } +} + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") +} + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof new file mode 100644 index 000000000..eb4aa7438 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof @@ -0,0 +1,25 @@ +/* +**Description** + +The resource will provision and configure the Word Automation Service Application. +The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. + +**Example** + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Present" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $InstallAccount + } +*/ + +[ClassVersion("1.0.0.0"), FriendlyName("xSPWordAutomationServiceApp")] +class MSFT_xSPWordAutomationServiceApp : OMI_BaseResource +{ + [Key] string Name; + [Write] string ApplicationPool; + [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; + [Required] string DatabaseName; + [Write] string DatabaseServer; +}; diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 60a700e88..daca70959 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -95,6 +95,7 @@ + @@ -178,6 +179,7 @@ + @@ -202,6 +204,7 @@ + diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 8a52e8497..192eb7b7d 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -88,6 +88,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 new file mode 100644 index 000000000..34502df4c --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 @@ -0,0 +1,103 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPWordAutomationServiceApp" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPWordAutomationServiceApp" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "Test Word App" + ApplicationPool = "Test App Pool" + DatabaseName = "WordAutomationn" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context "When no service applications exist in the current farm" { + + Mock Get-SPServiceApplication { return $null } + Mock New-SPWordConversionServiceApplication { } + + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "creates a new service application in the set method" { + Set-TargetResource @testParams + Assert-MockCalled New-SPWordConversionServiceApplication + } + } + + Context "When service applications exist in the current farm but the specific word automation app does not" { + + Mock Get-SPServiceApplication { return @(@{ + TypeName = "Some other service app type" + }) } + + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + } + + Context "When a service application exists and is configured correctly" { + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Word Automation Services" + DisplayName = $testParams.Name + ApplicationPool = @{ Name = $testParams.ApplicationPool } + }) + } + + It "returns values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "returns true when the Test method is called" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "When a service application exists and is not configured correctly" { + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Word Automation Services" + DisplayName = $testParams.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + }) + } + Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } } + Mock Set-SPWordConversionServiceApplication {} + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "calls the update service app cmdlet from the set method" { + Set-TargetResource @testParams + + Assert-MockCalled Get-SPServiceApplicationPool + Assert-MockCalled Set-SPWordConversionServiceApplication + } + } + } +} From f6c817273b4458dfd42d3aee481af84fe5f51a3e Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 23 Dec 2015 22:26:35 +0100 Subject: [PATCH 08/91] Revert "Changed check for count to check for type" This reverts commit 9d5e2c7f6b723a6b8528307f027d961d26b5954f. --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 index 0969d40d0..6249d3cfe 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -39,7 +39,7 @@ function Get-TargetResource $querytext = "$($params.Name)" $spQuery.Query = $querytext $results = $healthRulesList.GetItems($spQuery) - if ($results.GetType().IsArray -eq $false) { + if ($results.Count -eq 1) { $item = $results[0] return @{ @@ -105,7 +105,7 @@ function Set-TargetResource $querytext = "$($params.Name)" $spQuery.Query = $querytext $results = $healthRulesList.GetItems($spQuery) - if ($results.GetType().IsArray -eq $false) { + if ($results.Count -eq 1) { $item = $results[0] $item["HealthRuleCheckEnabled"] = $params.Enabled From 2d737cc5a6f7f7aaa8d77662ac29cc3409c7ea06 Mon Sep 17 00:00:00 2001 From: Camilo Date: Thu, 24 Dec 2015 05:44:22 +0000 Subject: [PATCH 09/91] adding missing .Util method --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 66d422341..7c5c1c49d 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -27,6 +27,17 @@ function Get-xSharePointAssemblyVersion() { return (Get-Command $PathToAssembly).FileVersionInfo.FileMajorPart } +function Get-xSharePointServiceContext { + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true,Position=1)] + $proxyGroup + ) + Write-Verbose "Getting SPContext for Proxy group $($proxyGroup)" + return [Microsoft.SharePoint.SPServiceContext]::GetContext($proxyGroup,[Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default) +} + function Get-xSharePointContentService() { [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null return [Microsoft.SharePoint.Administration.SPWebService]::ContentService From 528eab83d339fc14344bb174d50137c27097374d Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 26 Dec 2015 10:00:33 +1100 Subject: [PATCH 10/91] Fixed name check of MOF file in test for PowerShell function match --- Tests/xSharePoint/xSharePoint.TestHelpers.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 17b735acc..3ed25b435 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -103,7 +103,7 @@ function Assert-MofSchemaScriptParameters() { ) $hasErrors = $false $mofSchemas = Get-MofSchemaObject -fileName $mofFileName - $mofData = $mofSchemas | Where-Object { $_.ClassName -eq $mofFileName.Replace(".schema.mof", "") } + $mofData = $mofSchemas | Where-Object { $_.ClassName -eq (Get-Item $mofFileName).Name.Replace(".schema.mof", "") } $psFile = $mofFileName.Replace(".schema.mof", ".psm1") $tokens = $null From d6f0f02150a8d306dff2ff55760c02f2a55d1867 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 25 Dec 2015 23:34:36 +0000 Subject: [PATCH 11/91] fixing unit tests --- .../xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 index a9e9c9e9c..e2ff74848 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 @@ -98,6 +98,9 @@ Describe "xSPUserProfileSyncConnection" { } -PassThru ) } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + Mock New-Object -MockWith { + return (New-Object System.Collections.Generic.List[System.Object]) + } -ParameterFilter { $TypeName -eq "System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]]" } $userProfileServiceValidConnection = @{ Name = "User Profile Service Application" TypeName = "User Profile Service Application" From b8d767cfdde338c58a1e703c295c4d557af138b1 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 26 Dec 2015 11:03:50 +1100 Subject: [PATCH 12/91] Fixed the tests and resolved schema errors found as a result of the test now working correctly --- .../MSFT_xSPCreateFarm.psm1 | 6 ++-- .../MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 6 ++-- .../MSFT_xSPSearchTopology.schema.mof | 2 +- .../MSFT_xSPSecureStoreServiceApp.schema.mof | 2 +- .../MSFT_xSPVisioServiceApp.schema.mof | 2 +- .../MSFT_xSPWebAppGeneralSettings.psm1 | 6 ++-- .../MSFT_xSPWebAppPolicy.schema.mof | 2 +- .../MSFT_xSPWebApplicationAppDomain.psm1 | 6 ++-- ...MSFT_xSPWebApplicationAppDomain.schema.mof | 10 +++--- .../xSharePoint/xSharePoint.TestHelpers.psm1 | 32 +++++++++++-------- 10 files changed, 40 insertions(+), 34 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 index af9b56d41..724c67f31 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 @@ -11,7 +11,7 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $true)] [System.String] $AdminContentDatabaseName, [parameter(Mandatory = $false)] [System.UInt32] $CentralAdministrationPort, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) Write-Verbose -Message "Checking for local SP Farm" @@ -66,7 +66,7 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $true)] [System.String] $AdminContentDatabaseName, [parameter(Mandatory = $false)] [System.UInt32] $CentralAdministrationPort, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { @@ -128,7 +128,7 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $true)] [System.String] $AdminContentDatabaseName, [parameter(Mandatory = $false)] [System.UInt32] $CentralAdministrationPort, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index cc99c4c1c..b09a970c2 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -8,7 +8,7 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String] $DatabaseServer, [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) Write-Verbose -Message "Checking for local SP Farm" @@ -51,7 +51,7 @@ function Set-TargetResource [parameter(Mandatory = $true)] [System.String] $DatabaseServer, [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) Write-Verbose -Message "Joining existing farm configuration database" @@ -113,7 +113,7 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String] $DatabaseServer, [parameter(Mandatory = $true)] [System.String] $Passphrase, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, - [parameter(Mandatory = $false)] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole + [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchTopology/MSFT_xSPSearchTopology.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchTopology/MSFT_xSPSearchTopology.schema.mof index 10a83e0d3..50fc83cca 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchTopology/MSFT_xSPSearchTopology.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchTopology/MSFT_xSPSearchTopology.schema.mof @@ -37,6 +37,6 @@ class MSFT_xSPSearchTopology : OMI_BaseResource [Required] String AnalyticsProcessing[]; [Required] String QueryProcessing[]; [Required] String IndexPartition[]; - [Write] String FirstPartitionDirectory; + [Required] String FirstPartitionDirectory; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof index 083cc00d7..a96db36b5 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSecureStoreServiceApp/MSFT_xSPSecureStoreServiceApp.schema.mof @@ -26,7 +26,7 @@ class MSFT_xSPSecureStoreServiceApp : OMI_BaseResource [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; [Write] string DatabaseName; [Write] string DatabaseServer; - [Write, ValueMap {"Windows","SQL"}, Values{"Windows","SQL"}] string DatabaseAuthenticationType; + [Write, ValueMap{"Windows","SQL"}, Values{"Windows","SQL"}] string DatabaseAuthenticationType; [Write] string FailoverDatabaseServer; [Write] boolean PartitionMode; [Write] boolean Sharing; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPVisioServiceApp/MSFT_xSPVisioServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPVisioServiceApp/MSFT_xSPVisioServiceApp.schema.mof index 4f9afe5e7..6dff9888b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPVisioServiceApp/MSFT_xSPVisioServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPVisioServiceApp/MSFT_xSPVisioServiceApp.schema.mof @@ -14,5 +14,5 @@ The resource will provision and configure the Visio Graphics Service Application class MSFT_xSPVisioServiceApp : OMI_BaseResource { [Key] string Name; - [Write] string ApplicationPool; + [Required] string ApplicationPool; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 index 167a00d21..5b5e040eb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppGeneralSettings/MSFT_xSPWebAppGeneralSettings.psm1 @@ -11,7 +11,7 @@ function Get-TargetResource [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)] [ValidateSet("Strict","Permissive")] [System.String] $BrowserFileHandling, [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, @@ -56,7 +56,7 @@ function Set-TargetResource [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)] [ValidateSet("Strict","Permissive")] [System.String] $BrowserFileHandling, [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, @@ -99,7 +99,7 @@ function Test-TargetResource [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)] [ValidateSet("Strict","Permissive")] [System.String] $BrowserFileHandling, [parameter(Mandatory = $false)] [System.Boolean] $SecurityValidation, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinEnabled, [parameter(Mandatory = $false)] [System.Boolean] $RecycleBinCleanupEnabled, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppPolicy/MSFT_xSPWebAppPolicy.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppPolicy/MSFT_xSPWebAppPolicy.schema.mof index 37bdcb485..ed1cf0d24 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppPolicy/MSFT_xSPWebAppPolicy.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebAppPolicy/MSFT_xSPWebAppPolicy.schema.mof @@ -18,7 +18,7 @@ class MSFT_xSPWebAppPolicy : OMI_BaseResource { [Key] string WebAppUrl; [Key] string UserName; - [Write, ValueMap{"Deny All","Deny Write","Full Read", "Full Control"}, Values{"Deny All","Deny Write","Full Read", "Full Control"}] string PermissionLevel; + [Required, ValueMap{"Deny All","Deny Write","Full Read","Full Control"}, Values{"Deny All","Deny Write","Full Read","Full Control"}] string PermissionLevel; [Write] boolean ActAsSystemUser; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 index 25c263aea..adea92537 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -42,7 +42,7 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -80,7 +80,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof index 5f2c0ac4a..a151d8637 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof @@ -22,10 +22,10 @@ The app prefix should still be set using the xSPAppDomain resource before this i [ClassVersion("1.0.0.0"), FriendlyName("xSPWebApplicationAppDomain")] class MSFT_xSPWebApplicationAppDomain : OMI_BaseResource { - [Key] string WebApplication; - [Key, ValueMap{"Internet","Intranet","Extranet", "Custom"}, Values{"Internet","Intranet","Extranet", "Custom"}] string Zone; - [Required] string AppDomain; - [Write] string Port; - [Write] boolean SSL + [Key] String WebApplication; + [Key, ValueMap{"Internet","Intranet","Extranet","Custom"}, Values{"Internet","Intranet","Extranet","Custom"}] String Zone; + [Required] String AppDomain; + [Write] Uint32 Port; + [Write] Boolean SSL; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 3ed25b435..5b38ca822 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -61,6 +61,7 @@ function Get-MofSchemaObject() { ValueMap = $null DataType = $null Name = $null + IsArray = $false } $start = $textLine.IndexOf("[") + 1 @@ -90,6 +91,11 @@ function Get-MofSchemaObject() { $attributeValue.DataType = $nonMetadataObjects[1] $attributeValue.Name = $nonMetadataObjects[2] + if ($attributeValue.Name.EndsWith("[]") -eq $true) { + $attributeValue.Name = $attributeValue.Name.Replace("[]", "") + $attributeValue.IsArray = $true + } + $currentResult.Attributes += $attributeValue } } @@ -112,7 +118,7 @@ function Assert-MofSchemaScriptParameters() { $functions = $ast.FindAll( {$args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]}, $true) $functions | ForEach-Object { - if ($_ -like "*-TargetResource") { + if ($_.Name -like "*-TargetResource") { $function = $_ $astTokens = $null $astErrors = $null @@ -162,21 +168,21 @@ function Assert-MofSchemaScriptParameters() { if (-not $validateSetAttribute) { $hasErrors = $true Write-Warning "File $psFile has parameter $($mofParameter.Name) that is missing a ValidateSet attribute in the $($function.Name) method" - } - - $psValidateSetParams = $validateSetAttribute.PositionalArguments | % { $_.Value.ToString() } + } else { + $psValidateSetParams = $validateSetAttribute.PositionalArguments | % { $_.Value.ToString() } - $mofParameter.ValueMap | ForEach-Object { - if ($psValidateSetParams -notcontains $_) { - $hasErrors = $true - Write-Warning "File $psFile has parameter $($mofParameter.Name) that does not have '$_' in its validateset parameter for $($function.Name) method" + $mofParameter.ValueMap | ForEach-Object { + if ($psValidateSetParams -notcontains $_) { + $hasErrors = $true + Write-Warning "File $psFile has parameter $($mofParameter.Name) that does not have '$_' in its validateset parameter for $($function.Name) method" + } } - } - $psValidateSetParams | ForEach-Object { - if ($mofParameter.ValueMap -notcontains $_) { - $hasErrors = $true - Write-Warning "File $psFile has parameter $($mofParameter.Name) that contains '$_' in the $($function.Name) function which is not in the valuemap in the schema" + $psValidateSetParams | ForEach-Object { + if ($mofParameter.ValueMap -notcontains $_) { + $hasErrors = $true + Write-Warning "File $psFile has parameter $($mofParameter.Name) that contains '$_' in the $($function.Name) function which is not in the valuemap in the schema" + } } } } From 8602f63ed2bc6aa77aceb1a4e5ec4b599c932ec9 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 26 Dec 2015 11:09:39 +1100 Subject: [PATCH 13/91] Fixed missing default option for zone --- .../MSFT_xSPWebApplicationAppDomain.psm1 | 6 +++--- .../MSFT_xSPWebApplicationAppDomain.schema.mof | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 index adea92537..82f6f374b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -42,7 +42,7 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -80,7 +80,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $AppDomain, [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, [parameter(Mandatory = $false)] [System.UInt32] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof index a151d8637..32e27ce7d 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof @@ -23,7 +23,7 @@ The app prefix should still be set using the xSPAppDomain resource before this i class MSFT_xSPWebApplicationAppDomain : OMI_BaseResource { [Key] String WebApplication; - [Key, ValueMap{"Internet","Intranet","Extranet","Custom"}, Values{"Internet","Intranet","Extranet","Custom"}] String Zone; + [Key, ValueMap{"Default","Internet","Intranet","Extranet","Custom"}, Values{"Default","Internet","Intranet","Extranet","Custom"}] String Zone; [Required] String AppDomain; [Write] Uint32 Port; [Write] Boolean SSL; From 4d73840ccee3ab8b5a970832b6fd493b74e28e06 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 26 Dec 2015 11:22:18 +1100 Subject: [PATCH 14/91] Added test to check for array types correctly --- Tests/xSharePoint/xSharePoint.TestHelpers.psm1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 index 5b38ca822..c31a32698 100644 --- a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 +++ b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 @@ -127,6 +127,10 @@ function Assert-MofSchemaScriptParameters() { $parameters = $functionAst.FindAll( {$args[0] -is [System.Management.Automation.Language.ParameterAst]}, $true) foreach ($mofParameter in $mofData.Attributes) { + + if ($mofParameter.IsArray -eq $true) { + $t = "t" + } # Check the parameter exists $paramToCheck = $parameters | Where-Object { $_.Name.ToString() -eq "`$$($mofParameter.Name)" } @@ -192,6 +196,14 @@ function Assert-MofSchemaScriptParameters() { $hasErrors = $true Write-Warning "File $psFile has parameter $($mofParameter.Name) in function $($function.Name) that does not match the data type of the schema" } + + if ($mofParameter.IsArray -eq $true) { + if (($paramToCheck.Attributes | ? { $_.TypeName.ToString() -match $mofParameter.DataType -and $_.TypeName.IsArray -eq $true }) -eq $null) { + $hasErrors = $true + Write-Warning "File $psFile has parameter $($mofParameter.Name) in function $($function.Name) that is marked as an array in the schema but is not an array in the PowerShell module" + } + + } } else { switch ($mofParameter.EmbeddedInstance) { "MSFT_Credential" { From 9dee5689411d19f69fe66008e10ff9e26a74c349 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 26 Dec 2015 18:28:27 +1100 Subject: [PATCH 15/91] Fixed selection of SP version after patch to parameter structure --- .../DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 | 6 +++--- .../DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 index 724c67f31..35c0ad796 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 @@ -16,7 +16,7 @@ function Get-TargetResource Write-Verbose -Message "Checking for local SP Farm" - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } @@ -69,7 +69,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } @@ -131,7 +131,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index b09a970c2..bde31be48 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -13,7 +13,7 @@ function Get-TargetResource Write-Verbose -Message "Checking for local SP Farm" - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } @@ -56,7 +56,7 @@ function Set-TargetResource Write-Verbose -Message "Joining existing farm configuration database" - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } @@ -116,7 +116,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] [ValidateSet("Application","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","SpecialLoad","WebFrontEnd")] $ServerRole ) - if ($null -ne $ServerRole -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { + if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) { throw [Exception] "Server role is only supported in SharePoint 2016." } From 8f7a035db592b04dfb6cbe75498b8e7baab533e0 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sun, 3 Jan 2016 22:00:50 +1100 Subject: [PATCH 16/91] adding xSPUserProfileProperty. Needs unit tests. resource xSPUSerProfileSection will be created to handle sections --- .../MSFT_xSPUserProfileProperty.psm1 | 200 ++++++++++++++++++ .../MSFT_xSPUserProfileProperty.schema.mof | 63 ++++++ Modules/xSharePoint/xSharePoint.pssproj | 3 + 3 files changed, 266 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 new file mode 100644 index 000000000..57ef63318 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -0,0 +1,200 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $false)] [System.string ] $DisplayName , + [parameter(Mandatory = $false)] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Description , + [parameter(Mandatory = $false)] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string ] $MappingDirection , + [parameter(Mandatory = $false)] [System.int ] $Length , + [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , + [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Getting user profile service application $Name" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + + $upsa = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue + $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) + if ($null -eq $upsa) { + return $null + } + return @{ + Name = $serviceApp.DisplayName + ApplicationPool = $serviceApp.ApplicationPool.Name + FarmAccount = $farmAccount + MySiteHostLocation = $params.MySiteHostLocation + ProfileDBName = $databases.ProfileDatabase.Name + ProfileDBServer = $databases.ProfileDatabase.Server.Name + SocialDBName = $databases.SocialDatabase.Name + SocialDBServer = $databases.SocialDatabase.Server.Name + SyncDBName = $databases.SynchronizationDatabase.Name + SyncDBServer = $databases.SynchronizationDatabase.Server.Name + InstallAccount = $params.InstallAccount + } + + } + return $result +} + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $true)] [System.string ] $DisplayName , + [parameter(Mandatory = $true)] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Description , + [parameter(Mandatory = $false)] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string ] $MappingDirection , + [parameter(Mandatory = $false)] [System.int ] $Length , + [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , + [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Creating user profile property $Name" + + $result = Invoke-xSharePointCommand -Credential $FarmAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $UPAConfMgr = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) + + #$UPAConnMgr = $UPAConfMgr.ConnectionManager + $userProfilePropertyManager = $UPAConfMgr.ProfilePropertyManager + $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) + $CoreProperties = $UPAConfMgr.ProfilePropertyManager.GetCoreProperties() + + $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) + $userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) + + if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ + if($UPProperty -ne $null) + { + $CoreProperties.RemovePropertyByName($params.Name) + } + } elseif($UPProperty -eq $null){ + $coreProperty = $CoreProperties.Create($false) + $coreProperty.Name = $params.Name + $coreProperty.DisplayName = $params.DisplayName + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "PropLength" + + if($SharePointPropType.ToLower() -eq "stringmultivalue") + { + $coreProperty.IsMultivalued =$true; + } + $coreProperty.Type = $SharePointPropType + $CoreProperties.Add($coreProperty) + $UPTypeProperty = $userProfileTypeProperties.Create($coreProperty) + $upSubProperty = $userProfileProperties.Create($UPTypeProperty) + $userProfileProperties.Add($upSubProperty) + Sleep -Miliseconds 100 + $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) #sproperty + } + + $UPTypeProperty = $userProfileTypeProperties.GetPropertyByName($params.Name) + $coreProperty = $UPTypeProperty.CoreProperty + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" + + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnViewer" -ParamsValue $params -ParamKey "IsVisibleOnViewer" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnEditor" -ParamsValue $params -ParamKey "IsVisibleOnEditor" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsEventLog" -ParamsValue $params -ParamKey "IsEventLog" + + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "DefaultPrivacy" -ParamsValue $params -ParamKey "PrivacySetting" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" + + $UPTypeProperty.CoreProperty.Commit() + $UPTypeProperty.Commit() + $UPProperty.Commit() + #Setting the display order + if($params.ContainsKey("DisplayOrder")) + { + $userProfileProperties.SetDisplayOrderByPropertyName($params.Name,$SharePointPropDisplayOrder) + $userProfileProperties.CommitDisplayOrder() + } + + #region mapping + $syncConnection = $UPAConfMgr.ConnectionManager[$params.MappingConnectionName] + $PropertyMapping = $syncConnection.PropertyMapping + $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) + if($currentmapping -eq $null) + { + $import = ((!$params.ContainsKey("MappingDirection")) -or ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Import")) + $export = !$import -and ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") + $synchConnection.PropertyMapping.Add( $params.Name, $params.MappingPropertyName,$import, $export) + } + #endregion + } + return $result +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $false)] [System.string ] $DisplayName , + [parameter(Mandatory = $false)] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Description , + [parameter(Mandatory = $false)] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string ] $MappingDirection , + [parameter(Mandatory = $false)] [System.int ] $Length , + [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , + [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + + ) + + $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for user profile service application $Name" + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name") +} + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof new file mode 100644 index 000000000..99fbbf0bf --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -0,0 +1,63 @@ +/* +**Description** + +This resource will create a property in a user profile service application. +It creates, update or delete a property using the parameters that are passed in to it . + +The parameter DisplayOrder is absolute. ie.: If you want it to be placed as the 5th field of section Bla, which has propertyName value of 5000 then your DisplayOrder needs to be 5005 +If no DisplayOrder is added then SharePoint adds it as the last property of section X. + +Length is only relevant if Field type is "String". + +**Example** +xSPUserProfileProperty WorkEmailProperty +{ + Name = "WorkEmail" + UserProfileServiceAppName = "User Profile Service Application" + DisplayName = "Work Email" + Type = "Email" + Description = "" #implementation isn't using it yet + PolicySetting = "Required" + PrivacySetting = "Everyone" + AllowUserEdit = $false + MappingConnectionName = "contoso.com" + MappingPropertyName = "mail" + MappingDirection = "Import" + Length = 10 + DisplayOrder =25 #relative to the section + IsEventLog =$false + IsVisibleOnEditor=$true + IsVisibleOnViewer = $true + IsUserEditable = $true + UserOverridePrivacy = $false +} + +*/ + + +[ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileProperty")] +class MSFT_xSPUserProfileProperty : OMI_BaseResource +{ + [Key] string Name + [ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [required] string UserProfileServiceAppName + [required] string DisplayName + [Required, [ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] ] string Type + [write] string Description + [ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; + [ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; + [write] boolean AllowUserEdit + [write] string MappingConnectionName + [write] string MappingPropertyName + [write] string MappingDirection + [write] uint32 Length + [write] uint32 DisplayOrder + [write] boolean IsEventLog + [write] boolean IsVisibleOnEditor + [write] boolean IsVisibleOnViewer + [write] boolean IsUserEditable + [write] boolean UserOverridePrivacy + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + + diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 60a700e88..eafa7f4f7 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -51,6 +51,7 @@ + @@ -104,6 +105,7 @@ + @@ -190,6 +192,7 @@ + From 480db0d6eca67bb5611a32536ad1fe469fe60dbd Mon Sep 17 00:00:00 2001 From: Camilo Date: Mon, 4 Jan 2016 04:27:54 +0000 Subject: [PATCH 17/91] unit test skeleton written --- Tests/Tests.pssproj | 1 + ...harePoint.xSPUserProfileProperty.Tests.ps1 | 166 ++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index 8a52e8497..f4de2f13c 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -70,6 +70,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 new file mode 100644 index 000000000..92e4cca98 --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -0,0 +1,166 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPUserProfileProperty" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + + +Describe "xSPUserProfileProperty" { + InModuleScope $ModuleName { + $testParams = @{ + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + Server = "server.contoso.com" + UseSSL = $false + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") + ConnectionType = "ActiveDirectory" + } + + try { [Microsoft.Office.Server.UserProfiles] } + catch { + Add-Type @" + namespace Microsoft.Office.Server.UserProfiles { + public enum ConnectionType { ActiveDirectory, BusinessDataCatalog }; + } +"@ + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + Mock Get-xSharePointServiceContext {return @{}} + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" + + $connection = @{ + DisplayName = "Contoso" + Server = "contoso.com" + NamingContexts= New-Object System.Collections.ArrayList + AccountDomain = "Contoso" + AccountUsername = "TestAccount" + Type= "ActiveDirectory" + } + $connection = $connection | Add-Member ScriptMethod RefreshSchema { + $Global:xSPUPSSyncConnectionRefreshSchemaCalled = $true + } -PassThru | Add-Member ScriptMethod Update { + $Global:xSPUPSSyncConnectionUpdateCalled = $true + } -PassThru | Add-Member ScriptMethod SetCredentials { + param($userAccount,$securePassword ) + $Global:xSPUPSSyncConnectionSetCredentialsCalled = $true + } -PassThru | Add-Member ScriptMethod Delete { + $Global:xSPUPSSyncConnectionDeleteCalled = $true + } -PassThru + + $namingContext =@{ + ContainersIncluded = New-Object System.Collections.ArrayList + ContainersExcluded = New-Object System.Collections.ArrayList + DisplayName="Contoso" + PreferredDomainControllers=$null; + } + $namingContext.ContainersIncluded.Add("OU=com, OU=Contoso, OU=Included") + $namingContext.ContainersExcluded.Add("OU=com, OU=Contoso, OU=Excluded") + $connection.NamingContexts.Add($namingContext); + + $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` + param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` + $name, ` + $forest, ` + $useSSL, ` + $userName, ` + $securePassword, ` + $namingContext, ` + $p1, $p2 ` + ) + + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$true + } -PassThru + + Mock New-Object -MockWith { + return (@{ + ConnectionManager = $ConnnectionManager + } | Add-Member ScriptMethod IsSynchronizationRunning { + $Global:UpsSyncIsSynchronizationRunning=$true; + return $false; + } -PassThru ) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } + + Mock New-Object -MockWith { + return (New-Object System.Collections.Generic.List[System.Object]) + } -ParameterFilter { $TypeName -eq "System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]]" } + $userProfileServiceValidConnection = @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnectionManager= New-Object System.Collections.ArrayList + } + $userProfileServiceValidConnection.ConnectionManager.Add($connection); + + Context "When connection doesn't exist" { + <# $userProfileServiceNoConnections = @{ + Name = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + ServiceApplicationProxyGroup = "Proxy Group" + ConnnectionManager = @() + } + + Mock Get-SPServiceApplication { return $userProfileServiceNoConnections } + + Mock New-Object -MockWith {return @{} + + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext"} + It "returns null from the Get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + } + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "creates a new service application in the set method" { + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$false + Set-TargetResource @testParams + $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $true + } + #> + } + + Context "When property doesn't exist" { + } + + Context "When property exists" { + } + + Context "When property exists and type is different" { + } + + Context "When property exists and mapping does not " { + + } + Context "When property exists and mapping exists, mapping config matches" { + + } + Context "When property exists and mapping exists, mapping config does not match" { + + } + + + } +} From 074487b0bf354281a9c018124d09ea2e2594e74f Mon Sep 17 00:00:00 2001 From: Camilo Date: Mon, 4 Jan 2016 07:28:52 +0000 Subject: [PATCH 18/91] adding term set properties and started implementation --- .../MSFT_xSPUserProfileProperty.psm1 | 33 +++++++++++++++++-- .../MSFT_xSPUserProfileProperty.schema.mof | 17 ++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 57ef63318..9ab54bb81 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -22,7 +22,12 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $IsAlias , + [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.string ] $TermStore , + [parameter(Mandatory = $false)] [System.string ] $TermGroup , + [parameter(Mandatory = $false)] [System.string ] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -31,7 +36,7 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - + #TermSet ts = property.TermSet; $upsa = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) if ($null -eq $upsa) { @@ -78,7 +83,12 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $IsAlias , + [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.string ] $TermStore , + [parameter(Mandatory = $false)] [System.string ] $TermGroup , + [parameter(Mandatory = $false)] [System.string ] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -95,7 +105,8 @@ function Set-TargetResource $CoreProperties = $UPAConfMgr.ProfilePropertyManager.GetCoreProperties() $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) - $userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + # + #$userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ @@ -125,6 +136,7 @@ function Set-TargetResource $UPTypeProperty = $userProfileTypeProperties.GetPropertyByName($params.Name) $coreProperty = $UPTypeProperty.CoreProperty Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnViewer" -ParamsValue $params -ParamKey "IsVisibleOnViewer" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnEditor" -ParamsValue $params -ParamKey "IsVisibleOnEditor" @@ -134,7 +146,17 @@ function Set-TargetResource Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" - + #region MMS properties + $termSet = null; + if ((![String]::IsNullOrEmpty($termStoreName)) -and (![String]::IsNullOrEmpty($termgroupName)) -and (![String]::IsNullOrEmpty($termSetName))) + { + TaxonomySession session = new TaxonomySession(_site); + TermStore termStore = session.TermStores[termStoreName]; + Group group = termStore.Groups[groupName]; + termSet = group.TermSets[termSetName]; + } + #endregion + $UPTypeProperty.CoreProperty.Commit() $UPTypeProperty.Commit() $UPProperty.Commit() @@ -185,7 +207,12 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , + [parameter(Mandatory = $false)] [System.bool ] $IsAlias , + [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.string ] $TermStore , + [parameter(Mandatory = $false)] [System.string ] $TermGroup , + [parameter(Mandatory = $false)] [System.string ] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 99fbbf0bf..0f1c7e0a8 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -1,3 +1,4 @@ + /* **Description** @@ -9,6 +10,11 @@ If no DisplayOrder is added then SharePoint adds it as the last property of sect Length is only relevant if Field type is "String". +This DSC resource doesn't currently supports metadata properties + +-- needs to add support to + - linking to MMS terms + - indexed properties **Example** xSPUserProfileProperty WorkEmailProperty { @@ -29,6 +35,11 @@ xSPUserProfileProperty WorkEmailProperty IsVisibleOnEditor=$true IsVisibleOnViewer = $true IsUserEditable = $true + IsAlias = $false #: used to edit “Alias” of the property value under Search Settings. + IsSearchable = $false # e: used to edit “Indexed” of the property value again under Search Settings. + TermStore = "" + TermGroup = "" + TermSet = "" UserOverridePrivacy = $false } @@ -56,8 +67,14 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource [write] boolean IsVisibleOnEditor [write] boolean IsVisibleOnViewer [write] boolean IsUserEditable + [write] boolean IsAlias + [write] boolean IsSearchable [write] boolean UserOverridePrivacy + [write] string TermStore + [write] string TermSetGroup + [write] string TermSet [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; + From 089bbbf5b2ee08055c45905312c8ae2543bacb7a Mon Sep 17 00:00:00 2001 From: Camilo Date: Tue, 5 Jan 2016 12:45:44 +0000 Subject: [PATCH 19/91] adding support for termSets, fixing get-target --- .../MSFT_xSPUserProfileProperty.psm1 | 180 ++++++++++++------ .../MSFT_xSPUserProfileProperty.schema.mof | 2 - ...harePoint.xSPUserProfileProperty.Tests.ps1 | 6 + 3 files changed, 130 insertions(+), 58 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 9ab54bb81..cc9c80c6a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -36,25 +36,78 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - #TermSet ts = property.TermSet; + $upsa = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue - $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) if ($null -eq $upsa) { return $null } - return @{ - Name = $serviceApp.DisplayName - ApplicationPool = $serviceApp.ApplicationPool.Name - FarmAccount = $farmAccount - MySiteHostLocation = $params.MySiteHostLocation - ProfileDBName = $databases.ProfileDatabase.Name - ProfileDBServer = $databases.ProfileDatabase.Server.Name - SocialDBName = $databases.SocialDatabase.Name - SocialDBServer = $databases.SocialDatabase.Server.Name - SyncDBName = $databases.SynchronizationDatabase.Name - SyncDBServer = $databases.SynchronizationDatabase.Server.Name - InstallAccount = $params.InstallAccount + $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url + $context = Get-SPServiceContext $caURL + $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) + $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) + $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + if($null -eq $userProfileProperty ){ + return $null + } + + $termSet = @{ + TermSet = "" + TermGroup ="" + TermStore = "" + } + + if($userProfileProperty.CoreProperty.TermSet -ne $null) + { + $termSet.TermSet = $userProfileProperty.CoreProperty.TermSet.Name + $termSet.TermGroup = $userProfileProperty.CoreProperty.TermSet.Group.Name + $termSet.TermStore = $userProfileProperty.CoreProperty.TermSet.TermStore.Name + } + $mapping = @{ + ConectionName = "" + PropertyName ="" + Direction = "" + } + $syncConnection = $userProfileConfigManager.ConnectionManager | ? {$_.PropertyMapping.Item($params.Name) -ne $null} + if($syncConnection -ne $null) { + $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) + if($currentMapping -ne $null) + { + $mapping.Direction = "Import" + $mapping.ConnectionName = $params.MappingConnectionName + if($currentMapping.IsExport) + { + $mapping.Direction = "Export" + } + $mapping.PropertyName = $currentMapping.DataSourcePropertyName + } } + } + + return @{ + Name = $userProfileProperty.Name + UserProfileServiceAppName = $params.$UserProfileServiceAppName + DisplayName = $userProfileProperty.DisplayName + Type = $userProfileProperty.CoreProperty.Type.GetTypeCode() + Description = $userProfileProperty.Description + PolicySetting = $userProfileProperty.PrivacyPolicy + PrivacySetting = $userProfileProperty.DefaultPrivacy + MappingConnectionName = $MappingConnectionName.ConnectionName + MappingPropertyName = $mapping.PropertyName + MappingDirection = $Mapping.Direction + Length = $userProfileProperty.CoreProperty.Length + DisplayOrder =$userProfileProperty.DisplayOrder + IsEventLog =$userProfileProperty.TypeProperty.IsEventLog + IsVisibleOnEditor=$userProfileProperty.TypeProperty.IsVisibleOnEditor + IsVisibleOnViewer =$userProfileProperty.TypeProperty.IsVisibleOnViewer + IsUserEditable = $userProfileProperty.IsUserEditable + IsAlias = $userProfileProperty.IsAlias + IsSearchable = $userProfileProperty.CoreProperty.IsSearchable + TermStore = $termSet.TermStore + TermGroup = $termSet.TermGroup + TermSet = $termSet.TermSet + UserOverridePrivacy = $userProfileProperty.AllowPolicyOverride + } } return $result @@ -97,28 +150,39 @@ function Set-TargetResource $result = Invoke-xSharePointCommand -Credential $FarmAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $UPAConfMgr = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) + $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue + + If ($null -eq $ups) + { + return $null + } + #what if permission isn't granted ? + + $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url + $context = Get-SPServiceContext $caURL + $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) - #$UPAConnMgr = $UPAConfMgr.ConnectionManager - $userProfilePropertyManager = $UPAConfMgr.ProfilePropertyManager + #$UPAConnMgr = $userProfileConfigManager.ConnectionManager + $userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) - $CoreProperties = $UPAConfMgr.ProfilePropertyManager.GetCoreProperties() + $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) - # - #$userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) - $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) + $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ - if($UPProperty -ne $null) + if($userProfileProperty -ne $null) { $CoreProperties.RemovePropertyByName($params.Name) } - } elseif($UPProperty -eq $null){ + } elseif($userProfileProperty -eq $null){ $coreProperty = $CoreProperties.Create($false) $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "PropLength" + + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" if($SharePointPropType.ToLower() -eq "stringmultivalue") { @@ -127,55 +191,59 @@ function Set-TargetResource $coreProperty.Type = $SharePointPropType $CoreProperties.Add($coreProperty) $UPTypeProperty = $userProfileTypeProperties.Create($coreProperty) - $upSubProperty = $userProfileProperties.Create($UPTypeProperty) - $userProfileProperties.Add($upSubProperty) - Sleep -Miliseconds 100 - $UPProperty = $userProfileProperties.GetPropertyByName($params.Name) #sproperty + $upSubProperty = $UPProperties.Create($UPTypeProperty) + $UPProperties.Add($upSubProperty) + Sleep -Miliseconds 100 + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) } - $UPTypeProperty = $userProfileTypeProperties.GetPropertyByName($params.Name) - $coreProperty = $UPTypeProperty.CoreProperty - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" + $coreProperty = $userProfileProperty.CoreProperty + $userProfileTypeProperty = $userProfileProperty.TypeProperty Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Description" -ParamsValue $params -ParamKey "Description" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnViewer" -ParamsValue $params -ParamKey "IsVisibleOnViewer" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsVisibleOnEditor" -ParamsValue $params -ParamKey "IsVisibleOnEditor" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPTypeProperty -PropertyToSet "IsEventLog" -ParamsValue $params -ParamKey "IsEventLog" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileTypeProperty -PropertyToSet "IsVisibleOnViewer" -ParamsValue $params -ParamKey "IsVisibleOnViewer" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileTypeProperty -PropertyToSet "IsVisibleOnEditor" -ParamsValue $params -ParamKey "IsVisibleOnEditor" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileTypeProperty -PropertyToSet "IsEventLog" -ParamsValue $params -ParamKey "IsEventLog" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "DefaultPrivacy" -ParamsValue $params -ParamKey "PrivacySetting" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $UPProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "DefaultPrivacy" -ParamsValue $params -ParamKey "PrivacySetting" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" #region MMS properties - $termSet = null; if ((![String]::IsNullOrEmpty($termStoreName)) -and (![String]::IsNullOrEmpty($termgroupName)) -and (![String]::IsNullOrEmpty($termSetName))) { - TaxonomySession session = new TaxonomySession(_site); - TermStore termStore = session.TermStores[termStoreName]; - Group group = termStore.Groups[groupName]; - termSet = group.TermSets[termSetName]; + $session = new-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($caURL); + $termStore = $session.TermStores[$params.TermStore]; + $group = $termStore.Groups[$params.TermGroup]; + $termSet = $group.TermSets[$params.TermSet]; + if($termSet -ne $null) + { + $coreProperty.TermSet = $termSet + } } #endregion - $UPTypeProperty.CoreProperty.Commit() - $UPTypeProperty.Commit() - $UPProperty.Commit() + $coreProperty.CoreProperty.Commit() + $userProfileTypeProperty.Commit() + $userProfileProperty.Commit() #Setting the display order if($params.ContainsKey("DisplayOrder")) { - $userProfileProperties.SetDisplayOrderByPropertyName($params.Name,$SharePointPropDisplayOrder) - $userProfileProperties.CommitDisplayOrder() + $UPProperties.SetDisplayOrderByPropertyName($params.Name,$SharePointPropDisplayOrder) + $UPProperties.CommitDisplayOrder() } #region mapping - $syncConnection = $UPAConfMgr.ConnectionManager[$params.MappingConnectionName] - $PropertyMapping = $syncConnection.PropertyMapping - $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) - if($currentmapping -eq $null) - { - $import = ((!$params.ContainsKey("MappingDirection")) -or ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Import")) - $export = !$import -and ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") - $synchConnection.PropertyMapping.Add( $params.Name, $params.MappingPropertyName,$import, $export) + if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ + $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] + $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) + if($currentmapping -eq $null) + { + $import = ((!$params.ContainsKey("MappingDirection")) -or ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Import")) + $export = !$import -and ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") + $synchConnection.PropertyMapping.Add( $params.Name, $params.MappingPropertyName,$import, $export) + } } #endregion } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 0f1c7e0a8..f08cf11cb 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -25,7 +25,6 @@ xSPUserProfileProperty WorkEmailProperty Description = "" #implementation isn't using it yet PolicySetting = "Required" PrivacySetting = "Everyone" - AllowUserEdit = $false MappingConnectionName = "contoso.com" MappingPropertyName = "mail" MappingDirection = "Import" @@ -57,7 +56,6 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource [write] string Description [ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; [ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; - [write] boolean AllowUserEdit [write] string MappingConnectionName [write] string MappingPropertyName [write] string MappingDirection diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 92e4cca98..34a2b0a75 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -159,8 +159,14 @@ Describe "xSPUserProfileProperty" { } Context "When property exists and mapping exists, mapping config does not match" { + } + Context "When creating property and user has no access to MMS" { + } + Context "When creating property and there is no MMS with default storage location for column specific" { + + } } } From 8b7740f7870fc430707cecdadfe13cc85b18ac93 Mon Sep 17 00:00:00 2001 From: Camilo Date: Tue, 5 Jan 2016 12:51:57 +0000 Subject: [PATCH 20/91] ... --- .../MSFT_xSPUserProfileProperty.psm1 | 1 - .../MSFT_xSPUserProfileProperty.schema.mof | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index cc9c80c6a..924909c5a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -80,7 +80,6 @@ function Get-TargetResource $mapping.Direction = "Export" } $mapping.PropertyName = $currentMapping.DataSourcePropertyName - } } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index f08cf11cb..70f1136b0 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -18,7 +18,7 @@ This DSC resource doesn't currently supports metadata properties **Example** xSPUserProfileProperty WorkEmailProperty { - Name = "WorkEmail" + Name = "WorkEmail2" UserProfileServiceAppName = "User Profile Service Application" DisplayName = "Work Email" Type = "Email" @@ -34,7 +34,7 @@ xSPUserProfileProperty WorkEmailProperty IsVisibleOnEditor=$true IsVisibleOnViewer = $true IsUserEditable = $true - IsAlias = $false #: used to edit “Alias” of the property value under Search Settings. + IsAlias = $false #: used to edit "Alias" of the property value under Search Settings. IsSearchable = $false # e: used to edit “Indexed” of the property value again under Search Settings. TermStore = "" TermGroup = "" From 03b53ce054a0d633643eabeabef377927920bb2f Mon Sep 17 00:00:00 2001 From: Camilo Date: Tue, 5 Jan 2016 14:55:29 +0000 Subject: [PATCH 21/91] integration tested --- .../MSFT_xSPUserProfileProperty.psm1 | 117 ++++++++++-------- ...harePoint.xSPUserProfileProperty.Tests.ps1 | 4 +- 2 files changed, 69 insertions(+), 52 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 924909c5a..f026c9d51 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -12,19 +12,19 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.int ] $Length , - [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , - [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , - [parameter(Mandatory = $false)] [System.bool ] $IsAlias , - [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, - [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Int32] $Length , + [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , [parameter(Mandatory = $false)] [System.string ] $TermStore , [parameter(Mandatory = $false)] [System.string ] $TermGroup , [parameter(Mandatory = $false)] [System.string ] $TermSet , @@ -82,10 +82,11 @@ function Get-TargetResource $mapping.PropertyName = $currentMapping.DataSourcePropertyName } } + return @{ Name = $userProfileProperty.Name - UserProfileServiceAppName = $params.$UserProfileServiceAppName + UserProfileServiceAppName = $params.UserProfileServiceAppName DisplayName = $userProfileProperty.DisplayName Type = $userProfileProperty.CoreProperty.Type.GetTypeCode() Description = $userProfileProperty.Description @@ -125,19 +126,19 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.int ] $Length , - [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , - [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , - [parameter(Mandatory = $false)] [System.bool ] $IsAlias , - [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, - [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Int32] $Length , + [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , [parameter(Mandatory = $false)] [System.string ] $TermStore , [parameter(Mandatory = $false)] [System.string ] $TermGroup , [parameter(Mandatory = $false)] [System.string ] $TermSet , @@ -145,11 +146,11 @@ function Set-TargetResource ) Write-Verbose -Message "Creating user profile property $Name" - - $result = Invoke-xSharePointCommand -Credential $FarmAccount -Arguments $PSBoundParameters -ScriptBlock { + $test = $PSBoundParameters + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $test -ScriptBlock { $params = $args[0] - $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue If ($null -eq $ups) { @@ -160,17 +161,23 @@ function Set-TargetResource $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url $context = Get-SPServiceContext $caURL $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) - - #$UPAConnMgr = $userProfileConfigManager.ConnectionManager + $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() + $userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) - $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() + $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) - + $userProfileSubTypeProperties = $userProfileSubType.Properties $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] + if($null -eq $syncConnection ) { + throw "connection not found" + } + + if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ if($userProfileProperty -ne $null) { @@ -181,18 +188,20 @@ function Set-TargetResource $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" - if($SharePointPropType.ToLower() -eq "stringmultivalue") + if($params.Type.ToLower() -eq "stringmultivalue") { $coreProperty.IsMultivalued =$true; } - $coreProperty.Type = $SharePointPropType + $coreProperty.Type = $params.Type $CoreProperties.Add($coreProperty) - $UPTypeProperty = $userProfileTypeProperties.Create($coreProperty) - $upSubProperty = $UPProperties.Create($UPTypeProperty) - $UPProperties.Add($upSubProperty) - Sleep -Miliseconds 100 + $upTypeProperty = $userProfileTypeProperties.Create($coreProperty) + $userProfileTypeProperties.Add($upTypeProperty) + $upSubProperty = $userProfileSubTypeProperties.Create($UPTypeProperty) + $userProfileSubTypeProperties.Add($upSubProperty) + Sleep -Milliseconds 100 $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) } @@ -223,28 +232,34 @@ function Set-TargetResource } #endregion - $coreProperty.CoreProperty.Commit() + $userProfileProperty.CoreProperty.Commit() $userProfileTypeProperty.Commit() $userProfileProperty.Commit() #Setting the display order if($params.ContainsKey("DisplayOrder")) { - $UPProperties.SetDisplayOrderByPropertyName($params.Name,$SharePointPropDisplayOrder) - $UPProperties.CommitDisplayOrder() + $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) + $profileManager.Properties.SetDisplayOrderByPropertyName($params.Name,$params.DisplayOrder) + $profileManager.Properties.CommitDisplayOrder() } #region mapping if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] - $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) + $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) if($currentmapping -eq $null) { - $import = ((!$params.ContainsKey("MappingDirection")) -or ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Import")) $export = !$import -and ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") - $synchConnection.PropertyMapping.Add( $params.Name, $params.MappingPropertyName,$import, $export) + if($export){ + $syncConnection.PropertyMapping.AddNewExportMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + }else{ + $syncConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + } + } - } + } #endregion + } return $result } @@ -264,19 +279,19 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.bool ] $AllowUserEdit , + [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.int ] $Length , - [parameter(Mandatory = $false)] [System.int ] $DisplayOrder , - [parameter(Mandatory = $false)] [System.bool ] $IsEventLog , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.bool ] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.bool ] $IsUserEditable , - [parameter(Mandatory = $false)] [System.bool ] $IsAlias , - [parameter(Mandatory = $false)] [System.bool ] $IsSearchable, - [parameter(Mandatory = $false)] [System.bool ] $UserOverrridePrivacy , + [parameter(Mandatory = $false)] [System.Int32] $Length , + [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , [parameter(Mandatory = $false)] [System.string ] $TermStore , [parameter(Mandatory = $false)] [System.string ] $TermGroup , [parameter(Mandatory = $false)] [System.string ] $TermSet , diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 34a2b0a75..1c3d0b583 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -167,6 +167,8 @@ Describe "xSPUserProfileProperty" { Context "When creating property and there is no MMS with default storage location for column specific" { } - + Context "When property exists and ensure equals Absent" { + + } } } From 638a6db9e219d26d864f94536fbb6450e07bc147 Mon Sep 17 00:00:00 2001 From: Camilo Date: Wed, 6 Jan 2016 09:34:35 +0000 Subject: [PATCH 22/91] writing unit tests body. --- .../MSFT_xSPUserProfileProperty.psm1 | 128 +++++++++--- .../xSharePoint.Util/xSharePoint.Util.psm1 | 11 + ...harePoint.xSPUserProfileProperty.Tests.ps1 | 192 +++++++++++++++--- 3 files changed, 273 insertions(+), 58 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index f026c9d51..1b2e95410 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -44,8 +44,10 @@ function Get-TargetResource $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url $context = Get-SPServiceContext $caURL $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) - $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) - $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + + $userProfileSubTypeManager = Get-xSharePointUserProfileSubTypeManager $context + $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype("UserProfile") + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) if($null -eq $userProfileProperty ){ return $null @@ -92,7 +94,7 @@ function Get-TargetResource Description = $userProfileProperty.Description PolicySetting = $userProfileProperty.PrivacyPolicy PrivacySetting = $userProfileProperty.DefaultPrivacy - MappingConnectionName = $MappingConnectionName.ConnectionName + MappingConnectionName = $mapping.ConnectionName MappingPropertyName = $mapping.PropertyName MappingDirection = $Mapping.Direction Length = $userProfileProperty.CoreProperty.Length @@ -145,12 +147,28 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) + #note for integration test: CA can take a couple of minutes to notice the change. don't try refreshing properties page. go through from a fresh "flow" from Service apps page :) + Write-Verbose -Message "Creating user profile property $Name" $test = $PSBoundParameters $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $test -ScriptBlock { $params = $args[0] - - $ups = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue + #region Validating parameter combinations + if( ($params.ContainsKey("TermSet") -or $params.ContainsKey("TermGroup") -or $params.ContainsKey("TermSet") ) -and + ($params.ContainsKey("TermSet") -and $params.ContainsKey("TermGroup") -and $params.ContainsKey("TermSet") -eq $false ) + ) + { + throw "You have to provide all 3 parameters Termset, TermGroup and TermStore when providing any of the 3." + } + + + #what if combination property type + termstore isn't possible? + if($params.ContainsKey("TermSet") -and (@("String","StringMultivalue").Contains($params.Type) -eq $false) ){ + throw "Only String and String Multivalue can use Termsets" + } + #endregion + #region setting up objects + $ups = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue If ($null -eq $ups) { @@ -160,7 +178,12 @@ function Set-TargetResource $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url $context = Get-SPServiceContext $caURL + $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) + if($null -eq $userProfileConfigManager) + { + throw "account running process needs permissions" + } $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() $userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager @@ -168,22 +191,54 @@ function Set-TargetResource $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) - $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) + $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype("UserProfile") + $userProfileSubTypeProperties = $userProfileSubType.Properties - $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) - + $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] if($null -eq $syncConnection ) { throw "connection not found" } + #endregion + + #region retrieving term set + $termSet =$null + if ($params.ContainsKey("TermSet")) + { + $currentTermSet=$userProfileProperty.CoreProperty.TermSet; + if($currentTermSet.Name -ne $params.TermSet -or + $currentTermSet.Group.Name -ne $params.TermGroup -or + $currentTermSet.TermStore.Name -ne $params.TermStore){ + + $session = new-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($caURL); + $termStore = $session.TermStores[$params.TermStore]; + if($termStore -eq $null) + { + throw "Term Store $($params.termStore) not found" + } + $group = $termStore.Groups[$params.TermGroup]; + if($group -eq $null) + { + throw "Term Group $($params.termGroup) not found" + } + $termSet = $group.TermSets[$params.TermSet]; + if($termSet -eq $null) + { + throw "Term Set $($params.termSet) not found" + } + } + } + #endregion + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ if($userProfileProperty -ne $null) { $CoreProperties.RemovePropertyByName($params.Name) } } elseif($userProfileProperty -eq $null){ + #region creating property $coreProperty = $CoreProperties.Create($false) $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName @@ -196,6 +251,10 @@ function Set-TargetResource $coreProperty.IsMultivalued =$true; } $coreProperty.Type = $params.Type + if($termSet -ne $null){ + $coreProperty.TermSet = $termSet + } + $CoreProperties.Add($coreProperty) $upTypeProperty = $userProfileTypeProperties.Create($coreProperty) $userProfileTypeProperties.Add($upTypeProperty) @@ -203,8 +262,9 @@ function Set-TargetResource $userProfileSubTypeProperties.Add($upSubProperty) Sleep -Milliseconds 100 $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + #endregion } - + #region setting up properties $coreProperty = $userProfileProperty.CoreProperty $userProfileTypeProperty = $userProfileProperty.TypeProperty Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" @@ -218,46 +278,50 @@ function Set-TargetResource Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" - #region MMS properties - if ((![String]::IsNullOrEmpty($termStoreName)) -and (![String]::IsNullOrEmpty($termgroupName)) -and (![String]::IsNullOrEmpty($termSetName))) - { - $session = new-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($caURL); - $termStore = $session.TermStores[$params.TermStore]; - $group = $termStore.Groups[$params.TermGroup]; - $termSet = $group.TermSets[$params.TermSet]; - if($termSet -ne $null) - { - $coreProperty.TermSet = $termSet - } + if($termSet -ne $null){ + $coreProperty.TermSet = $termSet } #endregion - $userProfileProperty.CoreProperty.Commit() $userProfileTypeProperty.Commit() $userProfileProperty.Commit() - #Setting the display order + #region setting display order + if($params.ContainsKey("DisplayOrder")) { $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $profileManager.Properties.SetDisplayOrderByPropertyName($params.Name,$params.DisplayOrder) $profileManager.Properties.CommitDisplayOrder() } - + #endregion #region mapping if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) - if($currentmapping -eq $null) - { - $export = !$import -and ($params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") - if($export){ - $syncConnection.PropertyMapping.AddNewExportMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + if($currentMapping -eq $null -or + ($currentMapping.DataSourcePropertyName -ne $params.MappingPropertyName) -or + ($currentMapping.IsImport -and $params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export") + ){ + if($currentMapping -ne $null ){ + $currentMapping.Delete() #API allows updating, but UI doesn't do that. + } + $export = $params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export" + if ($Connection.Type -eq "ActiveDirectoryImport"){ + if($export){ + throw "not implemented" + }else{ + $Connection.AddPropertyMapping($params.MappingPropertyName,$params.Name) + $Connection.Update() + } }else{ - $syncConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + if ($export){ + $syncConnection.PropertyMapping.AddNewExportMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + }else{ + $syncConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$params.Name,$params.MappingPropertyName) + } } - - } - } + } + } #endregion } diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 66d422341..185a83acc 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -32,6 +32,17 @@ function Get-xSharePointContentService() { return [Microsoft.SharePoint.Administration.SPWebService]::ContentService } +function Get-xSharePointUserProfileSubTypeManager { + [CmdletBinding()] + param + ( + $context + ) + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + return [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) +} + function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" $fullPath = Get-Item $pathToSearch | Sort-Object { $_.Directory } -Descending | Select-Object -First 1 diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 1c3d0b583..d1e762e0a 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -16,14 +16,28 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPUserProfileProperty" { InModuleScope $ModuleName { $testParams = @{ - UserProfileService = "User Profile Service Application" - Forest = "contoso.com" - Name = "Contoso" - ConnectionCredentials = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) - Server = "server.contoso.com" - UseSSL = $false - IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") - ConnectionType = "ActiveDirectory" + Name = "WorkEmail14" + UserProfileServiceAppName = "User Profile Service Application" + DisplayName = "WorkEmail14" + Type = "String" + Description = "" #implementation isn't using it yet + PolicySetting = "Mandatory" + PrivacySetting = "Public" + MappingConnectionName = "contoso" + MappingPropertyName = "department" + MappingDirection = "Import" + Length = 30 + DisplayOrder = 5496 + IsEventLog =$false + IsVisibleOnEditor=$true + IsVisibleOnViewer = $true + IsUserEditable = $true + IsAlias = $false #: used to edit "Alias" of the property value under Search Settings. + IsSearchable = $false # e: used to edit “Indexed” of the property value again under Search Settings. + TermStore = "Managed Metadata service" + TermGroup = "People" + TermSet = "Department" + UserOverridePrivacy = $false } try { [Microsoft.Office.Server.UserProfiles] } @@ -31,13 +45,131 @@ Describe "xSPUserProfileProperty" { Add-Type @" namespace Microsoft.Office.Server.UserProfiles { public enum ConnectionType { ActiveDirectory, BusinessDataCatalog }; + public enum ProfileType { User}; } "@ } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") - Mock Get-xSharePointServiceContext {return @{}} + #required mocks + #(Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url + + + + $coreProperty = @{ + DisplayName = "WorkEmail" + Name = "WorkEmail" + IsMultiValued=$false + Type = "String" + TermSet = $null + Length=25 + IsSearchable =$true + } | Add-Member ScriptMethod Commit { + $Global:xSPUPSPropertyCommitCalled = $true + } -PassThru | Add-Member ScriptMethod Delete { + $Global:xSPUPSPropertyDeleteCalled = $true + } -PassThru + + + + $coreProperties = @() | Add-Member ScriptMethod Create { + $Global:xSPUPCoreCreateCalled = $true + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPCoreAddCalled = $true + } -PassThru + + + $typeProperty = @{ + IsVisibleOnViewer=$true + IsVisibleOnEditor=$true + IsEventLog=$true + }| Add-Member ScriptMethod Commit { + $Global:xSPUPPropertyCommitCalled = $true + } -PassThru + + $typeProperties = @() | Add-Member ScriptMethod Create { + $Global:xSPUPTypeCreateCalled = $true + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPTypeAddCalled = $true + } -PassThru + $subTypeProperty = @{ + Name= "WorkEmail2" + DisplayName="WorkEmail2" + Description = "" + PrivacyPolicy = "Required" + DefaultPrivacy = "Everyone" + DisplayOrder =5401 + IsUserEditable= $true + IsAlias = $true + CoreProperty = $coreProperty + TypeProperty = $typeProperty + AllowPolicyOverride=$true; + }| Add-Member ScriptMethod Commit { + $Global:xSPUPPropertyCommitCalled = $true + } -PassThru + + $userProfileSubTypePropertiesNoProperty = @() | Add-Member ScriptMethod Create { + $Global:xSPUPSubTypeCreateCalled = $true + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPSubTypeAddCalled = $true + } -PassThru | Add-Member ScriptMethod GetPropertyByName { + $Global:xSPUPGetPropertyByNameCalled = $true + return $null + } -PassThru + + $userProfileSubTypePropertiesValidProperty = @() | Add-Member ScriptMethod Create { + $Global:xSPUPSubTypeCreateCalled = $true + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPSubTypeAddCalled = $true + } -PassThru | Add-Member ScriptMethod GetPropertyByName { + $Global:xSPUPGetPropertyByNameCalled = $true + return $subTypeProperty + } -PassThru + + mock Get-xSharePointUserProfileSubTypeManager { + return @()| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesNoProperty + } + } -PassThru + } + + + Mock Get-SPWebApplication { + return @(IsAdministrationWebApplication=$true + Url ="caURL") + } + $TermSets =@{Department = @(Name="Department" + )} + + $TermGroups = @{People = @(Name="People" + TermSets = @TermSets + )} + $TermStoresList = @{"Managed Metadata service" = @(Name="Managed Metadata service" + Groups = @TermGroups + )} + + + Mock New-Object -MockWith { + return (@{ + TermStores = $TermStoresList + }) + } -ParameterFilter { $TypeName -eq "Microsoft.SharePoint.Taxonomy.TaxonomySession" } + + Mock New-Object -MockWith { + return (@{ + Properties = @() + } | Add-Member ScriptMethod SetDisplayOrderByPropertyName { + $Global:UpsSetDisplayOrderByPropertyNameCalled=$true; + return $false; + } -PassThru | Add-Member ScriptMethod CommitDisplayOrder { + $Global:UpsSetDisplayOrderByPropertyNameCalled=$true; + return $false; + } -PassThru ) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileManager" } Mock Invoke-xSharePointCommand { return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope } @@ -46,6 +178,27 @@ Describe "xSPUserProfileProperty" { Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" + $propertyMapping = @{}| Add-Member ScriptMethod Item { + param( [string]$property ) + $Global:xSPUPSMappingItemCalled = $true + if($property="WorkEmail2"){ + return @{ + DataSourcePropertyName="WorkEmail2" + IsImport=$true + IsExport=$false + }| Add-Member ScriptMethod Delete { + $Global:UpsMappingDeleteCalled=$true; + return $true; + } -PassThru | Add-Member ScriptMethod AddNewExportMapping { + $Global:UpsMappingAddNewExportCalled=$true; + return $true; + } -PassThru | Add-Member ScriptMethod AddNewMapping { + $Global:UpsMappingAddNewMappingCalled=$true; + return $true; + } -PassThru + } + + } -PassThru $connection = @{ DisplayName = "Contoso" Server = "contoso.com" @@ -53,27 +206,14 @@ Describe "xSPUserProfileProperty" { AccountDomain = "Contoso" AccountUsername = "TestAccount" Type= "ActiveDirectory" + PropertyMapping = $propertyMapping } - $connection = $connection | Add-Member ScriptMethod RefreshSchema { - $Global:xSPUPSSyncConnectionRefreshSchemaCalled = $true - } -PassThru | Add-Member ScriptMethod Update { + $connection = $connection | Add-Member ScriptMethod Update { $Global:xSPUPSSyncConnectionUpdateCalled = $true - } -PassThru | Add-Member ScriptMethod SetCredentials { - param($userAccount,$securePassword ) - $Global:xSPUPSSyncConnectionSetCredentialsCalled = $true - } -PassThru | Add-Member ScriptMethod Delete { - $Global:xSPUPSSyncConnectionDeleteCalled = $true + } -PassThru | Add-Member ScriptMethod AddPropertyMapping { + $Global:xSPUPSSyncConnectionAddPropertyMappingCalled = $true } -PassThru - $namingContext =@{ - ContainersIncluded = New-Object System.Collections.ArrayList - ContainersExcluded = New-Object System.Collections.ArrayList - DisplayName="Contoso" - PreferredDomainControllers=$null; - } - $namingContext.ContainersIncluded.Add("OU=com, OU=Contoso, OU=Included") - $namingContext.ContainersExcluded.Add("OU=com, OU=Contoso, OU=Excluded") - $connection.NamingContexts.Add($namingContext); $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` From 22b254e12cf7dfdee1724163a39a74c635c3e416 Mon Sep 17 00:00:00 2001 From: Camilo Date: Wed, 6 Jan 2016 10:02:38 +0000 Subject: [PATCH 23/91] more unit tests --- .../MSFT_xSPUserProfileProperty.psm1 | 22 +++-- .../MSFT_xSPUserProfileProperty.schema.mof | 4 +- ...harePoint.xSPUserProfileProperty.Tests.ps1 | 81 ++++++++++++------- 3 files changed, 71 insertions(+), 36 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 1b2e95410..455d75155 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.string ] $Name , [parameter(Mandatory = $false)] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , @@ -37,7 +37,7 @@ function Get-TargetResource $params = $args[0] - $upsa = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue + $upsa = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue if ($null -eq $upsa) { return $null } @@ -88,7 +88,7 @@ function Get-TargetResource return @{ Name = $userProfileProperty.Name - UserProfileServiceAppName = $params.UserProfileServiceAppName + UserProfileServiceAppName = $params.UserProfileService DisplayName = $userProfileProperty.DisplayName Type = $userProfileProperty.CoreProperty.Type.GetTypeCode() Description = $userProfileProperty.Description @@ -122,7 +122,7 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.string ] $Name , [parameter(Mandatory = $false)] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $true)] [System.string ] $DisplayName , [parameter(Mandatory = $true)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , @@ -168,7 +168,7 @@ function Set-TargetResource } #endregion #region setting up objects - $ups = Get-SPServiceApplication -Name $params.UserProfileServiceAppName -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue If ($null -eq $ups) { @@ -203,6 +203,7 @@ function Set-TargetResource #region retrieving term set $termSet =$null + #Get-TermSet if ($params.ContainsKey("TermSet")) { $currentTermSet=$userProfileProperty.CoreProperty.TermSet; @@ -239,6 +240,9 @@ function Set-TargetResource } } elseif($userProfileProperty -eq $null){ #region creating property + #Add-NewProperty $params + + # $userProfileProperty Add-NewProperty $params $coreProperty = $CoreProperties.Create($false) $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName @@ -262,9 +266,13 @@ function Set-TargetResource $userProfileSubTypeProperties.Add($upSubProperty) Sleep -Milliseconds 100 $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + + #return $userProfileProperty #endregion } #region setting up properties + #update-property $userProfileProperty $params $termSet + $coreProperty = $userProfileProperty.CoreProperty $userProfileTypeProperty = $userProfileProperty.TypeProperty Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "DisplayName" -ParamsValue $params -ParamKey "DisplayName" @@ -287,6 +295,7 @@ function Set-TargetResource $userProfileProperty.Commit() #region setting display order + # Set-DisplayOrder if($params.ContainsKey("DisplayOrder")) { $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) @@ -295,6 +304,7 @@ function Set-TargetResource } #endregion #region mapping + #Set-Mapping if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) @@ -337,7 +347,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.string ] $Name , [parameter(Mandatory = $false)] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileServiceAppName , + [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 70f1136b0..5e541019f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -19,7 +19,7 @@ This DSC resource doesn't currently supports metadata properties xSPUserProfileProperty WorkEmailProperty { Name = "WorkEmail2" - UserProfileServiceAppName = "User Profile Service Application" + UserProfileService = "User Profile Service Application" DisplayName = "Work Email" Type = "Email" Description = "" #implementation isn't using it yet @@ -50,7 +50,7 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource { [Key] string Name [ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; - [required] string UserProfileServiceAppName + [required] string UserProfileService [required] string DisplayName [Required, [ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] ] string Type [write] string Description diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index d1e762e0a..1b82778d9 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -15,12 +15,12 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPUserProfileProperty" { InModuleScope $ModuleName { - $testParams = @{ - Name = "WorkEmail14" - UserProfileServiceAppName = "User Profile Service Application" - DisplayName = "WorkEmail14" + $testParamsNewProperty = @{ + Name = "WorkEmailNew" + UserProfileService = "User Profile Service Application" + DisplayName = "WorkEmailNew" Type = "String" - Description = "" #implementation isn't using it yet + Description = "" PolicySetting = "Mandatory" PrivacySetting = "Public" MappingConnectionName = "contoso" @@ -32,13 +32,38 @@ Describe "xSPUserProfileProperty" { IsVisibleOnEditor=$true IsVisibleOnViewer = $true IsUserEditable = $true - IsAlias = $false #: used to edit "Alias" of the property value under Search Settings. - IsSearchable = $false # e: used to edit “Indexed” of the property value again under Search Settings. + IsAlias = $false + IsSearchable = $false TermStore = "Managed Metadata service" TermGroup = "People" TermSet = "Department" UserOverridePrivacy = $false } + + $testParamsUpdateProperty = @{ + Name = "WorkEmailUpdate" + UserProfileService = "User Profile Service Application" + DisplayName = "WorkEmailUpdate" + Type = "String" + Description = "" + PolicySetting = "Optional" + PrivacySetting = "Private" + MappingConnectionName = "contoso" + MappingPropertyName = "mail" + MappingDirection = "Import" + Length = 30 + DisplayOrder = 5496 + IsEventLog =$true + IsVisibleOnEditor=$false + IsVisibleOnViewer = $false + IsUserEditable = $false + IsAlias = $true + IsSearchable = $true + TermStore = "Managed Metadata service" + TermGroup = "People" + TermSet = "Location" + UserOverridePrivacy = $false + } try { [Microsoft.Office.Server.UserProfiles] } catch { @@ -52,14 +77,9 @@ Describe "xSPUserProfileProperty" { Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") - #required mocks - #(Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url - - - $coreProperty = @{ - DisplayName = "WorkEmail" - Name = "WorkEmail" + DisplayName = "WorkEmailUpdate" + Name = "WorkEmailUpdate" IsMultiValued=$false Type = "String" TermSet = $null @@ -72,7 +92,6 @@ Describe "xSPUserProfileProperty" { } -PassThru - $coreProperties = @() | Add-Member ScriptMethod Create { $Global:xSPUPCoreCreateCalled = $true } -PassThru | Add-Member ScriptMethod Add { @@ -94,8 +113,8 @@ Describe "xSPUserProfileProperty" { $Global:xSPUPTypeAddCalled = $true } -PassThru $subTypeProperty = @{ - Name= "WorkEmail2" - DisplayName="WorkEmail2" + Name= "WorkEmailUpdate" + DisplayName="WorkEmailUpdate" Description = "" PrivacyPolicy = "Required" DefaultPrivacy = "Everyone" @@ -181,9 +200,9 @@ Describe "xSPUserProfileProperty" { $propertyMapping = @{}| Add-Member ScriptMethod Item { param( [string]$property ) $Global:xSPUPSMappingItemCalled = $true - if($property="WorkEmail2"){ + if($property="WorkEmailUpdate"){ return @{ - DataSourcePropertyName="WorkEmail2" + DataSourcePropertyName="WorkEmailUpdate" IsImport=$true IsExport=$false }| Add-Member ScriptMethod Delete { @@ -251,20 +270,17 @@ Describe "xSPUserProfileProperty" { } $userProfileServiceValidConnection.ConnectionManager.Add($connection); - Context "When connection doesn't exist" { - <# $userProfileServiceNoConnections = @{ + Context "When property doesn't exist" { +<# $userProfileServiceNoConnections = @{ Name = "User Profile Service Application" ApplicationPool = "SharePoint Service Applications" FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) ServiceApplicationProxyGroup = "Proxy Group" ConnnectionManager = @() - } + }#> - Mock Get-SPServiceApplication { return $userProfileServiceNoConnections } + Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } - Mock New-Object -MockWith {return @{} - - } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext"} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } @@ -279,10 +295,19 @@ Describe "xSPUserProfileProperty" { Set-TargetResource @testParams $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $true } - #> + } - Context "When property doesn't exist" { + Context "When property doesn't exist, connection doesn't exist" { + } + + Context "When property doesn't exist, termset doesn't exist" { + } + + Context "When property doesn't exist, termgroup doesn't exist" { + } + + Context "When property doesn't exist, termgstore doesn't exist" { } Context "When property exists" { From 6542f5b221f8f4d76dafda25c97aa83dd294706a Mon Sep 17 00:00:00 2001 From: Camilo Date: Wed, 6 Jan 2016 12:40:06 +0000 Subject: [PATCH 24/91] more unit tests... --- .../MSFT_xSPUserProfileProperty.psm1 | 2 +- Modules/xSharePoint/xSharePoint.psd1 | 3 +- ...harePoint.xSPUserProfileProperty.Tests.ps1 | 129 +++++++++++------- 3 files changed, 84 insertions(+), 50 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 455d75155..a08840f69 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -42,7 +42,7 @@ function Get-TargetResource return $null } $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url - $context = Get-SPServiceContext $caURL + $context = Get-SPServiceContext -Site $caURL $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) $userProfileSubTypeManager = Get-xSharePointUserProfileSubTypeManager $context diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 669d2a1f9..c891e5e64 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -79,7 +79,8 @@ CmdletsToExport = @("Invoke-xSharePointCommand", "Test-xSharePointRunAsCredential", "Test-xSharePointUserIsLocalAdmin", "Test-xSharePointSpecificParameters", - "Set-xSharePointObjectPropertyIfValueExists") + "Set-xSharePointObjectPropertyIfValueExists", + "Get-xSharePointUserProfileSubTypeManager") # Variables to export from this module VariablesToExport = '*' diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 1b82778d9..72a05b509 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -1,7 +1,13 @@ + [CmdletBinding()] param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) +#(Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url +#C:\Users\camilo\Source\Repos\xSharePoint\Modules\xSharePoint\DSCResources\MSFT_xSPUserProfileProperty\ +#C:\Users\camilo\Source\Repos\xSharePoint\Tests\xSharePoint +#.\xSharePoint.xSPUserProfileProperty.Tests.ps1 +Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 $ErrorActionPreference = 'stop' Set-StrictMode -Version latest @@ -39,7 +45,8 @@ Describe "xSPUserProfileProperty" { TermSet = "Department" UserOverridePrivacy = $false } - + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + $farmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) $testParamsUpdateProperty = @{ Name = "WorkEmailUpdate" UserProfileService = "User Profile Service Application" @@ -90,12 +97,13 @@ Describe "xSPUserProfileProperty" { } -PassThru | Add-Member ScriptMethod Delete { $Global:xSPUPSPropertyDeleteCalled = $true } -PassThru - - - $coreProperties = @() | Add-Member ScriptMethod Create { + $coreProperty.Type = $coreProperty.Type +<#| Add-Member ScriptMethod GetTypeCode { + $Global:xSPUPCoreGetTypeCodeCalled = $true + } -PassThru + #> + $coreProperties = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { $Global:xSPUPCoreCreateCalled = $true - } -PassThru | Add-Member ScriptMethod Add { - $Global:xSPUPCoreAddCalled = $true } -PassThru @@ -107,11 +115,9 @@ Describe "xSPUserProfileProperty" { $Global:xSPUPPropertyCommitCalled = $true } -PassThru - $typeProperties = @() | Add-Member ScriptMethod Create { + $typeProperties = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { $Global:xSPUPTypeCreateCalled = $true - } -PassThru | Add-Member ScriptMethod Add { - $Global:xSPUPTypeAddCalled = $true - } -PassThru + } -PassThru $subTypeProperty = @{ Name= "WorkEmailUpdate" DisplayName="WorkEmailUpdate" @@ -128,48 +134,50 @@ Describe "xSPUserProfileProperty" { $Global:xSPUPPropertyCommitCalled = $true } -PassThru - $userProfileSubTypePropertiesNoProperty = @() | Add-Member ScriptMethod Create { + $userProfileSubTypePropertiesNoProperty = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { $Global:xSPUPSubTypeCreateCalled = $true - } -PassThru | Add-Member ScriptMethod Add { - $Global:xSPUPSubTypeAddCalled = $true - } -PassThru | Add-Member ScriptMethod GetPropertyByName { + } -PassThru | Add-Member ScriptMethod GetPropertyByName { $Global:xSPUPGetPropertyByNameCalled = $true return $null } -PassThru - $userProfileSubTypePropertiesValidProperty = @() | Add-Member ScriptMethod Create { + $userProfileSubTypePropertiesValidProperty = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { $Global:xSPUPSubTypeCreateCalled = $true - } -PassThru | Add-Member ScriptMethod Add { - $Global:xSPUPSubTypeAddCalled = $true } -PassThru | Add-Member ScriptMethod GetPropertyByName { $Global:xSPUPGetPropertyByNameCalled = $true return $subTypeProperty } -PassThru - mock Get-xSharePointUserProfileSubTypeManager { - return @()| Add-Member ScriptMethod GetProfileSubtype { + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { $Global:xSPUPGetProfileSubtypeCalled = $true return @{ Properties = $userProfileSubTypePropertiesNoProperty } } -PassThru - } - - Mock Get-SPWebApplication { - return @(IsAdministrationWebApplication=$true - Url ="caURL") + return $result } - $TermSets =@{Department = @(Name="Department" - )} - - $TermGroups = @{People = @(Name="People" - TermSets = @TermSets - )} + - $TermStoresList = @{"Managed Metadata service" = @(Name="Managed Metadata service" - Groups = @TermGroups - )} + Mock Get-SPWebApplication -MockWith { + return @( + @{ + IsAdministrationWebApplication=$true + Url ="caURL" + }) + } + #IncludeCentralAdministration + $TermSets =@{Department = @{Name="Department" + }} + + $TermGroups = @{People = @{Name="People" + TermSets = $TermSets + }} + + $TermStoresList = @{"Managed Metadata service" = @{Name="Managed Metadata service" + Groups = $TermGroups + }} Mock New-Object -MockWith { @@ -180,7 +188,7 @@ Describe "xSPUserProfileProperty" { Mock New-Object -MockWith { return (@{ - Properties = @() + Properties = New-Object System.Collections.ArrayList } | Add-Member ScriptMethod SetDisplayOrderByPropertyName { $Global:UpsSetDisplayOrderByPropertyNameCalled=$true; return $false; @@ -193,7 +201,15 @@ Describe "xSPUserProfileProperty" { return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope } - Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue +<# Mock Get-xSharePointUserProfileSubTypeManager{ + $properties = @() + return @()| Add-Member ScriptMethod GetProfileSubtype { + $Global:UpsSubTypeMgrGetProfileSubtypeCalled=$true; + return $false; + } -PassThru + + } + #> Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" @@ -217,11 +233,10 @@ Describe "xSPUserProfileProperty" { } -PassThru } - } -PassThru + } -PassThru -Force $connection = @{ DisplayName = "Contoso" Server = "contoso.com" - NamingContexts= New-Object System.Collections.ArrayList AccountDomain = "Contoso" AccountUsername = "TestAccount" Type= "ActiveDirectory" @@ -234,7 +249,7 @@ Describe "xSPUserProfileProperty" { } -PassThru - $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` + $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` $name, ` $forest, ` @@ -249,7 +264,15 @@ Describe "xSPUserProfileProperty" { } -PassThru Mock New-Object -MockWith { + $ProfilePropertyManager = @{} | Add-Member ScriptMethod GetCoreProperties { + $Global:UpsConfigManagerGetCorePropertiesCalled=$true; + return $false; + } -PassThru | Add-Member ScriptMethod GetProfileTypeProperties { + $Global:UpsConfigManagerGetProfileTypePropertiesCalled=$true; + return $false; + } -PassThru return (@{ + ProfilePropertyManager = $ProfilePropertyManager ConnectionManager = $ConnnectionManager } | Add-Member ScriptMethod IsSynchronizationRunning { $Global:UpsSyncIsSynchronizationRunning=$true; @@ -257,14 +280,11 @@ Describe "xSPUserProfileProperty" { } -PassThru ) } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } - Mock New-Object -MockWith { - return (New-Object System.Collections.Generic.List[System.Object]) - } -ParameterFilter { $TypeName -eq "System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]]" } $userProfileServiceValidConnection = @{ Name = "User Profile Service Application" TypeName = "User Profile Service Application" ApplicationPool = "SharePoint Service Applications" - FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) + FarmAccount = $farmAccount ServiceApplicationProxyGroup = "Proxy Group" ConnectionManager= New-Object System.Collections.ArrayList } @@ -282,18 +302,31 @@ Describe "xSPUserProfileProperty" { Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } It "returns null from the Get method" { - Get-TargetResource @testParams | Should BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true } It "returns false when the Test method is called" { - Test-TargetResource @testParams | Should Be $false + Test-TargetResource $testParamsNewProperty | Should Be $false } It "creates a new service application in the set method" { - $Global:xSPUPSAddActiveDirectoryConnectionCalled =$false - Set-TargetResource @testParams - $Global:xSPUPSAddActiveDirectoryConnectionCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + Set-TargetResource $testParamsNewProperty + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } } From a2c99dd0ae39ace0f953f848be7d7fdcbd40a03d Mon Sep 17 00:00:00 2001 From: Camilo Date: Thu, 7 Jan 2016 14:18:59 +0000 Subject: [PATCH 25/91] unit tested --- .../MSFT_xSPUserProfileProperty.psm1 | 67 ++- .../MSFT_xSPUserProfileProperty.schema.mof | 55 +- ...MSFT_xSPWebApplicationAppDomain.schema.mof | 2 +- ...harePoint.xSPUserProfileProperty.Tests.ps1 | 568 +++++++++++++++--- 4 files changed, 545 insertions(+), 147 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index a08840f69..6f6545d7b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -5,13 +5,13 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)] [System.string ] $Name , - [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , @@ -72,7 +72,7 @@ function Get-TargetResource } $syncConnection = $userProfileConfigManager.ConnectionManager | ? {$_.PropertyMapping.Item($params.Name) -ne $null} if($syncConnection -ne $null) { - $currentMapping = $synchConnection.PropertyMapping.Item($params.Name) + $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) if($currentMapping -ne $null) { $mapping.Direction = "Import" @@ -121,13 +121,13 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)] [System.string ] $Name , - [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , - [parameter(Mandatory = $true)] [System.string ] $DisplayName , - [parameter(Mandatory = $true)] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $DisplayName , + [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , @@ -161,10 +161,9 @@ function Set-TargetResource throw "You have to provide all 3 parameters Termset, TermGroup and TermStore when providing any of the 3." } - #what if combination property type + termstore isn't possible? - if($params.ContainsKey("TermSet") -and (@("String","StringMultivalue").Contains($params.Type) -eq $false) ){ - throw "Only String and String Multivalue can use Termsets" + if($params.ContainsKey("TermSet") -and (@("string","stringmultivalue").Contains($params.Type.ToLower()) -eq $false) ){ + throw "Only String and String Maultivalue can use Termsets" } #endregion #region setting up objects @@ -174,14 +173,13 @@ function Set-TargetResource { return $null } - #what if permission isn't granted ? $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url $context = Get-SPServiceContext $caURL $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) if($null -eq $userProfileConfigManager) - { + { #if config manager returns when ups is available then isuee is permissions throw "account running process needs permissions" } $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() @@ -190,17 +188,24 @@ function Set-TargetResource $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) - $userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) + $userProfileSubTypeManager = Get-xSharePointUserProfileSubTypeManager $context $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype("UserProfile") $userProfileSubTypeProperties = $userProfileSubType.Properties - $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] + $syncConnection = $userProfileConfigManager.ConnectionManager | Where-Object { $_.DisplayName -eq $params.MappingConnectionName} if($null -eq $syncConnection ) { throw "connection not found" } #endregion + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + + if($userProfileProperty -ne $null -and $userProfileProperty.CoreProperty.Type.GetTypeCode() -ne $params.Type ) + { + throw "Can't change property type. Current Type is $($userProfileProperty.CoreProperty.Type.GetTypeCode())" + } + #region retrieving term set $termSet =$null #Get-TermSet @@ -232,22 +237,19 @@ function Set-TargetResource #endregion - $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + #Ensure-Property $params if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ if($userProfileProperty -ne $null) { - $CoreProperties.RemovePropertyByName($params.Name) + $coreProperties.RemovePropertyByName($params.Name) + return; } } elseif($userProfileProperty -eq $null){ #region creating property - #Add-NewProperty $params - - # $userProfileProperty Add-NewProperty $params - $coreProperty = $CoreProperties.Create($false) + $coreProperty = $coreProperties.Create($false) $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" if($params.Type.ToLower() -eq "stringmultivalue") @@ -293,8 +295,11 @@ function Set-TargetResource $userProfileProperty.CoreProperty.Commit() $userProfileTypeProperty.Commit() $userProfileProperty.Commit() - #region setting display order + + + #/Ensure-Property + #region display order # Set-DisplayOrder if($params.ContainsKey("DisplayOrder")) { @@ -306,7 +311,8 @@ function Set-TargetResource #region mapping #Set-Mapping if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ - $syncConnection = $userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] + $syncConnection = $userProfileConfigManager.ConnectionManager| Where-Object { $_.DisplayName -eq $params.MappingConnectionName} + #$userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) if($currentMapping -eq $null -or ($currentMapping.DataSourcePropertyName -ne $params.MappingPropertyName) -or @@ -338,7 +344,6 @@ function Set-TargetResource return $result } - function Test-TargetResource { [CmdletBinding()] @@ -346,13 +351,13 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)] [System.string ] $Name , - [parameter(Mandatory = $false)] [System.string ] $Ensure , + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , @@ -374,9 +379,9 @@ function Test-TargetResource ) $CurrentValues = Get-TargetResource @PSBoundParameters - Write-Verbose -Message "Testing for user profile service application $Name" + Write-Verbose -Message "Testing for user profile property $Name" if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name","DisplayName","Type", "Description", "PolicySetting", "PrivacySetting","AllowUserEdit", "MappingConnectionName","MappingPropertyName", "MappingDirection", "Length", "DisplayOrder", "IsEventLog", "IsVisibleOnEditor", "IsVisibleOnViewer","IsUserEditable", "IsAlias", "IsSearchabe", "UserOverridePrivacy", "TermGroup", "TermStore", "TermSet") } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 5e541019f..53af9bfed 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -12,9 +12,6 @@ Length is only relevant if Field type is "String". This DSC resource doesn't currently supports metadata properties --- needs to add support to - - linking to MMS terms - - indexed properties **Example** xSPUserProfileProperty WorkEmailProperty { @@ -29,13 +26,13 @@ xSPUserProfileProperty WorkEmailProperty MappingPropertyName = "mail" MappingDirection = "Import" Length = 10 - DisplayOrder =25 #relative to the section + DisplayOrder =25 IsEventLog =$false IsVisibleOnEditor=$true IsVisibleOnViewer = $true IsUserEditable = $true - IsAlias = $false #: used to edit "Alias" of the property value under Search Settings. - IsSearchable = $false # e: used to edit “Indexed” of the property value again under Search Settings. + IsAlias = $false + IsSearchable = $false TermStore = "" TermGroup = "" TermSet = "" @@ -48,29 +45,29 @@ xSPUserProfileProperty WorkEmailProperty [ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileProperty")] class MSFT_xSPUserProfileProperty : OMI_BaseResource { - [Key] string Name - [ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; - [required] string UserProfileService - [required] string DisplayName - [Required, [ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] ] string Type - [write] string Description - [ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; - [ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; - [write] string MappingConnectionName - [write] string MappingPropertyName - [write] string MappingDirection - [write] uint32 Length - [write] uint32 DisplayOrder - [write] boolean IsEventLog - [write] boolean IsVisibleOnEditor - [write] boolean IsVisibleOnViewer - [write] boolean IsUserEditable - [write] boolean IsAlias - [write] boolean IsSearchable - [write] boolean UserOverridePrivacy - [write] string TermStore - [write] string TermSetGroup - [write] string TermSet + [Key] string Name ; + [write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [required] string UserProfileService; + [required] string DisplayName ; + [Required, ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] string Type; + [write] string Description ; + [write, ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; + [write, ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; + [write] string MappingConnectionName ; + [write] string MappingPropertyName ; + [write] string MappingDirection ; + [write] uint32 Length ; + [write] uint32 DisplayOrder; + [write] boolean IsEventLog ; + [write] boolean IsVisibleOnEditor; + [write] boolean IsVisibleOnViewer; + [write] boolean IsUserEditable ; + [write] boolean IsAlias; + [write] boolean IsSearchable; + [write] boolean UserOverridePrivacy ; + [write] string TermStore ; + [write] string TermSetGroup; + [write] string TermSet; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof index 5f2c0ac4a..979b41d1e 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof @@ -26,6 +26,6 @@ class MSFT_xSPWebApplicationAppDomain : OMI_BaseResource [Key, ValueMap{"Internet","Intranet","Extranet", "Custom"}, Values{"Internet","Intranet","Extranet", "Custom"}] string Zone; [Required] string AppDomain; [Write] string Port; - [Write] boolean SSL + [Write] boolean SSL; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 72a05b509..0acfcfd6c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -53,17 +53,18 @@ Describe "xSPUserProfileProperty" { DisplayName = "WorkEmailUpdate" Type = "String" Description = "" - PolicySetting = "Optional" + PolicySetting = "Optin" PrivacySetting = "Private" + Ensure ="Present" MappingConnectionName = "contoso" MappingPropertyName = "mail" MappingDirection = "Import" - Length = 30 - DisplayOrder = 5496 + Length = 25 + DisplayOrder = 5401 IsEventLog =$true - IsVisibleOnEditor=$false - IsVisibleOnViewer = $false - IsUserEditable = $false + IsVisibleOnEditor=$True + IsVisibleOnViewer = $true + IsUserEditable = $true IsAlias = $true IsSearchable = $true TermStore = "Managed Metadata service" @@ -84,12 +85,14 @@ Describe "xSPUserProfileProperty" { Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") - $coreProperty = @{ + $corePropertyUpdate = @{ DisplayName = "WorkEmailUpdate" Name = "WorkEmailUpdate" IsMultiValued=$false Type = "String" - TermSet = $null + TermSet = @{Name= $testParamsUpdateProperty.TermSet + Group= @{Name =$testParamsUpdateProperty.TermGroup} + TermStore = @{Name =$testParamsUpdateProperty.TermStore} } Length=25 IsSearchable =$true } | Add-Member ScriptMethod Commit { @@ -97,17 +100,33 @@ Describe "xSPUserProfileProperty" { } -PassThru | Add-Member ScriptMethod Delete { $Global:xSPUPSPropertyDeleteCalled = $true } -PassThru - $coreProperty.Type = $coreProperty.Type + $corePropertyUpdate.Type = $corePropertyUpdate.Type | Add-Member ScriptMethod GetTypeCode { + $Global:xSPUPSPropertyGetTypeCodeCalled = $true + return $corePropertyUpdate.Type + } -PassThru -Force <#| Add-Member ScriptMethod GetTypeCode { $Global:xSPUPCoreGetTypeCodeCalled = $true } -PassThru #> - $coreProperties = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { - $Global:xSPUPCoreCreateCalled = $true - } -PassThru - + $coreProperties = @{WorkEmailUpdate = $corePropertyUpdate} - $typeProperty = @{ + $coreProperties = $coreProperties | Add-Member ScriptMethod Create { + $Global:xSPUPCoreCreateCalled = $true + return @{ + Name=""; + DisplayName="" + Type="" + TermSet=$null + Length=10 + } + } -PassThru | Add-Member ScriptMethod RemovePropertyByName { + $Global:xSPUPCoreRemovePropertyByNameCalled = $true + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPCoreAddCalled = $true + } -PassThru -Force + + # $coreProperties.Add($coreProperty) + $typePropertyUpdate = @{ IsVisibleOnViewer=$true IsVisibleOnEditor=$true IsEventLog=$true @@ -115,39 +134,91 @@ Describe "xSPUserProfileProperty" { $Global:xSPUPPropertyCommitCalled = $true } -PassThru - $typeProperties = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { + $typeProperties = @{"WorkEmailUpdate" = $typePropertyUpdate} | Add-Member ScriptMethod Create { $Global:xSPUPTypeCreateCalled = $true - } -PassThru - $subTypeProperty = @{ + } -PassThru| Add-Member ScriptMethod Add { + $Global:xSPUPTypeAddCalled = $true + } -PassThru -Force + + #$typeProperties.Add($typeProperty) + $subTypePropertyUpdate = @{ Name= "WorkEmailUpdate" DisplayName="WorkEmailUpdate" Description = "" - PrivacyPolicy = "Required" - DefaultPrivacy = "Everyone" + PrivacyPolicy = "Optin" + DefaultPrivacy = "Private" DisplayOrder =5401 IsUserEditable= $true IsAlias = $true + CoreProperty = $corePropertyUpdate + TypeProperty = $typePropertyUpdate + AllowPolicyOverride=$false; + }| Add-Member ScriptMethod Commit { + $Global:xSPUPPropertyCommitCalled = $true + } -PassThru + + + $coreProperty = @{ + DisplayName = $testParamsNewProperty.DisplayName + Name = $testParamsNewProperty.Name + IsMultiValued=$testParamsNewProperty.Type -eq "stringmultivalue" + Type = $testParamsNewProperty.Type + TermSet = @{Name= $testParamsNewProperty.TermSet + Group= @{Name =$testParamsNewProperty.TermGroup} + TermStore = @{Name =$testParamsNewProperty.TermStore} } + Length=$testParamsNewProperty.Length + IsSearchable =$testParamsNewProperty.IsSearchable + } | Add-Member ScriptMethod Commit { + $Global:xSPUPSPropertyCommitCalled = $true + } -PassThru | Add-Member ScriptMethod Delete { + $Global:xSPUPSPropertyDeleteCalled = $true + } -PassThru + + $typeProperty = @{ + IsVisibleOnViewer=$testParamsNewProperty.IsVisibleOnViewer + IsVisibleOnEditor=$testParamsNewProperty.IsVisibleOnEditor + IsEventLog=$testParamsNewProperty.IsEventLog + }| Add-Member ScriptMethod Commit { + $Global:xSPUPPropertyCommitCalled = $true + } -PassThru + + $subTypeProperty = @{ + Name= $testParamsNewProperty.Name + DisplayName= $testParamsNewProperty.DisplayName + Description = $testParamsNewProperty.Description + PrivacyPolicy = $testParamsNewProperty.PolicySetting + DefaultPrivacy = $testParamsNewProperty.PrivateSetting + DisplayOrder =$testParamsNewProperty.DisplayOrder + IsUserEditable= $testParamsNewProperty.IsUserEditable + IsAlias = $testParamsNewProperty.IsAlias CoreProperty = $coreProperty TypeProperty = $typeProperty AllowPolicyOverride=$true; }| Add-Member ScriptMethod Commit { $Global:xSPUPPropertyCommitCalled = $true } -PassThru - - $userProfileSubTypePropertiesNoProperty = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { + $userProfileSubTypePropertiesNoProperty = @{} | Add-Member ScriptMethod Create { $Global:xSPUPSubTypeCreateCalled = $true } -PassThru | Add-Member ScriptMethod GetPropertyByName { + $result = $null + if($Global:xSPUPGetPropertyByNameCalled -eq $TRUE){ + $result = $subTypeProperty + } $Global:xSPUPGetPropertyByNameCalled = $true - return $null - } -PassThru + return $result + } -PassThru| Add-Member ScriptMethod Add { + $Global:xSPUPSubTypeAddCalled = $true + } -PassThru -Force - $userProfileSubTypePropertiesValidProperty = New-Object System.Collections.ArrayList | Add-Member ScriptMethod Create { + $userProfileSubTypePropertiesUpdateProperty = @{"WorkEmailUpdate" = $subTypePropertyUpdate } | Add-Member ScriptMethod Create { $Global:xSPUPSubTypeCreateCalled = $true - } -PassThru | Add-Member ScriptMethod GetPropertyByName { + } -PassThru | Add-Member ScriptMethod Add { + $Global:xSPUPSubTypeAddCalled = $true + } -PassThru -Force | Add-Member ScriptMethod GetPropertyByName { $Global:xSPUPGetPropertyByNameCalled = $true - return $subTypeProperty + return $subTypePropertyUpdate } -PassThru - + #$userProfileSubTypePropertiesValidProperty.Add($subTypeProperty); mock Get-xSharePointUserProfileSubTypeManager -MockWith { $result = @{}| Add-Member ScriptMethod GetProfileSubtype { $Global:xSPUPGetProfileSubtypeCalled = $true @@ -169,7 +240,10 @@ Describe "xSPUserProfileProperty" { } #IncludeCentralAdministration $TermSets =@{Department = @{Name="Department" - }} + } + Location = @{Name="Location" + } + } $TermGroups = @{People = @{Name="People" TermSets = $TermSets @@ -188,14 +262,13 @@ Describe "xSPUserProfileProperty" { Mock New-Object -MockWith { return (@{ - Properties = New-Object System.Collections.ArrayList - } | Add-Member ScriptMethod SetDisplayOrderByPropertyName { + Properties = @{} | Add-Member ScriptMethod SetDisplayOrderByPropertyName { $Global:UpsSetDisplayOrderByPropertyNameCalled=$true; return $false; } -PassThru | Add-Member ScriptMethod CommitDisplayOrder { $Global:UpsSetDisplayOrderByPropertyNameCalled=$true; return $false; - } -PassThru ) + } -PassThru }) } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileManager" } Mock Invoke-xSharePointCommand { return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope @@ -212,28 +285,28 @@ Describe "xSPUserProfileProperty" { #> Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" + $propertyMappingItem = @{ + DataSourcePropertyName="mail" + IsImport=$true + IsExport=$false + } | Add-Member ScriptMethod Delete { + $Global:UpsMappingDeleteCalled=$true; + return $true; + } -PassThru $propertyMapping = @{}| Add-Member ScriptMethod Item { param( [string]$property ) $Global:xSPUPSMappingItemCalled = $true if($property="WorkEmailUpdate"){ - return @{ - DataSourcePropertyName="WorkEmailUpdate" - IsImport=$true - IsExport=$false - }| Add-Member ScriptMethod Delete { - $Global:UpsMappingDeleteCalled=$true; - return $true; - } -PassThru | Add-Member ScriptMethod AddNewExportMapping { + return $propertyMappingItem} + } -PassThru -force | Add-Member ScriptMethod AddNewExportMapping { $Global:UpsMappingAddNewExportCalled=$true; return $true; } -PassThru | Add-Member ScriptMethod AddNewMapping { $Global:UpsMappingAddNewMappingCalled=$true; return $true; } -PassThru - } - - } -PassThru -Force + #} -PassThru -Force $connection = @{ DisplayName = "Contoso" Server = "contoso.com" @@ -242,6 +315,7 @@ Describe "xSPUserProfileProperty" { Type= "ActiveDirectory" PropertyMapping = $propertyMapping } + $connection = $connection | Add-Member ScriptMethod Update { $Global:xSPUPSSyncConnectionUpdateCalled = $true } -PassThru | Add-Member ScriptMethod AddPropertyMapping { @@ -249,7 +323,7 @@ Describe "xSPUserProfileProperty" { } -PassThru - $ConnnectionManager = New-Object System.Collections.ArrayList | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` + $ConnnectionManager = @($connection) | Add-Member ScriptMethod AddActiveDirectoryConnection{ ` param([Microsoft.Office.Server.UserProfiles.ConnectionType] $connectionType, ` $name, ` $forest, ` @@ -259,17 +333,20 @@ Describe "xSPUserProfileProperty" { $namingContext, ` $p1, $p2 ` ) - + $Global:xSPUPSAddActiveDirectoryConnectionCalled =$true } -PassThru - + + #$ConnnectionManager.add($connection) + Mock New-Object -MockWith { - $ProfilePropertyManager = @{} | Add-Member ScriptMethod GetCoreProperties { + $ProfilePropertyManager = @{"Contoso" = $connection} | Add-Member ScriptMethod GetCoreProperties { $Global:UpsConfigManagerGetCorePropertiesCalled=$true; - return $false; + + return ($coreProperties); } -PassThru | Add-Member ScriptMethod GetProfileTypeProperties { $Global:UpsConfigManagerGetProfileTypePropertiesCalled=$true; - return $false; + return $userProfileSubTypePropertiesUpdateProperty; } -PassThru return (@{ ProfilePropertyManager = $ProfilePropertyManager @@ -286,87 +363,406 @@ Describe "xSPUserProfileProperty" { ApplicationPool = "SharePoint Service Applications" FarmAccount = $farmAccount ServiceApplicationProxyGroup = "Proxy Group" - ConnectionManager= New-Object System.Collections.ArrayList + ConnectionManager= @($connection) #New-Object System.Collections.ArrayList } - $userProfileServiceValidConnection.ConnectionManager.Add($connection); + + #$userProfileServiceValidConnection.ConnectionManager.Add($connection); + + Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } + Context "When property doesn't exist" { -<# $userProfileServiceNoConnections = @{ - Name = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - FarmAccount = New-Object System.Management.Automation.PSCredential ("domain\username", (ConvertTo-SecureString "password" -AsPlainText -Force)) - ServiceApplicationProxyGroup = "Proxy Group" - ConnnectionManager = @() - }#> + + It "returns null from the Get method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "creates a new user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + + $Global:xSPUPSMappingItemCalled = $false + Set-TargetResource @testParamsNewProperty + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + + $Global:xSPUPSMappingItemCalled | Should be $true + + } + + } - Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } + Context "When property doesn't exist, connection doesn't exist" { + Mock New-Object -MockWith { + $ProfilePropertyManager = @{"Contoso" = $connection} | Add-Member ScriptMethod GetCoreProperties { + $Global:UpsConfigManagerGetCorePropertiesCalled=$true; + + return ($coreProperties); + } -PassThru | Add-Member ScriptMethod GetProfileTypeProperties { + $Global:UpsConfigManagerGetProfileTypePropertiesCalled=$true; + return $userProfileSubTypePropertiesUpdateProperty; + } -PassThru + return (@{ + ProfilePropertyManager = $ProfilePropertyManager + ConnectionManager = $() + } | Add-Member ScriptMethod IsSynchronizationRunning { + $Global:UpsSyncIsSynchronizationRunning=$true; + return $false; + } -PassThru ) + } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } It "returns null from the Get method" { - $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetProfileSubtypeCalled = $false $Global:xSPUPGetPropertyByNameCalled = $false $Global:xSPUPSMappingItemCalled = $false Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } $Global:xSPUPGetProfileSubtypeCalled | Should be $true $Global:xSPUPGetPropertyByNameCalled | Should be $true - $Global:xSPUPSMappingItemCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false } It "returns false when the Test method is called" { - Test-TargetResource $testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true } - It "creates a new service application in the set method" { - $Global:xSPUPGetPropertyByNameCalled = $false + It "attempts to create a new property but fails as connection isn't available" { + $Global:xSPUPGetProfileSubtypeCalled = $false $Global:xSPUPGetPropertyByNameCalled = $false $Global:xSPUPSMappingItemCalled = $false - Set-TargetResource $testParamsNewProperty + {Set-TargetResource @testParamsNewProperty} | should throw "connection not found" $Global:xSPUPGetProfileSubtypeCalled | Should be $true - $Global:xSPUPGetPropertyByNameCalled | Should be $true - $Global:xSPUPSMappingItemCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $false + $Global:xSPUPSMappingItemCalled | Should be $false } - } - Context "When property doesn't exist, connection doesn't exist" { - } - Context "When property doesn't exist, termset doesn't exist" { - } - Context "When property doesn't exist, termgroup doesn't exist" { } - Context "When property doesn't exist, termgstore doesn't exist" { + Context "When property doesn't exist, term set doesn't exist" { + $termSet = $testParamsNewProperty.TermSet + $testParamsNewProperty.TermSet = "Invalid" + + It "returns null from the Get method" { + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "creates a new user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + {Set-TargetResource @testParamsNewProperty} | should throw "Term Set $($testParamsNewProperty.TermSet) not found" + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + + } + $testParamsNewProperty.TermSet = $termSet + } - Context "When property exists" { + Context "When property doesn't exist, term group doesn't exist" { + $termGroup = $testParamsNewProperty.TermGroup + $testParamsNewProperty.TermGroup = "InvalidGroup" + + It "returns null from the Get method" { + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "creates a new user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + {Set-TargetResource @testParamsNewProperty} | should throw "Term Group $($testParamsNewProperty.TermGroup) not found" + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + + } + $testParamsNewProperty.TermGroup = $termGroup + } - Context "When property exists and type is different" { + Context "When property doesn't exist, term store doesn't exist" { + $termStore = $testParamsNewProperty.TermStore + $testParamsNewProperty.TermStore = "InvalidStore" + + It "returns null from the Get method" { + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsNewProperty | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsNewProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "creates a new user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + {Set-TargetResource @testParamsNewProperty} | should throw "Term Store $($testParamsNewProperty.TermStore) not found" + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + + } + $testParamsNewProperty.TermStore = $termStore + + } - Context "When property exists and mapping does not " { - + + Context "When property exists and all properties match" { + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesUpdateProperty + } + } -PassThru + + return $result + } + + It "returns valid value from the Get method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsUpdateProperty | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsUpdateProperty | Should Be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "updates an user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Set-TargetResource @testParamsUpdateProperty + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + + } + + } - Context "When property exists and mapping exists, mapping config matches" { - + + Context "When property exists and type is different - throws exception" { + $currentType = $testParamsUpdateProperty.Type + $testParamsUpdateProperty.Type = "StringMultiValue" + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesUpdateProperty + } + } -PassThru + + return $result + } + + It "returns valid value from the Get method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsUpdateProperty | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsUpdateProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "attempts to update an user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + {Set-TargetResource @testParamsUpdateProperty} | should throw "Can't change property type. Current Type" + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + } + $testParamsUpdateProperty.Type = $currentType + } + Context "When property exists and mapping exists, mapping config does not match" { - - } - Context "When creating property and user has no access to MMS" { - + + $propertyMappingItem.DataSourcePropertyName = "property" + + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesUpdateProperty + } + } -PassThru + + return $result + } + + It "returns valid value from the Get method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsUpdateProperty | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsUpdateProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } + + It "updates an user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + Set-TargetResource @testParamsUpdateProperty + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } } + Context "When property exists and mapping does not " { + $propertyMappingItem=$null + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesUpdateProperty + } + } -PassThru + + return $result + } + + It "returns valid value from the Get method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + Get-TargetResource @testParamsUpdateProperty | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } + + It "returns false when the Test method is called" { + $Global:xSPUPGetPropertyByNameCalled = $false + Test-TargetResource @testParamsUpdateProperty | Should Be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true + } - Context "When creating property and there is no MMS with default storage location for column specific" { - + It "updates an user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + + Set-TargetResource @testParamsUpdateProperty + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $true + } } + Context "When property exists and ensure equals Absent" { - + mock Get-xSharePointUserProfileSubTypeManager -MockWith { + $result = @{}| Add-Member ScriptMethod GetProfileSubtype { + $Global:xSPUPGetProfileSubtypeCalled = $true + return @{ + Properties = $userProfileSubTypePropertiesUpdateProperty + } + } -PassThru + + return $result + } + $testParamsUpdateProperty.Ensure = "Absent" + It "deletes an user profile property in the set method" { + $Global:xSPUPGetProfileSubtypeCalled = $false + $Global:xSPUPGetPropertyByNameCalled = $false + $Global:xSPUPSMappingItemCalled = $false + $Global:xSPUPCoreRemovePropertyByNameCalled=$false + + Set-TargetResource @testParamsUpdateProperty + + $Global:xSPUPGetProfileSubtypeCalled | Should be $true + $Global:xSPUPGetPropertyByNameCalled | Should be $true + $Global:xSPUPSMappingItemCalled | Should be $false + $Global:xSPUPCoreRemovePropertyByNameCalled | Should be $true + } } } } From 3daa35a5f0207e7eaae7f059d24e2da8edaca9d0 Mon Sep 17 00:00:00 2001 From: Camilo Date: Thu, 7 Jan 2016 14:29:04 +0000 Subject: [PATCH 26/91] fixing spaces... --- .../MSFT_xSPUserProfileProperty.psm1 | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 6f6545d7b..02a94f583 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -239,35 +239,35 @@ function Set-TargetResource #Ensure-Property $params if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){ - if($userProfileProperty -ne $null) - { - $coreProperties.RemovePropertyByName($params.Name) + if($userProfileProperty -ne $null) + { + $coreProperties.RemovePropertyByName($params.Name) return; - } + } } elseif($userProfileProperty -eq $null){ #region creating property - $coreProperty = $coreProperties.Create($false) - $coreProperty.Name = $params.Name - $coreProperty.DisplayName = $params.DisplayName + $coreProperty = $coreProperties.Create($false) + $coreProperty.Name = $params.Name + $coreProperty.DisplayName = $params.DisplayName - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" - - if($params.Type.ToLower() -eq "stringmultivalue") - { - $coreProperty.IsMultivalued =$true; - } - $coreProperty.Type = $params.Type + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" + + if($params.Type.ToLower() -eq "stringmultivalue") + { + $coreProperty.IsMultivalued =$true; + } + $coreProperty.Type = $params.Type if($termSet -ne $null){ $coreProperty.TermSet = $termSet } - $CoreProperties.Add($coreProperty) - $upTypeProperty = $userProfileTypeProperties.Create($coreProperty) + $CoreProperties.Add($coreProperty) + $upTypeProperty = $userProfileTypeProperties.Create($coreProperty) $userProfileTypeProperties.Add($upTypeProperty) - $upSubProperty = $userProfileSubTypeProperties.Create($UPTypeProperty) + $upSubProperty = $userProfileSubTypeProperties.Create($UPTypeProperty) $userProfileSubTypeProperties.Add($upSubProperty) - Sleep -Milliseconds 100 - $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) + Sleep -Milliseconds 100 + $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) #return $userProfileProperty #endregion @@ -304,8 +304,8 @@ function Set-TargetResource if($params.ContainsKey("DisplayOrder")) { $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) - $profileManager.Properties.SetDisplayOrderByPropertyName($params.Name,$params.DisplayOrder) - $profileManager.Properties.CommitDisplayOrder() + $profileManager.Properties.SetDisplayOrderByPropertyName($params.Name,$params.DisplayOrder) + $profileManager.Properties.CommitDisplayOrder() } #endregion #region mapping @@ -321,7 +321,7 @@ function Set-TargetResource if($currentMapping -ne $null ){ $currentMapping.Delete() #API allows updating, but UI doesn't do that. } - $export = $params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export" + $export = $params.ContainsKey("MappingDirection") -and $params.MappingDirection -eq "Export" if ($Connection.Type -eq "ActiveDirectoryImport"){ if($export){ throw "not implemented" From 13222453dc79a982896c8ccc189ab0d33f50531a Mon Sep 17 00:00:00 2001 From: Camilo Date: Thu, 7 Jan 2016 14:33:06 +0000 Subject: [PATCH 27/91] spaces... --- .../MSFT_xSPUserProfileProperty.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 02a94f583..b6bc53bb4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -380,7 +380,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Testing for user profile property $Name" - if ($null -eq $CurrentValues) { return $false } + if ($null -eq $CurrentValues) { return $false } return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name","DisplayName","Type", "Description", "PolicySetting", "PrivacySetting","AllowUserEdit", "MappingConnectionName","MappingPropertyName", "MappingDirection", "Length", "DisplayOrder", "IsEventLog", "IsVisibleOnEditor", "IsVisibleOnViewer","IsUserEditable", "IsAlias", "IsSearchabe", "UserOverridePrivacy", "TermGroup", "TermStore", "TermSet") } From 1d022374e763748d8d00c34a04035c3b9a5d0598 Mon Sep 17 00:00:00 2001 From: Camilo Date: Thu, 7 Jan 2016 14:40:13 +0000 Subject: [PATCH 28/91] used 'fixer' --- .../MSFT_xSPUserProfileProperty.psm1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index b6bc53bb4..fe4ab9357 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -250,7 +250,7 @@ function Set-TargetResource $coreProperty.Name = $params.Name $coreProperty.DisplayName = $params.DisplayName - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Length" -ParamsValue $params -ParamKey "Length" if($params.Type.ToLower() -eq "stringmultivalue") { @@ -265,7 +265,7 @@ function Set-TargetResource $upTypeProperty = $userProfileTypeProperties.Create($coreProperty) $userProfileTypeProperties.Add($upTypeProperty) $upSubProperty = $userProfileSubTypeProperties.Create($UPTypeProperty) - $userProfileSubTypeProperties.Add($upSubProperty) + $userProfileSubTypeProperties.Add($upSubProperty) Sleep -Milliseconds 100 $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) @@ -286,8 +286,8 @@ function Set-TargetResource Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "DefaultPrivacy" -ParamsValue $params -ParamKey "PrivacySetting" Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "PrivacyPolicy" -ParamsValue $params -ParamKey "PolicySetting" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" - Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "IsUserEditable" -ParamsValue $params -ParamKey "IsUserEditable" + Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $userProfileProperty -PropertyToSet "UserOverridePrivacy" -ParamsValue $params -ParamKey "UserOverridePrivacy" if($termSet -ne $null){ $coreProperty.TermSet = $termSet } From 4c55de42dabdcdf3a4fa7e289e122996b0c3b395 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 13 Jan 2016 15:54:44 +0100 Subject: [PATCH 29/91] First testable version of the resource --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 703 ++++++++++++++++-- ...SFT_xSPWordAutomationServiceApp.schema.mof | 49 +- 2 files changed, 679 insertions(+), 73 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index 0bbeef570..16dfe4fb6 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -4,39 +4,234 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, +<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, + [parameter(Mandatory = $false)] [System.Boolean] $DisableEmbeddedFonts, + [parameter(Mandatory = $false)] [ValidateRange(10,100)] [System.UInt32] $MaximumMemoryUsage, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $RecycleThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $DisableBinaryFileScan, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $ConversionProcesses, + [parameter(Mandatory = $false)] [ValidateRange(1,59)] [System.UInt32] $JobConversionFrequency, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfConversionsPerProcess, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $TimeBeforeConversionIsMonitored, + [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, + [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - - Write-Verbose -Message "Getting Word Automation service app '$Name'" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] + DynamicParam { + if ($Ensure -eq "Present") { + #create a new Application Pool attribute + $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute + $appPoolAttribute.Mandatory = $false + $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $appPoolAttributeCollection.Add($appPoolAttribute) + $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) + + #create a new DatabaseName attribute + $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbNameAttribute.Mandatory = $false + $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbNameAttributeCollection.Add($dbNameAttribute) + $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) + + #create a new DatabaseName attribute + $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbServerAttribute.Mandatory = $false + $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbServerAttributeCollection.Add($dbServerAttribute) + $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) + + #create a new SupportedFileFormats attribute + $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute + $suppFileFormatAttribute.Mandatory = $false + $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) + $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) + $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) + + #create a new DisableEmbeddedFonts attribute + $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute + $disEmbFontsAttribute.Mandatory = $false + $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) + $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) + + #create a new MaximumMemoryUsage attribute + $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxMemUsageAttribute.Mandatory = $false + $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) + $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) + $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) + + #create a new RecycleThreshold attribute + $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute + $recycleThresholdAttribute.Mandatory = $false + $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) + $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) + + #create a new DisableWordDocDocumentScanning attribute + $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute + $disWordScanningAttribute.Mandatory = $false + $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disWordScanningAttributeCollection.Add($disWordScanningAttribute) + $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) + + #create a new ConversionProcesses attribute + $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute + $convProcessesAttribute.Mandatory = $false + $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $convProcessesAttributeCollection.Add($convProcessesAttribute) + $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) + + #create a new JobConversionFrequency attribute + $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute + $jobConvFreqAttribute.Mandatory = $false + $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) + $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) + $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) + + #create a new NumberOfConversionsPerProcess attribute + $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute + $numConvPerProcAttribute.Mandatory = $false + $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) + $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) + + #create a new TimeBeforeConversionIsMonitored attribute + $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute + $timeConvMonAttribute.Mandatory = $false + $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $timeConvMonAttributeCollection.Add($timeConvMonAttribute) + $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) + + #create a new MaximumConversionAttempts attribute + $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvAttemptsAttribute.Mandatory = $false + $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) + $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) + + #create a new MaximumSyncConversionRequests attribute + $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxSyncConvReqAttribute.Mandatory = $false + $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) + $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) + + #create a new KeepAliveTimeout attribute + $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute + $keepAliveAttribute.Mandatory = $false + $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $keepAliveAttributeCollection.Add($keepAliveAttribute) + $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) + + #create a new MaximumConversionTime attribute + $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvTimeAttribute.Mandatory = $false + $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) + $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) + + #expose the name of our parameter + $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + $paramDictionary.Add('ApplicationPool', $appPoolParam) + $paramDictionary.Add('DatabaseName', $dbNameParam) + $paramDictionary.Add('DatabaseServer', $dbServerParam) + $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) + $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) + $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) + $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) + $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) + $paramDictionary.Add('ConversionProcesses', $convProcessesParam) + $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) + $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) + $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) + $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) + $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) + $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) + $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) + return $paramDictionary + } + } + + Process { + Write-Verbose -Message "Getting Word Automation service app '$Name'" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue - if ($null -eq $serviceApps) { - return $null - } - $serviceApp = $serviceApps | Where-Object { $_.TypeName -eq "Word Automation Services" } - - - If ($null -eq $serviceApp) { - return $null - } else { - $returnVal = @{ - Name = $serviceApp.DisplayName - ApplicationPool = $serviceApp.ApplicationPool.Name - DatabaseName = $serviceApp.Databases.Name - DatabaseServer = $serviceApp.Databases.Server.Name + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + + switch ($params.Ensure) { + "Present" { + If ($null -eq $serviceApp) { + return $null + } else { + $supportedFileFormats = @() + if ($serviceApp.WordServiceFormats.OpenXmlDocument) { $supportedFileFormats += "docx" } + if ($serviceApp.WordServiceFormats.Word972003Document) { $supportedFileFormats += "doc" } + if ($serviceApp.WordServiceFormats.RichTextFormat) { $supportedFileFormats += "rtf" } + if ($serviceApp.WordServiceFormats.WebPage) { $supportedFileFormats += "mht" } + if ($serviceApp.WordServiceFormats.Word2003Xml) { $supportedFileFormats += "xml" } + + $returnVal = @{ + Name = $serviceApp.DisplayName + Ensure = $params.Ensure + ApplicationPool = $serviceApp.ApplicationPool.Name + DatabaseName = $serviceApp.Database.Name + DatabaseServer = $serviceApp.Database.Server.Name + SupportedFileFormats = $supportedFileFormats + DisableEmbeddedFonts = $serviceApp.DisableEmbeddedFonts + MaximumMemoryUsage = $serviceApp.MaximumMemoryUsage + RecycleThreshold = $serviceApp.RecycleProcessThreshold + DisableBinaryFileScan = $serviceApp.DisableBinaryFileScan + ConversionProcesses = $serviceApp.TotalActiveProcesses + JobConversionFrequency = $serviceApp.TimerJobFrequency + NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance + TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout + MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts + MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests + KeepAliveTimeout = $serviceApp.KeepAliveTimeout + MaximumConversionTime = $serviceApp.MaximumConversionTime + InstallAccount = $params.InstallAccount + } + return $returnVal + } + } + "Absent" { + If ($null -ne $serviceApp) { + return $null + } else { + $returnVal = @{ + Name = $params.Name + Ensure = $params.Ensure + InstallAccount = $params.InstallAccount + } + return $returnVal + } + } } - return $returnVal - } - } - return $result + } + + return $result + } } function Set-TargetResource @@ -45,39 +240,248 @@ function Set-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, +<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, + [parameter(Mandatory = $false)] [System.Boolean] $DisableEmbeddedFonts, + [parameter(Mandatory = $false)] [ValidateRange(10,100)] [System.UInt32] $MaximumMemoryUsage, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $RecycleThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $DisableBinaryFileScan, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $ConversionProcesses, + [parameter(Mandatory = $false)] [ValidateRange(1,59)] [System.UInt32] $JobConversionFrequency, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfConversionsPerProcess, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $TimeBeforeConversionIsMonitored, + [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, + [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - $result = Get-TargetResource @PSBoundParameters + DynamicParam { + if ($Ensure -eq "Present") { + #create a new Application Pool attribute + $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute + $appPoolAttribute.Mandatory = $false + $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $appPoolAttributeCollection.Add($appPoolAttribute) + $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) - if ($result -eq $null) { - Write-Verbose -Message "Creating Word Automation Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - if($params.ContainsKey("InstallAccount")){ $params.Remove("InstallAccount")} - - New-SPWordConversionServiceApplication @params - } - } - else { - if ($ApplicationPool -ne $result.ApplicationPool) { - Write-Verbose -Message "Updating Word Automation Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - - Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Word Automation Services" } ` - | Set-SPWordConversionServiceApplication -ApplicationPool $appPool - } - } - } + #create a new DatabaseName attribute + $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbNameAttribute.Mandatory = $false + $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbNameAttributeCollection.Add($dbNameAttribute) + $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) + + #create a new DatabaseName attribute + $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbServerAttribute.Mandatory = $false + $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbServerAttributeCollection.Add($dbServerAttribute) + $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) + + #create a new SupportedFileFormats attribute + $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute + $suppFileFormatAttribute.Mandatory = $false + $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) + $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) + $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) + + #create a new DisableEmbeddedFonts attribute + $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute + $disEmbFontsAttribute.Mandatory = $false + $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) + $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) + + #create a new MaximumMemoryUsage attribute + $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxMemUsageAttribute.Mandatory = $false + $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) + $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) + $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) + + #create a new RecycleThreshold attribute + $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute + $recycleThresholdAttribute.Mandatory = $false + $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) + $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) + + #create a new DisableWordDocDocumentScanning attribute + $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute + $disWordScanningAttribute.Mandatory = $false + $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disWordScanningAttributeCollection.Add($disWordScanningAttribute) + $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) + + #create a new ConversionProcesses attribute + $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute + $convProcessesAttribute.Mandatory = $false + $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $convProcessesAttributeCollection.Add($convProcessesAttribute) + $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) + + #create a new JobConversionFrequency attribute + $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute + $jobConvFreqAttribute.Mandatory = $false + $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) + $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) + $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) + + #create a new NumberOfConversionsPerProcess attribute + $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute + $numConvPerProcAttribute.Mandatory = $false + $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) + $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) + + #create a new TimeBeforeConversionIsMonitored attribute + $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute + $timeConvMonAttribute.Mandatory = $false + $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $timeConvMonAttributeCollection.Add($timeConvMonAttribute) + $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) + + #create a new MaximumConversionAttempts attribute + $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvAttemptsAttribute.Mandatory = $false + $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) + $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) + + #create a new MaximumSyncConversionRequests attribute + $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxSyncConvReqAttribute.Mandatory = $false + $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) + $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) + + #create a new KeepAliveTimeout attribute + $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute + $keepAliveAttribute.Mandatory = $false + $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $keepAliveAttributeCollection.Add($keepAliveAttribute) + $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) + + #create a new MaximumConversionTime attribute + $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvTimeAttribute.Mandatory = $false + $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) + $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) + + #expose the name of our parameter + $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + $paramDictionary.Add('ApplicationPool', $appPoolParam) + $paramDictionary.Add('DatabaseName', $dbNameParam) + $paramDictionary.Add('DatabaseServer', $dbServerParam) + $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) + $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) + $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) + $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) + $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) + $paramDictionary.Add('ConversionProcesses', $convProcessesParam) + $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) + $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) + $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) + $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) + $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) + $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) + $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) + return $paramDictionary + } + } + + Process { + switch ($Ensure) { + "Present" { + Write-Verbose -Message "Creating and/or configuring Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + if ($null -eq $serviceApp) { + # Service application does not exist, create it + $cmdletparams = @{} + $cmdletparams.Name = $params.Name + if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } + if ($params.Name) { $cmdletparams.DatabaseServer = $params.DatabaseServer } + if ($params.Name) { $cmdletparams.ApplicationPool = $params.ApplicationPool } + + $serviceApp = New-SPWordConversionServiceApplication @cmdletparams + } else { + # Service application existed + # Check if the specified Application Pool is different and change if so + if ($params.ApplicationPool) { + if ($serviceApp.ApplicationPool.Name -ne $params.ApplicationPool) { + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool + } + } + + # Check if the specified Database Name and Server are different and change if so + if ($params.DatabaseName) { + if ($params.DatabaseServer) { + if ($serviceApp.Database.Server.Name -ne $params.DatabaseServer) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseServer $params.DatabaseServer -DatabaseName $params.DatabaseName } + } else { + if ($serviceApp.Database.Name -ne $params.DatabaseName) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseName $params.DatabaseName } + } + } + } + + if ($params.SupportedFileFormats) { + if ($params.SupportedFileFormats.Contains("docx")) { $serviceApp.WordServiceFormats.OpenXmlDocument = $true } else { $serviceApp.WordServiceFormats.OpenXmlDocument = $false } + if ($params.SupportedFileFormats.Contains("doc")) { $serviceApp.WordServiceFormats.Word972003Document = $true } else { $serviceApp.WordServiceFormats.Word972003Document = $false } + if ($params.SupportedFileFormats.Contains("rtf")) { $serviceApp.WordServiceFormats.RichTextFormat = $true } else { $serviceApp.WordServiceFormats.RichTextFormat = $false } + if ($params.SupportedFileFormats.Contains("mht")) { $serviceApp.WordServiceFormats.WebPage = $true } else { $serviceApp.WordServiceFormats.WebPage = $false } + if ($params.SupportedFileFormats.Contains("xml")) { $serviceApp.WordServiceFormats.Word2003Xml = $true } else { $serviceApp.WordServiceFormats.Word2003Xml = $false } + } + + if ($params.DisableEmbeddedFonts) { $serviceApp.DisableEmbeddedFonts = $params.DisableEmbeddedFonts } + if ($params.MaximumMemoryUsage) { $serviceApp.MaximumMemoryUsage = $params.MaximumMemoryUsage } + if ($params.RecycleThreshold) { $serviceApp.RecycleProcessThreshold = $params.RecycleThreshold } + if ($params.DisableBinaryFileScan) { $serviceApp.DisableBinaryFileScan = $params.DisableBinaryFileScan } + if ($params.ConversionProcesses) { $serviceApp.TotalActiveProcesses = $params.ConversionProcesses } + if ($params.JobConversionFrequency) { $serviceApp.TimerJobFrequency = $params.JobConversionFrequency } + if ($params.NumberOfConversionsPerProcess) { $serviceApp.ConversionsPerInstance = $params.NumberOfConversionsPerProcess } + if ($params.TimeBeforeConversionIsMonitored) {$serviceApp.ConversionTimeout = $params.TimeBeforeConversionIsMonitored } + if ($params.MaximumConversionAttempts) { $serviceApp.MaximumConversionAttempts = $params.MaximumConversionAttempts } + if ($params.MaximumSyncConversionRequests) { $serviceApp.MaximumSyncConversionRequests = $params.MaximumSyncConversionRequests } + if ($params.KeepAliveTimeout) { $serviceApp.KeepAliveTimeout = $params.KeepAliveTimeout } + if ($params.MaximumConversionTime) { $serviceApp.MaximumConversionTime = $params.MaximumConversionTime } + + $serviceApp.Update() + } + } + "Absent" { + Write-Verbose -Message "Removing Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + if ($null -ne $serviceApp) { + # Service app existed, deleting + Remove-SPServiceApplication $params.Name -RemoveData -Confirm:$false + } + } + } + } + } } function Test-TargetResource @@ -86,19 +490,180 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [System.String] $DatabaseName, - [parameter(Mandatory = $false)] [System.String] $DatabaseServer, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, +<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $DatabaseName, + [parameter(Mandatory = $false)] [System.String] $DatabaseServer, + [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, + [parameter(Mandatory = $false)] [System.Boolean] $DisableEmbeddedFonts, + [parameter(Mandatory = $false)] [ValidateRange(10,100)] [System.UInt32] $MaximumMemoryUsage, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $RecycleThreshold, + [parameter(Mandatory = $false)] [System.Boolean] $DisableBinaryFileScan, + [parameter(Mandatory = $false)] [ValidateRange(1,1000)] [System.UInt32] $ConversionProcesses, + [parameter(Mandatory = $false)] [ValidateRange(1,59)] [System.UInt32] $JobConversionFrequency, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfConversionsPerProcess, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $TimeBeforeConversionIsMonitored, + [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, + [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, + [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" - $CurrentValues = Get-TargetResource @PSBoundParameters + DynamicParam { + if ($Ensure -eq "Present") { + #create a new Application Pool attribute + $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute + $appPoolAttribute.Mandatory = $false + $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $appPoolAttributeCollection.Add($appPoolAttribute) + $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) + + #create a new DatabaseName attribute + $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbNameAttribute.Mandatory = $false + $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbNameAttributeCollection.Add($dbNameAttribute) + $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) + + #create a new DatabaseName attribute + $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute + $dbServerAttribute.Mandatory = $false + $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $dbServerAttributeCollection.Add($dbServerAttribute) + $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) + + #create a new SupportedFileFormats attribute + $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute + $suppFileFormatAttribute.Mandatory = $false + $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) + $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) + $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) + + #create a new DisableEmbeddedFonts attribute + $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute + $disEmbFontsAttribute.Mandatory = $false + $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) + $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) + + #create a new MaximumMemoryUsage attribute + $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxMemUsageAttribute.Mandatory = $false + $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) + $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) + $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) + + #create a new RecycleThreshold attribute + $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute + $recycleThresholdAttribute.Mandatory = $false + $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) + $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) + + #create a new DisableWordDocDocumentScanning attribute + $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute + $disWordScanningAttribute.Mandatory = $false + $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $disWordScanningAttributeCollection.Add($disWordScanningAttribute) + $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) + + #create a new ConversionProcesses attribute + $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute + $convProcessesAttribute.Mandatory = $false + $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $convProcessesAttributeCollection.Add($convProcessesAttribute) + $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) + $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) + + #create a new JobConversionFrequency attribute + $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute + $jobConvFreqAttribute.Mandatory = $false + $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) + $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) + $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) + + #create a new NumberOfConversionsPerProcess attribute + $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute + $numConvPerProcAttribute.Mandatory = $false + $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) + $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) + + #create a new TimeBeforeConversionIsMonitored attribute + $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute + $timeConvMonAttribute.Mandatory = $false + $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $timeConvMonAttributeCollection.Add($timeConvMonAttribute) + $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) + + #create a new MaximumConversionAttempts attribute + $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvAttemptsAttribute.Mandatory = $false + $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) + $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) + + #create a new MaximumSyncConversionRequests attribute + $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxSyncConvReqAttribute.Mandatory = $false + $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) + $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) + + #create a new KeepAliveTimeout attribute + $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute + $keepAliveAttribute.Mandatory = $false + $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $keepAliveAttributeCollection.Add($keepAliveAttribute) + $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) + $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) + + #create a new MaximumConversionTime attribute + $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute + $maxConvTimeAttribute.Mandatory = $false + $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] + $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) + $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) + $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) + + #expose the name of our parameter + $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + $paramDictionary.Add('ApplicationPool', $appPoolParam) + $paramDictionary.Add('DatabaseName', $dbNameParam) + $paramDictionary.Add('DatabaseServer', $dbServerParam) + $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) + $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) + $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) + $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) + $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) + $paramDictionary.Add('ConversionProcesses', $convProcessesParam) + $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) + $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) + $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) + $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) + $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) + $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) + $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) + return $paramDictionary + } + } + + Process { + Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" + $CurrentValues = Get-TargetResource @PSBoundParameters - if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + } } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof index eb4aa7438..d9d00d4e4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof @@ -4,12 +4,39 @@ The resource will provision and configure the Word Automation Service Application. The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. -**Example** +**Example** + +Make sure the service application exists and has a specific configuration + xSPWordAutomationServiceApp Word Automation { Name = "Word Automation Service Application" Ensure = "Present" - ApplicationPool = "SharePoint Web Services" + ApplicationPool = "SharePoint Web Services" + DatabaseName = WordAutomation_DB + DatabaseServer = SQLServer + SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleThreshold = 100 + DisableBinaryFileScan = $false + ConversionProcesses = 8 + JobConversionFrequency = 15 + NumberOfConversionsPerProcess = 12 + TimeBeforeConversionIsMonitored = 5 + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 + MaximumConversionTime = 300 + PsDscRunAsCredential = $InstallAccount + } + +Make sure the service application does not exist and remove when it does + + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Absent" PsDscRunAsCredential = $InstallAccount } */ @@ -18,8 +45,22 @@ The database specific parameters are only used during initial provisioning of th class MSFT_xSPWordAutomationServiceApp : OMI_BaseResource { [Key] string Name; + [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write] string ApplicationPool; - [Write, EmbeddedInstance("MSFT_Credential")] String DatabaseCredentials; - [Required] string DatabaseName; + [Write] string DatabaseName; [Write] string DatabaseServer; + [Write, ValueMap{"docx","doc","mht","rtf","xml"}, Values{"docx","doc","mht","rtf","xml"}] string SupportedFileFormats[]; + [Write] boolean DisableEmbeddedFonts; + [Write] uint32 MaximumMemoryUsage; + [Write] uint32 RecycleThreshold; + [Write] boolean DisableBinaryFileScan; + [Write] uint32 ConversionProcesses; + [Write] uint32 JobConversionFrequency; + [Write] uint32 NumberOfConversionsPerProcess; + [Write] uint32 TimeBeforeConversionIsMonitored; + [Write] uint32 MaximumConversionAttempts; + [Write] uint32 MaximumSyncConversionRequests; + [Write] uint32 KeepAliveTimeout; + [Write] uint32 MaximumConversionTime; + [Write, EmbeddedInstance("MSFT_Credential")] string InstallAccount; }; From fe90ad9f2faad5a3807f4baaa0281f0761bd83cd Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 13 Jan 2016 19:19:40 +0100 Subject: [PATCH 30/91] Removed dynamic parameters, which DSC unfortunately does not support --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 696 ++++-------------- ...SFT_xSPWordAutomationServiceApp.schema.mof | 4 +- 2 files changed, 134 insertions(+), 566 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index 16dfe4fb6..826404b31 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, -<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, [parameter(Mandatory = $false)] [System.String] $DatabaseName, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, @@ -21,217 +21,73 @@ function Get-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - DynamicParam { - if ($Ensure -eq "Present") { - #create a new Application Pool attribute - $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute - $appPoolAttribute.Mandatory = $false - $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $appPoolAttributeCollection.Add($appPoolAttribute) - $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) + Write-Verbose -Message "Getting Word Automation service app '$Name'" - #create a new DatabaseName attribute - $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbNameAttribute.Mandatory = $false - $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbNameAttributeCollection.Add($dbNameAttribute) - $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) - - #create a new DatabaseName attribute - $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbServerAttribute.Mandatory = $false - $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbServerAttributeCollection.Add($dbServerAttribute) - $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) - - #create a new SupportedFileFormats attribute - $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute - $suppFileFormatAttribute.Mandatory = $false - $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) - $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) - $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) - - #create a new DisableEmbeddedFonts attribute - $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute - $disEmbFontsAttribute.Mandatory = $false - $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) - $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) - - #create a new MaximumMemoryUsage attribute - $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxMemUsageAttribute.Mandatory = $false - $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) - $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) - $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) - - #create a new RecycleThreshold attribute - $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute - $recycleThresholdAttribute.Mandatory = $false - $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) - $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) - - #create a new DisableWordDocDocumentScanning attribute - $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute - $disWordScanningAttribute.Mandatory = $false - $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disWordScanningAttributeCollection.Add($disWordScanningAttribute) - $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) - - #create a new ConversionProcesses attribute - $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute - $convProcessesAttribute.Mandatory = $false - $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $convProcessesAttributeCollection.Add($convProcessesAttribute) - $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) - - #create a new JobConversionFrequency attribute - $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute - $jobConvFreqAttribute.Mandatory = $false - $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) - $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) - $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) - - #create a new NumberOfConversionsPerProcess attribute - $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute - $numConvPerProcAttribute.Mandatory = $false - $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) - $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) - - #create a new TimeBeforeConversionIsMonitored attribute - $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute - $timeConvMonAttribute.Mandatory = $false - $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $timeConvMonAttributeCollection.Add($timeConvMonAttribute) - $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) - - #create a new MaximumConversionAttempts attribute - $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvAttemptsAttribute.Mandatory = $false - $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) - $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) - - #create a new MaximumSyncConversionRequests attribute - $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxSyncConvReqAttribute.Mandatory = $false - $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) - $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) - - #create a new KeepAliveTimeout attribute - $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute - $keepAliveAttribute.Mandatory = $false - $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $keepAliveAttributeCollection.Add($keepAliveAttribute) - $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) - - #create a new MaximumConversionTime attribute - $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvTimeAttribute.Mandatory = $false - $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) - $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) - - #expose the name of our parameter - $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - $paramDictionary.Add('ApplicationPool', $appPoolParam) - $paramDictionary.Add('DatabaseName', $dbNameParam) - $paramDictionary.Add('DatabaseServer', $dbServerParam) - $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) - $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) - $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) - $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) - $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) - $paramDictionary.Add('ConversionProcesses', $convProcessesParam) - $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) - $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) - $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) - $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) - $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) - $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) - $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) - return $paramDictionary - } + if (($ApplicationPool -or $DatabaseName -or $DatabaseServer -or $SupportedFileFormats -or $DisableEmbeddedFonts -or $MaximumMemoryUsage -or $RecycleThreshold -or $DisableBinaryFileScan -or $ConversionProcesses -or $JobConversionFrequency -or $NumberOfConversionsPerProcess -or $TimeBeforeConversionIsMonitored -or $MaximumConversionAttempts -or $MaximumSyncConversionRequests -or $KeepAliveTimeout -or $MaximumConversionTime) -and ($Ensure -eq "Absent")) { + throw "You cannot use any of the parameters when Ensure is specified as Absent" } - - Process { - Write-Verbose -Message "Getting Word Automation service app '$Name'" - $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } - switch ($params.Ensure) { - "Present" { - If ($null -eq $serviceApp) { - return $null - } else { - $supportedFileFormats = @() - if ($serviceApp.WordServiceFormats.OpenXmlDocument) { $supportedFileFormats += "docx" } - if ($serviceApp.WordServiceFormats.Word972003Document) { $supportedFileFormats += "doc" } - if ($serviceApp.WordServiceFormats.RichTextFormat) { $supportedFileFormats += "rtf" } - if ($serviceApp.WordServiceFormats.WebPage) { $supportedFileFormats += "mht" } - if ($serviceApp.WordServiceFormats.Word2003Xml) { $supportedFileFormats += "xml" } - - $returnVal = @{ - Name = $serviceApp.DisplayName - Ensure = $params.Ensure - ApplicationPool = $serviceApp.ApplicationPool.Name - DatabaseName = $serviceApp.Database.Name - DatabaseServer = $serviceApp.Database.Server.Name - SupportedFileFormats = $supportedFileFormats - DisableEmbeddedFonts = $serviceApp.DisableEmbeddedFonts - MaximumMemoryUsage = $serviceApp.MaximumMemoryUsage - RecycleThreshold = $serviceApp.RecycleProcessThreshold - DisableBinaryFileScan = $serviceApp.DisableBinaryFileScan - ConversionProcesses = $serviceApp.TotalActiveProcesses - JobConversionFrequency = $serviceApp.TimerJobFrequency - NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance - TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout - MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts - MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests - KeepAliveTimeout = $serviceApp.KeepAliveTimeout - MaximumConversionTime = $serviceApp.MaximumConversionTime - InstallAccount = $params.InstallAccount - } - return $returnVal - } + switch ($params.Ensure) { + "Present" { + If ($null -eq $serviceApp) { + return $null + } else { + $supportedFileFormats = @() + if ($serviceApp.WordServiceFormats.OpenXmlDocument) { $supportedFileFormats += "docx" } + if ($serviceApp.WordServiceFormats.Word972003Document) { $supportedFileFormats += "doc" } + if ($serviceApp.WordServiceFormats.RichTextFormat) { $supportedFileFormats += "rtf" } + if ($serviceApp.WordServiceFormats.WebPage) { $supportedFileFormats += "mht" } + if ($serviceApp.WordServiceFormats.Word2003Xml) { $supportedFileFormats += "xml" } + + $returnVal = @{ + Name = $serviceApp.DisplayName + Ensure = $params.Ensure + ApplicationPool = $serviceApp.ApplicationPool.Name + DatabaseName = $serviceApp.Database.Name + DatabaseServer = $serviceApp.Database.Server.Name + SupportedFileFormats = $supportedFileFormats + DisableEmbeddedFonts = $serviceApp.DisableEmbeddedFonts + MaximumMemoryUsage = $serviceApp.MaximumMemoryUsage + RecycleThreshold = $serviceApp.RecycleProcessThreshold + DisableBinaryFileScan = $serviceApp.DisableBinaryFileScan + ConversionProcesses = $serviceApp.TotalActiveProcesses + JobConversionFrequency = $serviceApp.TimerJobFrequency + NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance + TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout + MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts + MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests + KeepAliveTimeout = $serviceApp.KeepAliveTimeout + MaximumConversionTime = $serviceApp.MaximumConversionTime + InstallAccount = $params.InstallAccount + } + return $returnVal } - "Absent" { - If ($null -ne $serviceApp) { - return $null - } else { - $returnVal = @{ - Name = $params.Name - Ensure = $params.Ensure - InstallAccount = $params.InstallAccount - } - return $returnVal - } + } + "Absent" { + If ($null -ne $serviceApp) { + return $null + } else { + $returnVal = @{ + Name = $params.Name + Ensure = $params.Ensure + InstallAccount = $params.InstallAccount + } + return $returnVal } - } - } - - return $result + } + } } + + return $result } function Set-TargetResource @@ -242,7 +98,7 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, -<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, [parameter(Mandatory = $false)] [System.String] $DatabaseName, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, @@ -257,229 +113,85 @@ function Set-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - DynamicParam { - if ($Ensure -eq "Present") { - #create a new Application Pool attribute - $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute - $appPoolAttribute.Mandatory = $false - $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $appPoolAttributeCollection.Add($appPoolAttribute) - $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) - - #create a new DatabaseName attribute - $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbNameAttribute.Mandatory = $false - $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbNameAttributeCollection.Add($dbNameAttribute) - $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) - - #create a new DatabaseName attribute - $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbServerAttribute.Mandatory = $false - $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbServerAttributeCollection.Add($dbServerAttribute) - $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) - - #create a new SupportedFileFormats attribute - $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute - $suppFileFormatAttribute.Mandatory = $false - $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) - $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) - $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) - - #create a new DisableEmbeddedFonts attribute - $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute - $disEmbFontsAttribute.Mandatory = $false - $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) - $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) - - #create a new MaximumMemoryUsage attribute - $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxMemUsageAttribute.Mandatory = $false - $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) - $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) - $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) - - #create a new RecycleThreshold attribute - $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute - $recycleThresholdAttribute.Mandatory = $false - $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) - $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) - - #create a new DisableWordDocDocumentScanning attribute - $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute - $disWordScanningAttribute.Mandatory = $false - $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disWordScanningAttributeCollection.Add($disWordScanningAttribute) - $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) - - #create a new ConversionProcesses attribute - $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute - $convProcessesAttribute.Mandatory = $false - $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $convProcessesAttributeCollection.Add($convProcessesAttribute) - $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) - - #create a new JobConversionFrequency attribute - $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute - $jobConvFreqAttribute.Mandatory = $false - $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) - $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) - $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) - - #create a new NumberOfConversionsPerProcess attribute - $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute - $numConvPerProcAttribute.Mandatory = $false - $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) - $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) - - #create a new TimeBeforeConversionIsMonitored attribute - $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute - $timeConvMonAttribute.Mandatory = $false - $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $timeConvMonAttributeCollection.Add($timeConvMonAttribute) - $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) - - #create a new MaximumConversionAttempts attribute - $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvAttemptsAttribute.Mandatory = $false - $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) - $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) - - #create a new MaximumSyncConversionRequests attribute - $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxSyncConvReqAttribute.Mandatory = $false - $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) - $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) - - #create a new KeepAliveTimeout attribute - $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute - $keepAliveAttribute.Mandatory = $false - $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $keepAliveAttributeCollection.Add($keepAliveAttribute) - $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) - - #create a new MaximumConversionTime attribute - $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvTimeAttribute.Mandatory = $false - $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) - $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) - - #expose the name of our parameter - $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - $paramDictionary.Add('ApplicationPool', $appPoolParam) - $paramDictionary.Add('DatabaseName', $dbNameParam) - $paramDictionary.Add('DatabaseServer', $dbServerParam) - $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) - $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) - $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) - $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) - $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) - $paramDictionary.Add('ConversionProcesses', $convProcessesParam) - $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) - $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) - $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) - $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) - $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) - $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) - $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) - return $paramDictionary - } + if (($ApplicationPool -or $DatabaseName -or $DatabaseServer -or $SupportedFileFormats -or $DisableEmbeddedFonts -or $MaximumMemoryUsage -or $RecycleThreshold -or $DisableBinaryFileScan -or $ConversionProcesses -or $JobConversionFrequency -or $NumberOfConversionsPerProcess -or $TimeBeforeConversionIsMonitored -or $MaximumConversionAttempts -or $MaximumSyncConversionRequests -or $KeepAliveTimeout -or $MaximumConversionTime) -and ($Ensure -eq "Absent")) { + throw "You cannot use any of the parameters when Ensure is specified as Absent" } - Process { - switch ($Ensure) { - "Present" { - Write-Verbose -Message "Creating and/or configuring Word Automation Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - - $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } - if ($null -eq $serviceApp) { - # Service application does not exist, create it - $cmdletparams = @{} - $cmdletparams.Name = $params.Name - if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } - if ($params.Name) { $cmdletparams.DatabaseServer = $params.DatabaseServer } - if ($params.Name) { $cmdletparams.ApplicationPool = $params.ApplicationPool } - - $serviceApp = New-SPWordConversionServiceApplication @cmdletparams - } else { - # Service application existed - # Check if the specified Application Pool is different and change if so - if ($params.ApplicationPool) { - if ($serviceApp.ApplicationPool.Name -ne $params.ApplicationPool) { - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool - } - } - - # Check if the specified Database Name and Server are different and change if so - if ($params.DatabaseName) { - if ($params.DatabaseServer) { - if ($serviceApp.Database.Server.Name -ne $params.DatabaseServer) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseServer $params.DatabaseServer -DatabaseName $params.DatabaseName } - } else { - if ($serviceApp.Database.Name -ne $params.DatabaseName) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseName $params.DatabaseName } - } + switch ($Ensure) { + "Present" { + Write-Verbose -Message "Creating and/or configuring Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + if ($null -eq $serviceApp) { + # Service application does not exist, create it + $cmdletparams = @{} + $cmdletparams.Name = $params.Name + if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } + if ($params.Name) { $cmdletparams.DatabaseServer = $params.DatabaseServer } + if ($params.Name) { $cmdletparams.ApplicationPool = $params.ApplicationPool } + + $serviceApp = New-SPWordConversionServiceApplication @cmdletparams + } else { + # Service application existed + # Check if the specified Application Pool is different and change if so + if ($params.ApplicationPool) { + if ($serviceApp.ApplicationPool.Name -ne $params.ApplicationPool) { + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool } } - if ($params.SupportedFileFormats) { - if ($params.SupportedFileFormats.Contains("docx")) { $serviceApp.WordServiceFormats.OpenXmlDocument = $true } else { $serviceApp.WordServiceFormats.OpenXmlDocument = $false } - if ($params.SupportedFileFormats.Contains("doc")) { $serviceApp.WordServiceFormats.Word972003Document = $true } else { $serviceApp.WordServiceFormats.Word972003Document = $false } - if ($params.SupportedFileFormats.Contains("rtf")) { $serviceApp.WordServiceFormats.RichTextFormat = $true } else { $serviceApp.WordServiceFormats.RichTextFormat = $false } - if ($params.SupportedFileFormats.Contains("mht")) { $serviceApp.WordServiceFormats.WebPage = $true } else { $serviceApp.WordServiceFormats.WebPage = $false } - if ($params.SupportedFileFormats.Contains("xml")) { $serviceApp.WordServiceFormats.Word2003Xml = $true } else { $serviceApp.WordServiceFormats.Word2003Xml = $false } + # Check if the specified Database Name and Server are different and change if so + if ($params.DatabaseName) { + if ($params.DatabaseServer) { + if ($serviceApp.Database.Server.Name -ne $params.DatabaseServer) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseServer $params.DatabaseServer -DatabaseName $params.DatabaseName } + } else { + if ($serviceApp.Database.Name -ne $params.DatabaseName) { Set-SPWordConversionServiceApplication $serviceApp -DatabaseName $params.DatabaseName } + } } + } - if ($params.DisableEmbeddedFonts) { $serviceApp.DisableEmbeddedFonts = $params.DisableEmbeddedFonts } - if ($params.MaximumMemoryUsage) { $serviceApp.MaximumMemoryUsage = $params.MaximumMemoryUsage } - if ($params.RecycleThreshold) { $serviceApp.RecycleProcessThreshold = $params.RecycleThreshold } - if ($params.DisableBinaryFileScan) { $serviceApp.DisableBinaryFileScan = $params.DisableBinaryFileScan } - if ($params.ConversionProcesses) { $serviceApp.TotalActiveProcesses = $params.ConversionProcesses } - if ($params.JobConversionFrequency) { $serviceApp.TimerJobFrequency = $params.JobConversionFrequency } - if ($params.NumberOfConversionsPerProcess) { $serviceApp.ConversionsPerInstance = $params.NumberOfConversionsPerProcess } - if ($params.TimeBeforeConversionIsMonitored) {$serviceApp.ConversionTimeout = $params.TimeBeforeConversionIsMonitored } - if ($params.MaximumConversionAttempts) { $serviceApp.MaximumConversionAttempts = $params.MaximumConversionAttempts } - if ($params.MaximumSyncConversionRequests) { $serviceApp.MaximumSyncConversionRequests = $params.MaximumSyncConversionRequests } - if ($params.KeepAliveTimeout) { $serviceApp.KeepAliveTimeout = $params.KeepAliveTimeout } - if ($params.MaximumConversionTime) { $serviceApp.MaximumConversionTime = $params.MaximumConversionTime } + if ($params.SupportedFileFormats) { + if ($params.SupportedFileFormats.Contains("docx")) { $serviceApp.WordServiceFormats.OpenXmlDocument = $true } else { $serviceApp.WordServiceFormats.OpenXmlDocument = $false } + if ($params.SupportedFileFormats.Contains("doc")) { $serviceApp.WordServiceFormats.Word972003Document = $true } else { $serviceApp.WordServiceFormats.Word972003Document = $false } + if ($params.SupportedFileFormats.Contains("rtf")) { $serviceApp.WordServiceFormats.RichTextFormat = $true } else { $serviceApp.WordServiceFormats.RichTextFormat = $false } + if ($params.SupportedFileFormats.Contains("mht")) { $serviceApp.WordServiceFormats.WebPage = $true } else { $serviceApp.WordServiceFormats.WebPage = $false } + if ($params.SupportedFileFormats.Contains("xml")) { $serviceApp.WordServiceFormats.Word2003Xml = $true } else { $serviceApp.WordServiceFormats.Word2003Xml = $false } + } - $serviceApp.Update() + if ($params.DisableEmbeddedFonts) { $serviceApp.DisableEmbeddedFonts = $params.DisableEmbeddedFonts } + if ($params.MaximumMemoryUsage) { $serviceApp.MaximumMemoryUsage = $params.MaximumMemoryUsage } + if ($params.RecycleThreshold) { $serviceApp.RecycleProcessThreshold = $params.RecycleThreshold } + if ($params.DisableBinaryFileScan) { $serviceApp.DisableBinaryFileScan = $params.DisableBinaryFileScan } + if ($params.ConversionProcesses) { $serviceApp.TotalActiveProcesses = $params.ConversionProcesses } + if ($params.JobConversionFrequency) { $serviceApp.TimerJobFrequency = $params.JobConversionFrequency } + if ($params.NumberOfConversionsPerProcess) { $serviceApp.ConversionsPerInstance = $params.NumberOfConversionsPerProcess } + if ($params.TimeBeforeConversionIsMonitored) {$serviceApp.ConversionTimeout = $params.TimeBeforeConversionIsMonitored } + if ($params.MaximumConversionAttempts) { $serviceApp.MaximumConversionAttempts = $params.MaximumConversionAttempts } + if ($params.MaximumSyncConversionRequests) { $serviceApp.MaximumSyncConversionRequests = $params.MaximumSyncConversionRequests } + if ($params.KeepAliveTimeout) { $serviceApp.KeepAliveTimeout = $params.KeepAliveTimeout } + if ($params.MaximumConversionTime) { $serviceApp.MaximumConversionTime = $params.MaximumConversionTime } + + $serviceApp.Update() + } + } + "Absent" { + Write-Verbose -Message "Removing Word Automation Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } + if ($null -ne $serviceApp) { + # Service app existed, deleting + Remove-SPServiceApplication $params.Name -RemoveData -Confirm:$false } } - "Absent" { - Write-Verbose -Message "Removing Word Automation Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - - $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } - if ($null -ne $serviceApp) { - # Service app existed, deleting - Remove-SPServiceApplication $params.Name -RemoveData -Confirm:$false - } - } - } } } } @@ -492,7 +204,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, -<# [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, [parameter(Mandatory = $false)] [System.String] $DatabaseName, [parameter(Mandatory = $false)] [System.String] $DatabaseServer, [parameter(Mandatory = $false)] [ValidateSet("docx","doc","mht","rtf","xml")] [System.String[]] $SupportedFileFormats, @@ -507,163 +219,19 @@ function Test-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime,#> + [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - DynamicParam { - if ($Ensure -eq "Present") { - #create a new Application Pool attribute - $appPoolAttribute = New-Object System.Management.Automation.ParameterAttribute - $appPoolAttribute.Mandatory = $false - $appPoolAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $appPoolAttributeCollection.Add($appPoolAttribute) - $appPoolParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ApplicationPool', [System.String], $appPoolAttributeCollection) - - #create a new DatabaseName attribute - $dbNameAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbNameAttribute.Mandatory = $false - $dbNameAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbNameAttributeCollection.Add($dbNameAttribute) - $dbNameParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseName', [System.String], $dbNameAttributeCollection) - - #create a new DatabaseName attribute - $dbServerAttribute = New-Object System.Management.Automation.ParameterAttribute - $dbServerAttribute.Mandatory = $false - $dbServerAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $dbServerAttributeCollection.Add($dbServerAttribute) - $dbServerParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DatabaseServer', [System.String], $dbServerAttributeCollection) - - #create a new SupportedFileFormats attribute - $suppFileFormatAttribute = New-Object System.Management.Automation.ParameterAttribute - $suppFileFormatAttribute.Mandatory = $false - $suppFileFormatAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $suppFileFormatAttributeCollection.Add($suppFileFormatAttribute) - $suppFileFormatAttributeCollection.Add(((New-Object System.Management.Automation.ValidateSetAttribute(("docx","doc","mht","rtf","xml"))))) - $suppFileFormatParam = New-Object System.Management.Automation.RuntimeDefinedParameter('SupportedFileFormats', [string[]], $suppFileFormatAttributeCollection) - - #create a new DisableEmbeddedFonts attribute - $disEmbFontsAttribute = New-Object System.Management.Automation.ParameterAttribute - $disEmbFontsAttribute.Mandatory = $false - $disEmbFontsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disEmbFontsAttributeCollection.Add($disEmbFontsAttribute) - $disEmbFontsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableEmbeddedFonts', [Boolean], $disEmbFontsAttributeCollection) - - #create a new MaximumMemoryUsage attribute - $maxMemUsageAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxMemUsageAttribute.Mandatory = $false - $maxMemUsageAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxMemUsageAttributeCollection.Add($maxMemUsageAttribute) - $maxMemUsageAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((10,100))))) - $maxMemUsageParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumMemoryUsage', [Int32], $maxMemUsageAttributeCollection) - - #create a new RecycleThreshold attribute - $recycleThresholdAttribute = New-Object System.Management.Automation.ParameterAttribute - $recycleThresholdAttribute.Mandatory = $false - $recycleThresholdAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $recycleThresholdAttributeCollection.Add($recycleThresholdAttribute) - $recycleThresholdAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $recycleThresholdParam = New-Object System.Management.Automation.RuntimeDefinedParameter('RecycleThreshold', [Int32], $recycleThresholdAttributeCollection) - - #create a new DisableWordDocDocumentScanning attribute - $disWordScanningAttribute = New-Object System.Management.Automation.ParameterAttribute - $disWordScanningAttribute.Mandatory = $false - $disWordScanningAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $disWordScanningAttributeCollection.Add($disWordScanningAttribute) - $disWordScanningParam = New-Object System.Management.Automation.RuntimeDefinedParameter('DisableWordDocDocumentScanning', [Boolean], $disWordScanningAttributeCollection) - - #create a new ConversionProcesses attribute - $convProcessesAttribute = New-Object System.Management.Automation.ParameterAttribute - $convProcessesAttribute.Mandatory = $false - $convProcessesAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $convProcessesAttributeCollection.Add($convProcessesAttribute) - $convProcessesAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,1000))))) - $convProcessesParam = New-Object System.Management.Automation.RuntimeDefinedParameter('ConversionProcesses', [Int32], $convProcessesAttributeCollection) - - #create a new JobConversionFrequency attribute - $jobConvFreqAttribute = New-Object System.Management.Automation.ParameterAttribute - $jobConvFreqAttribute.Mandatory = $false - $jobConvFreqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $jobConvFreqAttributeCollection.Add($jobConvFreqAttribute) - $jobConvFreqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,59))))) - $jobConvFreqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('JobConversionFrequency', [Int32], $jobConvFreqAttributeCollection) - - #create a new NumberOfConversionsPerProcess attribute - $numConvPerProcAttribute = New-Object System.Management.Automation.ParameterAttribute - $numConvPerProcAttribute.Mandatory = $false - $numConvPerProcAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $numConvPerProcAttributeCollection.Add($numConvPerProcAttribute) - $numConvPerProcParam = New-Object System.Management.Automation.RuntimeDefinedParameter('NumberOfConversionsPerProcess', [Int32], $numConvPerProcAttributeCollection) - - #create a new TimeBeforeConversionIsMonitored attribute - $timeConvMonAttribute = New-Object System.Management.Automation.ParameterAttribute - $timeConvMonAttribute.Mandatory = $false - $timeConvMonAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $timeConvMonAttributeCollection.Add($timeConvMonAttribute) - $timeConvMonAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $timeConvMonParam = New-Object System.Management.Automation.RuntimeDefinedParameter('TimeBeforeConversionIsMonitored', [Int32], $timeConvMonAttributeCollection) - - #create a new MaximumConversionAttempts attribute - $maxConvAttemptsAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvAttemptsAttribute.Mandatory = $false - $maxConvAttemptsAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvAttemptsAttributeCollection.Add($maxConvAttemptsAttribute) - $maxConvAttemptsAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $maxConvAttemptsParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionAttempts', [Int32], $maxConvAttemptsAttributeCollection) - - #create a new MaximumSyncConversionRequests attribute - $maxSyncConvReqAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxSyncConvReqAttribute.Mandatory = $false - $maxSyncConvReqAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxSyncConvReqAttributeCollection.Add($maxSyncConvReqAttribute) - $maxSyncConvReqAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxSyncConvReqParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumSyncConversionRequests', [Int32], $maxSyncConvReqAttributeCollection) - - #create a new KeepAliveTimeout attribute - $keepAliveAttribute = New-Object System.Management.Automation.ParameterAttribute - $keepAliveAttribute.Mandatory = $false - $keepAliveAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $keepAliveAttributeCollection.Add($keepAliveAttribute) - $keepAliveAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,10))))) - $keepAliveParam = New-Object System.Management.Automation.RuntimeDefinedParameter('KeepAliveTimeout', [Int32], $keepAliveAttributeCollection) - - #create a new MaximumConversionTime attribute - $maxConvTimeAttribute = New-Object System.Management.Automation.ParameterAttribute - $maxConvTimeAttribute.Mandatory = $false - $maxConvTimeAttributeCollection = new-object System.Collections.ObjectModel.Collection[System.Attribute] - $maxConvTimeAttributeCollection.Add($maxConvTimeAttribute) - $maxConvTimeAttributeCollection.Add(((New-Object System.Management.Automation.ValidateRangeAttribute((1,60))))) - $maxConvTimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter('MaximumConversionTime', [Int32], $maxConvTimeAttributeCollection) - - #expose the name of our parameter - $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - $paramDictionary.Add('ApplicationPool', $appPoolParam) - $paramDictionary.Add('DatabaseName', $dbNameParam) - $paramDictionary.Add('DatabaseServer', $dbServerParam) - $paramDictionary.Add('SupportedFileFormats', $suppFileFormatParam) - $paramDictionary.Add('DisableEmbeddedFonts', $disEmbFontsParam) - $paramDictionary.Add('MaximumMemoryUsage', $maxMemUsageParam) - $paramDictionary.Add('RecycleThreshold', $recycleThresholdParam) - $paramDictionary.Add('DisableWordDocDocumentScanning', $disWordScanningParam) - $paramDictionary.Add('ConversionProcesses', $convProcessesParam) - $paramDictionary.Add('JobConversionFrequency', $jobConvFreqParam) - $paramDictionary.Add('NumberOfConversionsPerProcess', $numConvPerProcParam) - $paramDictionary.Add('TimeBeforeConversionIsMonitored', $timeConvMonParam) - $paramDictionary.Add('MaximumConversionAttempts', $maxConvAttemptsParam) - $paramDictionary.Add('MaximumSyncConversionRequests', $maxSyncConvReqParam) - $paramDictionary.Add('KeepAliveTimeout', $keepAliveParam) - $paramDictionary.Add('MaximumConversionTime', $maxConvTimeParam) - return $paramDictionary - } + if (($ApplicationPool -or $DatabaseName -or $DatabaseServer -or $SupportedFileFormats -or $DisableEmbeddedFonts -or $MaximumMemoryUsage -or $RecycleThreshold -or $DisableBinaryFileScan -or $ConversionProcesses -or $JobConversionFrequency -or $NumberOfConversionsPerProcess -or $TimeBeforeConversionIsMonitored -or $MaximumConversionAttempts -or $MaximumSyncConversionRequests -or $KeepAliveTimeout -or $MaximumConversionTime) -and ($Ensure -eq "Absent")) { + throw "You cannot use any of the parameters when Ensure is specified as Absent" } - Process { - Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" - $CurrentValues = Get-TargetResource @PSBoundParameters + Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" + $CurrentValues = Get-TargetResource @PSBoundParameters - if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") - } + if ($null -eq $CurrentValues) { return $false } + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof index d9d00d4e4..dd7ad2e17 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof @@ -13,8 +13,8 @@ Make sure the service application exists and has a specific configuration Name = "Word Automation Service Application" Ensure = "Present" ApplicationPool = "SharePoint Web Services" - DatabaseName = WordAutomation_DB - DatabaseServer = SQLServer + DatabaseName = "WordAutomation_DB" + DatabaseServer = "SQLServer" SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" DisableEmbeddedFonts = $false MaximumMemoryUsage = 100 From a27bdc998297bee421d6174afd67d09b329314d6 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 13 Jan 2016 20:33:31 +0100 Subject: [PATCH 31/91] Changed Timespan values and configuration of timerjob --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index 826404b31..496205b0b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -62,11 +62,11 @@ function Get-TargetResource ConversionProcesses = $serviceApp.TotalActiveProcesses JobConversionFrequency = $serviceApp.TimerJobFrequency NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance - TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout + TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout.TotalMinutes MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests - KeepAliveTimeout = $serviceApp.KeepAliveTimeout - MaximumConversionTime = $serviceApp.MaximumConversionTime + KeepAliveTimeout = $serviceApp.KeepAliveTimeout.TotalSeconds + MaximumConversionTime = $serviceApp.MaximumConversionTime.TotalMinutes InstallAccount = $params.InstallAccount } return $returnVal @@ -121,6 +121,10 @@ function Set-TargetResource throw "You cannot use any of the parameters when Ensure is specified as Absent" } + if (($Ensure -eq "Absent") -and ($ApplicationPool -and $DatabaseName)) { + throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + switch ($Ensure) { "Present" { Write-Verbose -Message "Creating and/or configuring Word Automation Service Application $Name" @@ -130,6 +134,9 @@ function Set-TargetResource $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } if ($null -eq $serviceApp) { # Service application does not exist, create it + + ######################## Check if application pool exists + $cmdletparams = @{} $cmdletparams.Name = $params.Name if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } @@ -142,6 +149,9 @@ function Set-TargetResource # Check if the specified Application Pool is different and change if so if ($params.ApplicationPool) { if ($serviceApp.ApplicationPool.Name -ne $params.ApplicationPool) { + + ######################## Check if application pool exists + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool } @@ -170,13 +180,31 @@ function Set-TargetResource if ($params.RecycleThreshold) { $serviceApp.RecycleProcessThreshold = $params.RecycleThreshold } if ($params.DisableBinaryFileScan) { $serviceApp.DisableBinaryFileScan = $params.DisableBinaryFileScan } if ($params.ConversionProcesses) { $serviceApp.TotalActiveProcesses = $params.ConversionProcesses } - if ($params.JobConversionFrequency) { $serviceApp.TimerJobFrequency = $params.JobConversionFrequency } + if ($params.JobConversionFrequency) { + # Check for TimerJob and change schedule + $wordAutomationTimerjob = Get-SPTimerJob $params.Name + if ($wordAutomationTimerjob.Count -eq 1) { + $schedule = "every $($params.JobConversionFrequency) minutes between 0 and 0" + Set-SPTimerJob $job -Schedule $schedule + } else { + throw "Timerjob could not be found" + } + } if ($params.NumberOfConversionsPerProcess) { $serviceApp.ConversionsPerInstance = $params.NumberOfConversionsPerProcess } - if ($params.TimeBeforeConversionIsMonitored) {$serviceApp.ConversionTimeout = $params.TimeBeforeConversionIsMonitored } + if ($params.TimeBeforeConversionIsMonitored) { + $timespan = New-TimeSpan -Minutes $params.TimeBeforeConversionIsMonitored + $serviceApp.ConversionTimeout = $timespan + } if ($params.MaximumConversionAttempts) { $serviceApp.MaximumConversionAttempts = $params.MaximumConversionAttempts } if ($params.MaximumSyncConversionRequests) { $serviceApp.MaximumSyncConversionRequests = $params.MaximumSyncConversionRequests } - if ($params.KeepAliveTimeout) { $serviceApp.KeepAliveTimeout = $params.KeepAliveTimeout } - if ($params.MaximumConversionTime) { $serviceApp.MaximumConversionTime = $params.MaximumConversionTime } + if ($params.KeepAliveTimeout) { + $timespan = New-TimeSpan -Seconds $params.KeepAliveTimeout + $serviceApp.KeepAliveTimeout = $timespan + } + if ($params.MaximumConversionTime) { + $timespan = New-TimeSpan -Minutes $params.MaximumConversionTime + $serviceApp.MaximumConversionTime = $timespan + } $serviceApp.Update() } From 893985728818379f9290099d1433080b70406296 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 13 Jan 2016 20:52:41 +0100 Subject: [PATCH 32/91] Added Application Pool exists check and fixes bugs --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index 496205b0b..e0c01fd08 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -21,7 +21,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, + [parameter(Mandatory = $false)] [ValidateRange(60,3600)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -66,7 +66,7 @@ function Get-TargetResource MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests KeepAliveTimeout = $serviceApp.KeepAliveTimeout.TotalSeconds - MaximumConversionTime = $serviceApp.MaximumConversionTime.TotalMinutes + MaximumConversionTime = $serviceApp.MaximumConversionTime.TotalSeconds InstallAccount = $params.InstallAccount } return $returnVal @@ -113,7 +113,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, + [parameter(Mandatory = $false)] [ValidateRange(60,3600)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -135,25 +135,29 @@ function Set-TargetResource if ($null -eq $serviceApp) { # Service application does not exist, create it - ######################## Check if application pool exists + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + if ($appPool) { + $cmdletparams = @{} + $cmdletparams.Name = $params.Name + if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } + if ($params.Name) { $cmdletparams.DatabaseServer = $params.DatabaseServer } + if ($params.Name) { $cmdletparams.ApplicationPool = $params.ApplicationPool } - $cmdletparams = @{} - $cmdletparams.Name = $params.Name - if ($params.Name) { $cmdletparams.DatabaseName = $params.DatabaseName } - if ($params.Name) { $cmdletparams.DatabaseServer = $params.DatabaseServer } - if ($params.Name) { $cmdletparams.ApplicationPool = $params.ApplicationPool } - - $serviceApp = New-SPWordConversionServiceApplication @cmdletparams + $serviceApp = New-SPWordConversionServiceApplication @cmdletparams + } else { + throw "Specified application pool does not exist" + } } else { # Service application existed # Check if the specified Application Pool is different and change if so if ($params.ApplicationPool) { if ($serviceApp.ApplicationPool.Name -ne $params.ApplicationPool) { - - ######################## Check if application pool exists - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool + if ($appPool) { + Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool + } else { + throw "Specified application pool does not exist" + } } } @@ -202,7 +206,7 @@ function Set-TargetResource $serviceApp.KeepAliveTimeout = $timespan } if ($params.MaximumConversionTime) { - $timespan = New-TimeSpan -Minutes $params.MaximumConversionTime + $timespan = New-TimeSpan -Seconds $params.MaximumConversionTime $serviceApp.MaximumConversionTime = $timespan } @@ -247,7 +251,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [ValidateRange(1,10)] [System.UInt32] $MaximumConversionAttempts, [parameter(Mandatory = $false)] [ValidateRange(1,60)] [System.UInt32] $MaximumSyncConversionRequests, [parameter(Mandatory = $false)] [ValidateRange(10,60)] [System.UInt32] $KeepAliveTimeout, - [parameter(Mandatory = $false)] [ValidateRange(60,4294967295)] [System.UInt32] $MaximumConversionTime, + [parameter(Mandatory = $false)] [ValidateRange(60,3600)] [System.UInt32] $MaximumConversionTime, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) From f7b16e47b4c883a8997e80bad6e0b52d521833fb Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 13 Jan 2016 21:33:20 +0100 Subject: [PATCH 33/91] Bug fixes for issues found during testing --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index e0c01fd08..5ba3297b1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -60,7 +60,7 @@ function Get-TargetResource RecycleThreshold = $serviceApp.RecycleProcessThreshold DisableBinaryFileScan = $serviceApp.DisableBinaryFileScan ConversionProcesses = $serviceApp.TotalActiveProcesses - JobConversionFrequency = $serviceApp.TimerJobFrequency + JobConversionFrequency = $serviceApp.TimerJobFrequency.TotalMinutes NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout.TotalMinutes MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts @@ -189,7 +189,7 @@ function Set-TargetResource $wordAutomationTimerjob = Get-SPTimerJob $params.Name if ($wordAutomationTimerjob.Count -eq 1) { $schedule = "every $($params.JobConversionFrequency) minutes between 0 and 0" - Set-SPTimerJob $job -Schedule $schedule + Set-SPTimerJob $wordAutomationTimerjob -Schedule $schedule } else { throw "Timerjob could not be found" } @@ -221,7 +221,7 @@ function Set-TargetResource $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue | Where-Object { $_.TypeName -eq "Word Automation Services" } if ($null -ne $serviceApp) { # Service app existed, deleting - Remove-SPServiceApplication $params.Name -RemoveData -Confirm:$false + Remove-SPServiceApplication $serviceApp -RemoveData -Confirm:$false } } } @@ -263,7 +263,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters } Export-ModuleMember -Function *-TargetResource From f5c3bab50e43a6026d2881ce6601ddc6b1e91b59 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sun, 17 Jan 2016 15:11:04 +0100 Subject: [PATCH 34/91] Created Pester tests and fixed bugs that were found by the tests --- .../MSFT_xSPWordAutomationServiceApp.psm1 | 10 +- ...SFT_xSPWordAutomationServiceApp.schema.mof | 2 +- ...oint.xSPWordAutomationServiceApp.Tests.ps1 | 271 +++++++++++++++++- 3 files changed, 272 insertions(+), 11 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 index 5ba3297b1..501488535 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1 @@ -31,6 +31,10 @@ function Get-TargetResource throw "You cannot use any of the parameters when Ensure is specified as Absent" } + if (($Ensure -eq "Present") -and -not ($ApplicationPool -and $DatabaseName)) { + throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] @@ -121,7 +125,7 @@ function Set-TargetResource throw "You cannot use any of the parameters when Ensure is specified as Absent" } - if (($Ensure -eq "Absent") -and ($ApplicationPool -and $DatabaseName)) { + if (($Ensure -eq "Present") -and -not ($ApplicationPool -and $DatabaseName)) { throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" } @@ -259,6 +263,10 @@ function Test-TargetResource throw "You cannot use any of the parameters when Ensure is specified as Absent" } + if (($Ensure -eq "Present") -and -not ($ApplicationPool -and $DatabaseName)) { + throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + Write-Verbose -Message "Testing for Word Automation Service Application '$Name'" $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof index dd7ad2e17..29d27c598 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof @@ -23,7 +23,7 @@ Make sure the service application exists and has a specific configuration ConversionProcesses = 8 JobConversionFrequency = 15 NumberOfConversionsPerProcess = 12 - TimeBeforeConversionIsMonitored = 5 + TimeBeforeConversionIsMonitored = 5 MaximumConversionAttempts = 2 MaximumSyncConversionRequests = 25 KeepAliveTimeout = 30 diff --git a/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 index 34502df4c..d6f214559 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 @@ -15,9 +15,24 @@ Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName Describe "xSPWordAutomationServiceApp" { InModuleScope $ModuleName { $testParams = @{ - Name = "Test Word App" - ApplicationPool = "Test App Pool" - DatabaseName = "WordAutomationn" + Name = "Word Automation Service Application" + Ensure = "Present" + ApplicationPool = "SharePoint Web Services" + DatabaseName = "WordAutomation_DB" + DatabaseServer = "SQLServer" + SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleThreshold = 100 + DisableBinaryFileScan = $false + ConversionProcesses = 8 + JobConversionFrequency = 15 + NumberOfConversionsPerProcess = 12 + TimeBeforeConversionIsMonitored = 5 + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 + MaximumConversionTime = 300 } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -27,10 +42,45 @@ Describe "xSPWordAutomationServiceApp" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - Context "When no service applications exist in the current farm" { + Context "When no service applications exist in the current farm and Ensure is set to Present" { Mock Get-SPServiceApplication { return $null } - Mock New-SPWordConversionServiceApplication { } + Mock New-SPWordConversionServiceApplication { + $returnval = @(@{ + WordServiceFormats = @{ + OpenXmlDocument = $false + Word972003Document = $true + RichTextFormat = $true + WebPage = $true + Word2003Xml = $true + } + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleProcessThreshold = 100 + DisableBinaryFileScan = $false + TotalActiveProcesses = 8 + TimerJobFrequency = 15 + ConversionsPerInstance = 12 + ConversionTimeout = 5 + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 + MaximumConversionTime = 300 + }) + $returnVal = $returnVal | Add-Member ScriptMethod Update { $Global:xSharePointSiteUseUpdated = $true } -PassThru + return $returnval + } + Mock Get-SPServiceApplicationPool { + return @(@{ + Name = $testParams.ApplicationPool + }) + } + + Mock Get-SPTimerJob { + $returnval = @(@{ Name = "Just a name" }) + return ,$returnval + } + Mock Set-SPTimerJob {} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty @@ -41,12 +91,23 @@ Describe "xSPWordAutomationServiceApp" { Test-TargetResource @testParams | Should Be $false } + $Global:xSharePointSiteUseUpdated = $false It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPWordConversionServiceApplication + $Global:xSharePointSiteUseUpdated | Should Be $true } } + Context "When no service applications exist in the current farm and Ensure is set to Present, but the Application Pool does not exist" { + Mock Get-SPServiceApplication { return $null } + Mock Get-SPServiceApplicationPool { return $null } + + It "fails to create a new service application in the set method because the specified application pool is missing" { + { Set-TargetResource @testParams } | Should throw "Specified application pool does not exist" + } + } + Context "When service applications exist in the current farm but the specific word automation app does not" { Mock Get-SPServiceApplication { return @(@{ @@ -65,12 +126,34 @@ Describe "xSPWordAutomationServiceApp" { TypeName = "Word Automation Services" DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } + Database = @{ + Name = $testParams.DatabaseName + Server = @{ Name = $testParams.DatabaseServer } + } + WordServiceFormats = @{ + OpenXmlDocument = $true + Word972003Document = $true + RichTextFormat = $true + WebPage = $true + Word2003Xml = $true + } + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleProcessThreshold = 100 + DisableBinaryFileScan = $false + TotalActiveProcesses = 8 + TimerJobFrequency = @{ TotalMinutes = 15 } + ConversionsPerInstance = 12 + ConversionTimeout = @{ TotalMinutes = 5 } + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = @{ TotalSeconds = 30 } + MaximumConversionTime = @{ TotalSeconds = 300 } }) } It "returns values from the get method" { Get-TargetResource @testParams | Should Not BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } } It "returns true when the Test method is called" { @@ -78,26 +161,196 @@ Describe "xSPWordAutomationServiceApp" { } } - Context "When a service application exists and is not configured correctly" { + Context "When a service application exists and incorrect application pool is configured" { Mock Get-SPServiceApplication { - return @(@{ + $returnval = @(@{ TypeName = "Word Automation Services" DisplayName = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } + WordServiceFormats = @{ + OpenXmlDocument = $false + Word972003Document = $true + RichTextFormat = $true + WebPage = $true + Word2003Xml = $true + } + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleProcessThreshold = 100 + DisableBinaryFileScan = $false + TotalActiveProcesses = 8 + TimerJobFrequency = 15 + ConversionsPerInstance = 12 + ConversionTimeout = 5 + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 + MaximumConversionTime = 300 }) + $returnVal = $returnVal | Add-Member ScriptMethod Update { $Global:xSharePointSiteUseUpdated = $true } -PassThru + return $returnval } + Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } } - Mock Set-SPWordConversionServiceApplication {} + Mock Set-SPWordConversionServiceApplication {} + + Mock Get-SPTimerJob { + $returnval = @(@{ Name = "Just a name" }) + return ,$returnval + } + Mock Set-SPTimerJob {} + It "returns false when the Test method is called" { Test-TargetResource @testParams | Should Be $false } + $Global:xSharePointSiteUseUpdated = $false It "calls the update service app cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Get-SPServiceApplicationPool Assert-MockCalled Set-SPWordConversionServiceApplication + $Global:xSharePointSiteUseUpdated | Should Be $true } } + + Context "When a service application exists and incorrect settings are configured" { + Mock Get-SPServiceApplication { + $returnval = @(@{ + TypeName = "Word Automation Services" + DisplayName = $testParams.Name + ApplicationPool = @{ Name = $testParams.ApplicationPool } + WordServiceFormats = @{ + OpenXmlDocument = $false + Word972003Document = $true + RichTextFormat = $true + WebPage = $true + Word2003Xml = $true + } + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleProcessThreshold = 100 + DisableBinaryFileScan = $false + TotalActiveProcesses = 8 + TimerJobFrequency = 15 + ConversionsPerInstance = 12 + ConversionTimeout = 5 + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 + MaximumConversionTime = 300 + }) + $returnVal = $returnVal | Add-Member ScriptMethod Update { $Global:xSharePointSiteUseUpdated = $true } -PassThru + return $returnval + } + + Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } } + Mock Set-SPWordConversionServiceApplication {} + + Mock Get-SPTimerJob { + $returnval = @(@{ Name = "Just a name" }) + return ,$returnval + } + Mock Set-SPTimerJob {} + + It "returns false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + $Global:xSharePointSiteUseUpdated = $false + It "calls the update service app cmdlet from the set method" { + Set-TargetResource @testParams + Assert-MockCalled Get-SPServiceApplication + $Global:xSharePointSiteUseUpdated | Should Be $true + } + } + + Context "When no service application exists and Ensure is set to Absent" { + $testParams = @{ + Name = "Word Automation Service Application" + Ensure = "Absent" + } + + Mock Get-SPServiceApplication { return $null } + + It "returns values from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "returns true when the Test method is called" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "When a service application exists and Ensure is set to Absent" { + $testParams = @{ + Name = "Word Automation Service Application" + Ensure = "Absent" + } + + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Word Automation Services" + DisplayName = $testParams.Name + }) + } + Mock Remove-SPServiceApplication { } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "should return false when the Test method is called" { + Test-TargetResource @testParams | Should Be $false + } + + It "should call the update service app cmdlet from the set method" { + Set-TargetResource @testParams + Assert-MockCalled Remove-SPServiceApplication + } + } + + Context "When Ensure is set to Absent, but another parameter is also used" { + $testParams = @{ + Name = "Word Automation Service Application" + Ensure = "Absent" + ApplicationPool = "SharePoint Web Services" + } + + It "should return null from the get method" { + { Get-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" + } + + It "should return false from the test method" { + { Test-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" + } + } + + Context "When Ensure is set to Present, but the Application Pool or Database parameters are missing" { + $testParams = @{ + Name = "Word Automation Service Application" + Ensure = "Present" + ApplicationPool = "SharePoint Web Services" + } + + It "should return null from the get method" { + { Get-TargetResource @testParams } | Should throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + + It "should return false from the test method" { + { Test-TargetResource @testParams } | Should throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "An Application Pool and Database Name are required to configure the Word Automation Service Application" + } + } + } } From 0cef9601f5c56daaf3d29bddba947bb30b8ad9f3 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sun, 17 Jan 2016 16:49:33 +0100 Subject: [PATCH 35/91] Updated Readme.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fefef925e..1c7474480 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,9 @@ Additional detailed documentation is included on the wiki on GitHub. ## Version History +### Unreleased + * Added xSPWordAutomationServiceApp resources + ### 0.9.0.0 * Added xSPAppCatalog, xSPAppDomain, xSPWebApplicationAppDomain, xSPSessionStateService, xSPDesignerSettings, xSPQuotaTemplate, xSPWebAppSiteUseAndDeletion, xSPSearchTopology, xSPSearchIndexPartition, xSPWebAppPolicy and xSPTimerJobState resources From 50f973294957541daf3377b7de785a8e02f719a1 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sun, 17 Jan 2016 19:37:06 +0100 Subject: [PATCH 36/91] Updated description in mof file --- .../MSFT_xSPWordAutomationServiceApp.schema.mof | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof index 29d27c598..6736e911b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof @@ -1,8 +1,12 @@ /* **Description** -The resource will provision and configure the Word Automation Service Application. -The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. +The resource is able to provision, unprovision and configure the Word Automation Service Application. +All settings that you can configure on the Service Application administration page are configurable using this resource. + +Important: +When you specify Ensure=Present, the Application Pool and DatabaseName parameters are required. +When you specify Ensure=Absent, no other parameters are allowed (with the exception of Name, InstallAccount or PsDscRunAsCredential). **Example** @@ -21,13 +25,13 @@ Make sure the service application exists and has a specific configuration RecycleThreshold = 100 DisableBinaryFileScan = $false ConversionProcesses = 8 - JobConversionFrequency = 15 + JobConversionFrequency = 15 (in minutes) NumberOfConversionsPerProcess = 12 - TimeBeforeConversionIsMonitored = 5 + TimeBeforeConversionIsMonitored = 5 (in minutes) MaximumConversionAttempts = 2 MaximumSyncConversionRequests = 25 - KeepAliveTimeout = 30 - MaximumConversionTime = 300 + KeepAliveTimeout = 30 (in seconds) + MaximumConversionTime = 300 (in seconds) PsDscRunAsCredential = $InstallAccount } From baab88a190fd24ca12922ba5a253504846bb3e25 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sun, 17 Jan 2016 20:04:18 +0100 Subject: [PATCH 37/91] Added help file --- ...about_xSPWordAutomationServiceApp.help.txt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt diff --git a/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt new file mode 100644 index 000000000..933d67d21 --- /dev/null +++ b/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt @@ -0,0 +1,68 @@ +NAME + xSPWordAutomationServiceApp + +PARAMETERS + Name (Key, string) + Ensure (Required, string) - Values "Present", "Absent" + ApplicationPool (Write, string) + DatabaseName (Write, string) + DatabaseServer (Write, string) + SupportedFileFormats (Write, string[]) - Values docx", "doc", "mht", "rtf", "xml" + DisableEmbeddedFonts (Write, boolean) + MaximumMemoryUsage (Write, uint32) + RecycleThreshold (Write, uint32) + DisableBinaryFileScan (Write, boolean) + ConversionProcesses (Write, uint32) + JobConversionFrequency (Write, uint32) + NumberOfConversionsPerProcess (Write, uint32) + TimeBeforeConversionIsMonitored (Write, uint32) + MaximumConversionAttempts (Write, uint32) + MaximumSyncConversionRequests (Write, uint32) + KeepAliveTimeout (Write, uint32) + MaximumConversionTime (Write, uint32) + InstallAccount (Write, string) + +DESCRIPTION + +The resource is able to provision, unprovision and configure the Word Automation Service Application. +All settings that you can configure on the Service Application administration page are configurable using this resource. + +Important: +When you specify Ensure=Present, the Application Pool and DatabaseName parameters are required. +When you specify Ensure=Absent, no other parameters are allowed (with the exception of Name, InstallAccount or PsDscRunAsCredential). + +EXAMPLE + +Make sure the service application exists and has a specific configuration + + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Present" + ApplicationPool = "SharePoint Web Services" + DatabaseName = "WordAutomation_DB" + DatabaseServer = "SQLServer" + SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleThreshold = 100 + DisableBinaryFileScan = $false + ConversionProcesses = 8 + JobConversionFrequency = 15 (in minutes) + NumberOfConversionsPerProcess = 12 + TimeBeforeConversionIsMonitored = 5 (in minutes) + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 (in seconds) + MaximumConversionTime = 300 (in seconds) + PsDscRunAsCredential = $InstallAccount + } + +Make sure the service application does not exist and remove when it does + + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Absent" + PsDscRunAsCredential = $InstallAccount + } From 8781d1c65f6ee1427bd979c21e4d9b06716886d1 Mon Sep 17 00:00:00 2001 From: Andy Cox Date: Wed, 20 Jan 2016 14:11:48 +0000 Subject: [PATCH 38/91] Fixed typo. --- Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 b/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 index 066e2959b..0967849cf 100644 --- a/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 +++ b/Modules/xSharePoint/Examples/Small Farm/SharePoint.psd1 @@ -69,7 +69,7 @@ WebApplications = @( @{ Name = "SharePoint Sites" - DatabaeName = "SP_Content_01" + DatabaseName = "SP_Content_01" Url = "http://sites.sharepoint.contoso.local" Authentication = "NTLM" Anonymous = $false From d282ec2b9f0abadc58e4be80410d75e8bc580bdb Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 21 Jan 2016 21:20:58 +0100 Subject: [PATCH 39/91] First draft of xSPShellAdmins resource --- .../MSFT_xSPShellAdmins.psm1 | 269 ++++++++++++++++++ .../MSFT_xSPShellAdmins.schema.mof | 29 ++ Modules/xSharePoint/xSharePoint.pssproj | 3 + 3 files changed, 301 insertions(+) create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 create mode 100644 Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 new file mode 100644 index 000000000..e718c87ec --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -0,0 +1,269 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + + Write-Verbose -Message "Getting all Shell Admins" + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $shellAdmins = Get-SPShellAdmin + $allContentDatabases = $true + + if ($params.AllContentDatabases) { + if ($params.Members) { + # Check if the members are configured on all databases + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + foreach ($member in $params.Members) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + $allContentDatabases = $false + } + } + } + } + + if ($params.MembersToInclude) { + # Check if the members are configured on all databases + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + foreach ($member in $params.MembersToInclude) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + $allContentDatabases = $false + } + } + } + } + + if ($params.MembersToExclude) { + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + foreach ($member in $params.MembersToExclude) { + if ($dbShellAdmins.UserName.Contains($member)) { + $allContentDatabases = $false + } + } + } + } + } else { + $allContentDatabases = $false + } + + return @{ + Name = $params.Name + Members = $shellAdmins.UserName + MembersToInclude = $params.MembersToInclude + MembersToExclude = $params.MembersToExclude + AllContentDatabases = $allContentDatabases + InstallAccount = $params.InstallAccount + } + } + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Setting Shell Admin config" + + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + + $shellAdmins = Get-SPShellAdmin + + if ($params.Members) { + $differences = Compare-Object -ReferenceObject $shellAdmins.UserName -DifferenceObject $params.Members + + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches. No further processing required" + } else { + Write-Verbose "Shell Admins group does not match. Perform corrective action" + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -UserName $user + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -UserName $user -Confirm:$false + } + } + } + + if ($params.AllContentDatabases) { + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + + $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members + + if ($differences -eq $null) { + Write-Verbose "Shell Admins for database $($contentDatabase.Name) group matches. No further processing required" + } else { + Write-Verbose "Shell Admins for database $($contentDatabase.Name) group does not match. Perform corrective action" + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -UserName $user -Database $contentDatabase.Id + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -UserName $user -Database $contentDatabase.Id -Confirm:$false + } + } + } + } + } + } + + if ($params.MembersToInclude) { + foreach ($member in $params.MembersToInclude) { + if (-not $shellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member + } + + if ($params.AllContentDatabases) { + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + if (-not $dbShellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member -Database $contentDatabase.Id + } + } + } + } + } + + if ($params.MembersToExclude) { + foreach ($member in $params.MembersToInclude) { + if ($shellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -UserName $member -Confirm:$false + } + + if ($params.AllContentDatabases) { + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + if ($dbShellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -UserName $member -Database $contentDatabase.Id -Confirm:$false + } + } + } + } + } + } +} + + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [parameter(Mandatory = $true)] [System.String] $Name, + [parameter(Mandatory = $false)] [System.String[]] $Members, + [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, + [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + ) + + Write-Verbose -Message "Testing Farm Administrator settings" + + if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { + Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + + $CurrentValues = Get-TargetResource @PSBoundParameters + + if ($null -eq $CurrentValues) { return $false } + + if ($CurrentValues.AllContentDatabases -eq $AllContentDatabases) { + if ($Members) { + Write-Verbose "Processing Members parameter" + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members + + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches" + return $true + } else { + Write-Verbose "Shell Admins group does not match" + return $false + } + } + + $result = $true + if ($MembersToInclude) { + Write-Verbose "Processing MembersToInclude parameter" + ForEach ($member in $MembersToInclude) { + if (-not($CurrentValues.Members.Contains($member))) { + Write-Verbose "$member is not a Shell Admin. Set result to false" + $result = $false + } else { + Write-Verbose "$member is already a Shell Admin. Skipping" + } + } + } + + if ($MembersToExclude) { + Write-Verbose "Processing MembersToExclude parameter" + ForEach ($member in $MembersToExclude) { + if ($CurrentValues.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + $result = $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } + } + } + + return $result + } else { + return $false + } +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof new file mode 100644 index 000000000..3a30fe8e5 --- /dev/null +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof @@ -0,0 +1,29 @@ +/* +**Description** + +This resource is used to manage the users with Shell Admin permissions. +There are a number of approaches to how this can be implemented. +The "Members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. +The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. + +**Example** + + xSPShellAdmins ShellAdmins + { + Name = "Shell Admins" + Members = "CONTOSO\user1", "CONTOSO\user2" + AllContentDatabases = $true + } +*/ + +[ClassVersion("1.0.0.0"), FriendlyName("xSPShellAdmins")] +class MSFT_xSPShellAdmins : OMI_BaseResource +{ + [Key] String Name; + [Write] String Members[]; + [Write] String MembersToInclude[]; + [Write] String MembersToExclude[]; + [Write] Boolean AllContentDatabases; + [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; + diff --git a/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj index 60a700e88..b96ac0a63 100644 --- a/Modules/xSharePoint/xSharePoint.pssproj +++ b/Modules/xSharePoint/xSharePoint.pssproj @@ -95,6 +95,7 @@ + @@ -104,6 +105,7 @@ + @@ -190,6 +192,7 @@ + From 4aaa1b0782f99c9dbcc0f2d9c96ed85792296de7 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 23 Jan 2016 12:47:50 +1100 Subject: [PATCH 40/91] Removed help files from dev, they are generated and pushed in to release builds only --- .../en-US/about_xSPAntivirusSettings.help.txt | 28 -------- .../en-US/about_xSPAppCatalog.help.txt | 21 ------ .../en-US/about_xSPAppDomain.help.txt | 24 ------- .../about_xSPAppManagementServiceApp.help.txt | 27 -------- .../en-US/about_xSPBCSServiceApp.help.txt | 28 -------- .../en-US/about_xSPCacheAccounts.help.txt | 23 ------- .../en-US/about_xSPCreateFarm.help.txt | 38 ---------- .../en-US/about_xSPDesignerSettings.help.txt | 45 ------------ ...bout_xSPDiagnosticLoggingSettings.help.txt | 54 --------------- .../about_xSPDistributedCacheService.help.txt | 30 -------- .../about_xSPFarmAdministrators.help.txt | 25 ------- .../en-US/about_xSPFeature.help.txt | 27 -------- .../en-US/about_xSPInstall.help.txt | 37 ---------- .../en-US/about_xSPInstallPrereqs.help.txt | 69 ------------------- .../en-US/about_xSPJoinFarm.help.txt | 26 ------- .../en-US/about_xSPManagedAccount.help.txt | 26 ------- ...bout_xSPManagedMetaDataServiceApp.help.txt | 27 -------- .../en-US/about_xSPManagedPath.help.txt | 28 -------- .../about_xSPOutgoingEmailSettings.help.txt | 28 -------- .../about_xSPPasswordChangeSettings.help.txt | 27 -------- .../en-US/about_xSPQuotaTemplate.help.txt | 29 -------- .../about_xSPSearchIndexPartition.help.txt | 35 ---------- .../en-US/about_xSPSearchServiceApp.help.txt | 27 -------- .../en-US/about_xSPSearchTopology.help.txt | 42 ----------- .../about_xSPSecureStoreServiceApp.help.txt | 34 --------- .../en-US/about_xSPServiceAppPool.help.txt | 22 ------ .../en-US/about_xSPServiceInstance.help.txt | 29 -------- .../about_xSPSessionStateService.help.txt | 26 ------- .../xSharePoint/en-US/about_xSPSite.help.txt | 38 ---------- .../en-US/about_xSPStateServiceApp.help.txt | 24 ------- ...xSPSubscriptionSettingsServiceApp.help.txt | 27 -------- .../en-US/about_xSPTimerJobState.help.txt | 38 ---------- .../en-US/about_xSPUsageApplication.help.txt | 32 --------- .../about_xSPUserProfileServiceApp.help.txt | 40 ----------- .../about_xSPUserProfileSyncService.help.txt | 26 ------- .../en-US/about_xSPVisioServiceApp.help.txt | 18 ----- .../about_xSPWebAppBlockedFileTypes.help.txt | 30 -------- .../about_xSPWebAppGeneralSettings.help.txt | 39 ----------- .../en-US/about_xSPWebAppPolicy.help.txt | 24 ------- ...about_xSPWebAppSiteUseAndDeletion.help.txt | 28 -------- ...about_xSPWebAppThrottlingSettings.help.txt | 42 ----------- .../about_xSPWebAppWorkflowSettings.help.txt | 26 ------- .../en-US/about_xSPWebApplication.help.txt | 38 ---------- .../about_xSPWebApplicationAppDomain.help.txt | 31 --------- 44 files changed, 1383 deletions(-) delete mode 100644 Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPFeature.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPInstall.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSite.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPUserProfileServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPUserProfileSyncService.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt delete mode 100644 Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt diff --git a/Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt deleted file mode 100644 index 36c109a8e..000000000 --- a/Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt +++ /dev/null @@ -1,28 +0,0 @@ -NAME - xSPAntivirusSettings - -PARAMETERS - ScanOnDownload (Key, Boolean) - ScanOnUpload (Write, Boolean) - AllowDownloadInfected (Write, Boolean) - AttemptToClean (Write, Boolean) - TimeoutDuration (Write, Uint16) - NumberOfThreads (Write, Uint16) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to set the global antivirus settings for the local farm. -These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. -Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. - -EXAMPLE - - xSPAntivirusSettings AVSettings - { - ScanOnDownload = $true - ScanOnUpload = $true - AllowDownloadInfected = $false - AttemptToClean = $false - } - diff --git a/Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt b/Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt deleted file mode 100644 index 2517b9435..000000000 --- a/Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt +++ /dev/null @@ -1,21 +0,0 @@ -NAME - xSPAppCatalog - -PARAMETERS - SiteUrl (Key, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource will ensure that a specific site collection is marked as the app catalog for the web application that the site is in. -The catalog site needs to have been created using the correct template (APPCATALOG#0). - -EXAMPLE - - xSPAppCatalog MainAppCatalog - { - SiteUrl = "https://content.sharepoint.contoso.com/sites/AppCatalog" - PsDscRunAsCredential = $SPSetupAccount - } - - diff --git a/Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt b/Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt deleted file mode 100644 index 0c0fb216e..000000000 --- a/Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt +++ /dev/null @@ -1,24 +0,0 @@ -NAME - xSPAppDomain - -PARAMETERS - AppDomain (Key, string) - Prefix (Required, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource will set the value for the app domain settings at the farm level. -You can set the domain name and the prefix that is to be used for app URLs. - - -EXAMPLE - - xSPAppDomain LocalFarmAppUrls - { - AppDomain = "contosointranetapps.com" - Prefix = "app" - PsDscRunAsCredential = $InstallAccount - } - - diff --git a/Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt deleted file mode 100644 index 907b721de..000000000 --- a/Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPAppManagementServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, String) - DatabaseName (Write, string) - DatabaseServer (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to provision and manage an instance of the App Management Services Service Application. -It will identify an instance of the app management service application through the application display name. -Currently the resource will provision the app if it does not yet exist, and will change the application pool associated to the app if it does not match the configuration. -Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. - -EXAMPLE - - xSPAppManagementServiceApp AppManagementServiceApp - { - Name = "App Management Service Application" - AppPool = "SharePoint web services" - DatabaseServer = "SQL01.contoso.com" - DatabaseName = "SP_ManagedMetadata" -} - diff --git a/Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt deleted file mode 100644 index 1ae922739..000000000 --- a/Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt +++ /dev/null @@ -1,28 +0,0 @@ -NAME - xSPBCSServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, String) - DatabaseName (Write, string) - DatabaseServer (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to provision and manage an instance of the Business Connectivity Services Service Application. -It will identify an instance of the BCS app through the application display name. -Currently the resource will provision the app if it does not yet exist, and will change the service account associated to the app if it does not match the configuration. -Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. - -EXAMPLE - - xSPBCSServiceApp BCSServiceApp - { - Name = "BCS Service Application" - ApplicationPool = "SharePoint Service Applications" - DatabaseName = "SP_BCS" - DatabaseServer = $DatabaseServer - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt b/Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt deleted file mode 100644 index ff8f5448e..000000000 --- a/Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt +++ /dev/null @@ -1,23 +0,0 @@ -NAME - xSPCacheAccounts - -PARAMETERS - WebAppUrl (Key, string) - SuperUserAlias (Required, string) - SuperReaderAlias (Required, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to set the "super user" and "super reader" cache accounts for the specified web application object (as described in the TechNet article [Configure object cache user accounts in SharePoint Server 2013](https://technet.microsoft.com/en-us/library/ff758656.aspx)). - -EXAMPLE - - xSPCacheAccounts SetCacheAccounts - { - WebAppUrl = "http://sharepoint.contoso.com" - SuperUserAlias = "DEMO\svcSPSuperUser" - SuperReaderAlias = "DEMO\svcSPReader" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt b/Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt deleted file mode 100644 index 3a963643f..000000000 --- a/Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt +++ /dev/null @@ -1,38 +0,0 @@ -NAME - xSPCreateFarm - -PARAMETERS - FarmConfigDatabaseName (Key, String) - DatabaseServer (Key, String) - FarmAccount (Required, String) - InstallAccount (Write, String) - Passphrase (Required, String) - AdminContentDatabaseName (Required, String) - CentralAdministrationPort (Write, uint32) - ServerRole (Write, string, Allowed values: Application, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, SpecialLoad, WebFrontEnd) - -DESCRIPTION - -This resource is used to provision a new SharePoint farm. -It should only be used on the first server in the farm to create the configuration database, all servers to join the farm after the first server creates the configuration database should use [xSPJoinFarm](xSPJoinFarm). -Once the config DB has been created, the resource will install local help collections, secure resources, activate features and provision the central admin site. - -The port of the Central Admin website can be set by using the CentralAdministrationPort property, if this is not defined the site will be provisioned on port 9999. -However this setting will not impact existing deployments that already have Central Admin provisioned on another port. -Also when a farm is created, the current behavior is to not enroll the server as a cache server (which is the default behavior of SharePoint). -This means you need to use [xSPDistributedCacheService](xSPDistributedCacheService) on at least one server in the farm to designate it as a cache server. - -EXAMPLE - - xSPCreateFarm CreateSPFarm - { - DatabaseServer = "SQL.contoso.local\SQLINSTANCE" - FarmConfigDatabaseName = "SP_Config" - Passphrase = "Example Passphrase" - FarmAccount = $FarmAccount - PsDscRunAsCredential = $SetupAccount - AdminContentDatabaseName = "SP_AdminContent" - CentralAdministrationPort = 2000 - ServerRole = Custom - } - diff --git a/Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt deleted file mode 100644 index 3f633ae0a..000000000 --- a/Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt +++ /dev/null @@ -1,45 +0,0 @@ -NAME - xSPDesignerSettings - -PARAMETERS - Url (Key, string) - SettingsScope (Required, string, Allowed values: WebApplication, SiteCollection) - AllowSharePointDesigner (Write, Boolean) - AllowDetachPagesFromDefinition (Write, Boolean) - AllowCustomiseMasterPage (Write, Boolean) - AllowManageSiteURLStructure (Write, Boolean) - AllowCreateDeclarativeWorkflow (Write, Boolean) - AllowSavePublishDeclarativeWorkflow (Write, Boolean) - AllowSaveDeclarativeWorkflowAsTemplate (Write, Boolean) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to set the SharePoint Designer settings for the local farm or site collections. -These settings will be used to control if users are allowed to make changes using SharePoint Designer. -Note that this will not prevent users from installing SharePoint Designer, just from using SharePoint Designer to connect to the farm. - -Settings can be applied against an entire web application, or a specific site collection. -Use the "SettingsScope" property to set it to either "WebApplication" or "SiteCollection" to define which you are targetting. - -Known issue: -When using PowerShell v4 or PowerShell v5 with the InstallAccount switch (instead of PsDscRunAsCredential), you cannot use the SettingsScope "SiteCollection". -Due to an issue with Remote PowerShell and SharePoint, changing the Site Collection settings results in an Access Denied error. -Consider implementing PowerShell v5 and switching to the PsDscRunAsCredential configuration. - -EXAMPLE - - xSPDesignerSettings MainWebAppSPDSettings - { - Url = "https://intranet.sharepoint.contoso.com" - SettingsScope = "WebApplication" - AllowSharePointDesigner = $false - AllowDetachPagesFromDefinition = $false - AllowCustomiseMasterPage = $false - AllowManageSiteURLStructure = $false - AllowCreateDeclarativeWorkflow = $false - AllowSavePublishDeclarativeWorkflow = $false - AllowSaveDeclarativeWorkflowAsTemplate = $false - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt deleted file mode 100644 index e7aed4e26..000000000 --- a/Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt +++ /dev/null @@ -1,54 +0,0 @@ -NAME - xSPDiagnosticLoggingSettings - -PARAMETERS - LogPath (Key, string) - LogSpaceInGB (Required, uint32) - AppAnalyticsAutomaticUploadEnabled (Write, boolean) - CustomerExperienceImprovementProgramEnabled (Write, boolean) - DaysToKeepLogs (Write, uint32) - DownloadErrorReportingUpdatesEnabled (Write, boolean) - ErrorReportingAutomaticUploadEnabled (Write, boolean) - ErrorReportingEnabled (Write, boolean) - EventLogFloodProtectionEnabled (Write, boolean) - EventLogFloodProtectionNotifyInterval (Write, uint32) - EventLogFloodProtectionQuietPeriod (Write, uint32) - EventLogFloodProtectionThreshold (Write, uint32) - EventLogFloodProtectionTriggerPeriod (Write, uint32) - LogCutInterval (Write, uint32) - LogMaxDiskSpaceUsageEnabled (Write, boolean) - ScriptErrorReportingDelay (Write, uint32) - ScriptErrorReportingEnabled (Write, boolean) - ScriptErrorReportingRequireAuth (Write, boolean) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for configuring settings to do with the diagnostic (ULS) logging on servers in the farm. -These settings are applied to the diagnostic logging service for the farm and do not need to be applied to each server individually, the settings will be propagated throughout the farm when they are set. - -EXAMPLE - - xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings - { - PsDscRunAsCredential = $InstallAccount - LogPath = "L:\ULSLogs" - LogSpaceInGB = 10 - AppAnalyticsAutomaticUploadEnabled = $false - CustomerExperienceImprovementProgramEnabled = $true - DaysToKeepLogs = 7 - DownloadErrorReportingUpdatesEnabled = $false - ErrorReportingAutomaticUploadEnabled = $false - ErrorReportingEnabled = $false - EventLogFloodProtectionEnabled = $true - EventLogFloodProtectionNotifyInterval = 5 - EventLogFloodProtectionQuietPeriod = 2 - EventLogFloodProtectionThreshold = 5 - EventLogFloodProtectionTriggerPeriod = 2 - LogCutInterval = 15 - LogMaxDiskSpaceUsageEnabled = $true - ScriptErrorReportingDelay = 30 - ScriptErrorReportingEnabled = $true - ScriptErrorReportingRequireAuth = $true - } - diff --git a/Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt b/Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt deleted file mode 100644 index 8801f477f..000000000 --- a/Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt +++ /dev/null @@ -1,30 +0,0 @@ -NAME - xSPDistributedCacheService - -PARAMETERS - Name (Key, String) - Ensure (Required, string, Allowed values: Present, Absent) - CacheSizeInMB (Required, UInt32) - ServiceAccount (Required, String) - InstallAccount (Write, String) - CreateFirewallRules (Required, Boolean) - -DESCRIPTION - -This resource is responsible for provisioning the distributed cache to the service it runs on. -This is required in your farm on at least one server (as the behavior of [xSPCreateFarm](xSPCreateFarm) and [xSPJoinFarm](xSPJoinFarm) is to not enroll every server as a cache server). -The service will be provisioned or de-provisioned based on the Ensure property, and when provisioned the CacheSizeInMB property and ServiceAccount property will be used to configure it. -The property createFirewallRules is used to determine if exceptions should be added to the windows firewall to allow communication between servers on the appropriate ports. - -EXAMPLE - - xSPDistributedCacheService EnableDistributedCache - { - Name = "AppFabricCachingService" - Ensure = "Present" - CacheSizeInMB = 8192 - ServiceAccount = "DEMO\ServiceAccount" - InstallAccount = $InstallAccount - CreateFirewallRules = $true - } - diff --git a/Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt b/Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt deleted file mode 100644 index aa03f07b8..000000000 --- a/Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt +++ /dev/null @@ -1,25 +0,0 @@ -NAME - xSPFarmAdministrators - -PARAMETERS - Name (Key, String) - Members[] (Write, String) - MembersToInclude[] (Write, String) - MembersToExclude[] (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to manage the membership of the farm administrators group. -There are a number of approaches to how this can be implemented. -The "members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. -The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. - -EXAMPLE - - xSPFarmAdministrators LocalFarmAdmins - { - Name = "Farm Administrators" - Members = @("CONTOSO\user1", "CONTOSO\user2") - } - diff --git a/Modules/xSharePoint/en-US/about_xSPFeature.help.txt b/Modules/xSharePoint/en-US/about_xSPFeature.help.txt deleted file mode 100644 index 819300593..000000000 --- a/Modules/xSharePoint/en-US/about_xSPFeature.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPFeature - -PARAMETERS - Name (Key, string) - FeatureScope (Required, string, Allowed values: Farm, WebApplication, Site, Web) - Url (Key, string) - InstallAccount (Write, String) - Ensure (Required, string, Allowed values: Present, Absent) - -DESCRIPTION - -This resource is used to make sure that a specific feature is either enabled or disabled at a given URL/scope. -The Ensure property will dictate if the feature should be on or off. -The name property is the name of the feature based on its folder name in the FEATURES folder in the SharePoint hive directory. - -EXAMPLE - - xSPFeature EnableViewFormsLockDown - { - Name = "ViewFormPagesLockDown" - Url = "http://www.contoso.com" - Ensure = "Present" - Scope = "Site" - PsDscRunAsCredential = $SetupAccuount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPInstall.help.txt b/Modules/xSharePoint/en-US/about_xSPInstall.help.txt deleted file mode 100644 index 11fd1b24d..000000000 --- a/Modules/xSharePoint/en-US/about_xSPInstall.help.txt +++ /dev/null @@ -1,37 +0,0 @@ -NAME - xSPInstall - -PARAMETERS - BinaryDir (Key, String) - ProductKey (Required, String) - Ensure (Required, string, Allowed values: Present, Absent) - -DESCRIPTION - -This resource is used to install the SharePoint binaries. -The BinaryDir parameter should point to the path that setup.exe is located (not to setup.exe itself). -The ProductKey parameter is used to inject in to the configuration file and validate the license key during the installation process. -This module depends on the prerequisites already being installed, which can be done through the use of [xSPInstallPreReqs](xSPInstallPreReqs). - -EXAMPLE - - xSPInstall InstallBinaries - { - BinaryDir = "C:\SPInstall" - ProductKey = $ProductKey - } - -**Installing SharePoint Foundation 2013** - -Currently SharePoint Foundation is not supported by xSPInstall (see [Issue #81](https://github.com/PowerShell/xSharePoint/issues/81) for the details). A workaround for this is to use the package resource as demonstrated below. - - Package InstallSharePointFoundation - { - Ensure = "Present" - Name = "Microsoft SharePoint Foundation 2013 Core" - Path = "E:\SharePoint2013\Setup.exe" - Arguments = "/config E:\SharePoint2013\files\setupfarmsilent\config.xml" - ProductID = "90150000-1014-0000-1000-0000000FF1CE" - ReturnCode = 0 - } - diff --git a/Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt b/Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt deleted file mode 100644 index 2df04ba51..000000000 --- a/Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt +++ /dev/null @@ -1,69 +0,0 @@ -NAME - xSPInstallPrereqs - -PARAMETERS - InstallerPath (Key, String) - OnlineMode (Required, Boolean) - SQLNCli (Write, String) - PowerShell (Write, String) - NETFX (Write, String) - IDFX (Write, String) - Sync (Write, String) - AppFabric (Write, String) - IDFX11 (Write, String) - MSIPCClient (Write, String) - WCFDataServices (Write, String) - KB2671763 (Write, String) - WCFDataServices56 (Write, String) - KB2898850 (Write, String) - MSVCRT11 (Write, String) - MSVCRT14 (Write, String) - KB3092423 (Write, String) - ODBC (Write, String) - DotNet452 (Write, String) - Ensure (Required, string, Allowed values: Present, Absent) - -DESCRIPTION - -This resource is responsible for ensuring the installation of all SharePoint prerequisites. -It makes use of the PrerequisiteInstaller.exe file that is part of the SharePoint binaries, and will install the required Windows features as well as additional software. -The OnlineMode boolean will tell the prerequisite installer which mode to run in, if it is online you do not need to list any other parameters for this resource. -If you do not use online mode, you must include all other parameters to specify where the installation files are located. -These additional parameters map directly to the options passed to prerequisiteinstaller.exe. - -Additionally, the process of installing the prerequisites on a Windows Server usually results in 2-3 restarts of the system being required. To ensure the DSC configuration is able to restart the server when needed, ensure the below settings for the local configuration manager are included in your DSC file. - - LocalConfigurationManager - { - RebootNodeIfNeeded = $true - } - -**Examples** - -Online example: - - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $true - } - -Offline example: - - xSPInstallPrereqs InstallPrerequisites - { - InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" - OnlineMode = $false - SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" - PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" - NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" - IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" - Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" - AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" - IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" - MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" - WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" - KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" - WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt b/Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt deleted file mode 100644 index 5c3151c05..000000000 --- a/Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt +++ /dev/null @@ -1,26 +0,0 @@ -NAME - xSPJoinFarm - -PARAMETERS - FarmConfigDatabaseName (Key, string) - DatabaseServer (Key, string) - InstallAccount (Write, String) - Passphrase (Required, string) - ServerRole (Write, string, Allowed values: Application, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, SpecialLoad, WebFrontEnd) - -DESCRIPTION - -This resource will be responsible for joining a server to an existing SharePoint farm. -To create a new farm use the [xSPCreateFarm](xSPCreateFarm) resource on a different server to begin with, and then pass the same database server and configuration database name parameters to the additional servers using this resource. -After the server has joined the farm, the process will wait for 5 minutes to allow farm specific configuration to take place on the server, before allowing further DSC configuration to take place. - -EXAMPLE - - xSPJoinFarm JoinSPFarm - { - DatabaseServer = $DatabaseServer - FarmConfigDatabaseName = "SP_Config" - Passphrase = $FarmPassPhrase - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt b/Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt deleted file mode 100644 index b9a08d091..000000000 --- a/Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt +++ /dev/null @@ -1,26 +0,0 @@ -NAME - xSPManagedAccount - -PARAMETERS - AccountName (Key, string) - Account (Required, String) - InstallAccount (Write, String) - EmailNotification (Write, Uint32) - PreExpireDays (Write, Uint32) - Schedule (Write, string) - -DESCRIPTION - -This resource will ensure a managed account is provisioned in to the SharePoint farm. -The Account object specific the credential to store (including username and password) to set as the managed account. -The settings for EmailNotification, PreExpireDays and Schedule all relate to enabling automatic password change for the managed account, leaving these option out of the resource will ensure that no automatic password changing from SharePoint occurs. - -EXAMPLE - - xSPManagedAccount WebPoolManagedAccount - { - AccountName = $WebPoolManagedAccount.UserName - Account = $WebPoolManagedAccount - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt deleted file mode 100644 index ddf468d41..000000000 --- a/Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPManagedMetaDataServiceApp - -PARAMETERS - Name (Key, string) - InstallAccount (Write, String) - ApplicationPool (Required, string) - DatabaseServer (Write, string) - DatabaseName (Write, string) - -DESCRIPTION - -Creates a managed metadata service application. -The application pool property specifies which application pool it should use, and will reset the application back to this pool if it is changed after its initial provisioning. -The database server and database name properties are only used during provisioning, and will not be altered as part of the ongoing operation of the DSC resource. - -EXAMPLE - - xSPManagedMetaDataServiceApp ManagedMetadataServiceApp - { - Name = "Managed Metadata Service Application" - InstallAccount = $InstallAccount - ApplicationPool = "SharePoint Service Applications" - DatabaseServer = $DatabaseServer - DatabaseName = "SP_ManagedMetadata" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt b/Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt deleted file mode 100644 index 28e0a61f8..000000000 --- a/Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt +++ /dev/null @@ -1,28 +0,0 @@ -NAME - xSPManagedPath - -PARAMETERS - WebAppUrl (Key, string) - InstallAccount (Write, String) - RelativeUrl (Key, string) - Explicit (Required, boolean) - HostHeader (Required, boolean) - -DESCRIPTION - -This resource is responsible for creating managed paths associated with a specific web application. -The WebAppUrl parameter is used to specify the web application to create the path against, and the RelativeUrl parameter lets you set the URL. -Explicit when set to true will create an explicit inclusion path, if set to false the path is created as wildcard inclusion. -If you are using host named site collections set HostHeader to true and the path will be created as a host header path to be applied for host named site collections. - -EXAMPLE - - xSPManagedPath TeamsManagedPath - { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $InstallAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true - } - diff --git a/Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt deleted file mode 100644 index a04ccfe2c..000000000 --- a/Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt +++ /dev/null @@ -1,28 +0,0 @@ -NAME - xSPOutgoingEmailSettings - -PARAMETERS - WebAppUrl (key, string) - SMTPServer (Required, string) - FromAddress (Required, string) - ReplyToAddress (Required, string) - CharacterSet (Required, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to set the outgoing email settings for either a single web application, or the whole farm. -To configure the resource for a specific web app, use the URL of the web application for the WebAppUrl property, to change the settings for the whole farm use the URL of the central admin website instead. -It is possible to set the outgoing server, from address, reply to address and the character set to be used for emails. - -EXAMPLE - - xSPOutgoingEmailSettings FarmWideEmailSettings - { - WebAppUrl = "http://sharepoint1:2013" - SMTPServer = "smtp.contoso.com" - FromAddress = "sharepoint@contoso.com" - ReplyToAddress = "noreply@contoso.com" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt deleted file mode 100644 index 500f86ecb..000000000 --- a/Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPPasswordChangeSettings - -PARAMETERS - MailAddress (key, string) - DaysBeforeExpiry (Write, Uint32) - PasswordChangeWaitTimeSeconds (Write, Uint32) - NumberOfRetries (Write, Uint32) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to control settings that relate to the automatic changing of passwords for managed accounts (where they opt-in to be managed by SharePoint). -These settings can be manually controlled through central administration, or configured in this resource. -The settings relate to email notifications of when passwords are reset, as well as behavior when a reset occurs such as a time out and number of retries. - -EXAMPLE - - xSPPasswordChangeSettings ManagedAccountPasswordResetSettings - { - MailAddress = "sharepoint@contoso.com" - DaysBeforeExpiry = "14" - PasswordChangeWaitTimeSeconds = "60" - NumberOfRetries = "3" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt b/Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt deleted file mode 100644 index 8e259c1c1..000000000 --- a/Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt +++ /dev/null @@ -1,29 +0,0 @@ -NAME - xSPQuotaTemplate - -PARAMETERS - Name (Key, string) - StorageMaxInMB (Write, uint32) - StorageWarningInMB (Write, uint32) - MaximumUsagePointsSolutions (Write, uint32) - WarningUsagePointsSolutions (Write, uint32) - Ensure (Required, string, Allowed values: Present, Absent) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to configure quota templates in the farm. -These settings will be used to make sure a certain quota template exists or not. When it exists, it will also make sure the settings are configured as specified. - -EXAMPLE - - xSPQuotaTemplate TeamsiteTemplate - { - Name = "Teamsite" - StorageMaxInMB = 1024 - StorageWarningInMB = 512 - MaximumUsagePointsSolutions = 1000 - WarningUsagePointsSolutions = 800 - Ensure = "Present" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt b/Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt deleted file mode 100644 index 9dc88f845..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt +++ /dev/null @@ -1,35 +0,0 @@ -NAME - xSPSearchIndexPartition - -PARAMETERS - Index (Key, Uint32) - Servers[] (Required, String) - RootDirectory (Write, String) - ServiceAppName (Required, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for creating search indexes. -It works by creating the index topology components and updating the topology from the server that runs this resource. -For this reason this resource only needs to run from one server and not from each server which will host the index component. -The search service application and existing search topology must be deployed before creating additional indexes. -The first index will be created through the use of the xSPSearchRoles resource. -Additional search index partitions can be created through using this resource. - -Note that for the search topology to apply correctly, the path specified for RootDirectory needs to exist on the server that is executing this resource. -For example, if the below example was executed on "Server1" it would also need to ensure that it was able to create the index path at I:\. -If no disk labeled I: was available on server1, this would fail, even though it will not hold an actual index component. - -EXAMPLE - - xSPSearchIndexPartition MainSearchPartition - { - Servers = @("Server2", "Server3") - Index = 1 - RootDirectory = "I:\SearchIndexes\1" - ServiceAppName = "Search Service Application" - PsDscRunAsCredential = $SPSetupAccount - DependsOn = "[xSPSearchRoles]LocalSearchRoles" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt deleted file mode 100644 index e8a2d3cd5..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPSearchServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, string) - DatabaseName (Write, string) - DatabaseServer (Write, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for provisioning the search service application. -The current version lets you specify the database name and server, as well as the application pool. -If the application pool is changed the DSC resource will set it back as per what is set in the resource. -The database name parameter is used as the prefix for all search databases (so you will end up with one for the admin database which matches the name, and then "_analyticsreportingstore", "_crawlstore" and "_linkstore" databases as well). - -EXAMPLE - - xSPSearchServiceApp SearchServiceApp - { - Name = "Search Service Application" - DatabaseName = "SP_Search" - ApplicationPool = "SharePoint Service Applications" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt b/Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt deleted file mode 100644 index 3dfdadcc4..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt +++ /dev/null @@ -1,42 +0,0 @@ -NAME - xSPSearchTopology - -PARAMETERS - ServiceAppName (Key, String) - Admin[] (Required, String) - Crawler[] (Required, String) - ContentProcessing[] (Required, String) - AnalyticsProcessing[] (Required, String) - QueryProcessing[] (Required, String) - IndexPartition[] (Required, String) - FirstPartitionDirectory (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for provisioning a search topology in to the current farm. -It allows the configuration to dictate the search topology roles that the current server should be running. -Any combination of roles can be specified and the topology will be upaded to reflect the current servers new roles. -If this is the first server to apply topology to a farm, then at least one search index must be provided. -To this end, the FirstPartitionIndex, FirstPartitionDirectory and FirstPartitionServers allow configuring where the first index partition will belong. -This will behave the same as the xSPSearchIndexPartition resource. - -Note that for the search topology to apply correctly, the path specified for FirstPartitionDirectory needs to exist on the server that is executing this resource. -For example, if the below example was executed on "Server1" it would also need to ensure that it was able to create the index path at I:\. -If no disk labeled I: was available on server1, this would fail, even though it will not hold an actual index component. - -EXAMPLE - - xSPSearchRoles LocalSearchRoles - { - ServiceAppName = "Search Service Application" - Admin = @("Server1","Server2") - Crawler = @("Server1","Server2") - ContentProcessing = @("Server1","Server2") - AnalyticsProcessing = @("Server1","Server2") - QueryProcessing = @("Server3","Server4") - PsDscRunAsCredential = $SPSetupAccount - FirstPartitionDirectory = "I:\SearchIndexes\0" - IndexPartition = @("Server3","Server4") - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt deleted file mode 100644 index 6baa6372f..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt +++ /dev/null @@ -1,34 +0,0 @@ -NAME - xSPSecureStoreServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, string) - AuditingEnabled (Required, boolean) - AuditlogMaxSize (Write, uint32) - DatabaseCredentials (Write, String) - DatabaseName (Write, string) - DatabaseServer (Write, string) - DatabaseAuthenticationType (Write, string, Allowed values: te, ValueMap {Windows, SQL) - FailoverDatabaseServer (Write, string) - PartitionMode (Write, boolean) - Sharing (Write, boolean) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for provisioning and configuring the secure store service application. -The parameters passed in (except those related to database specifics) are validated and set when the resource is run, the database values are only used in provisioning of the service application. - -EXAMPLE - - xSPSecureStoreServiceApp SecureStoreServiceApp - { - Name = "Secure Store Service Application" - ApplicationPool = "SharePoint Service Applications" - AuditingEnabled = $true - AuditlogMaxSize = 30 - DatabaseName = "SP_SecureStore" - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt b/Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt deleted file mode 100644 index 0290e3773..000000000 --- a/Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt +++ /dev/null @@ -1,22 +0,0 @@ -NAME - xSPServiceAppPool - -PARAMETERS - Name (Key, string) - ServiceAccount (Required, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used for provisioning an application pool that can be used for service applications. -The account used for the service account must already be registered as a managed account (which can be provisioned through [xSPManagedAccount](xSPManagedAccount)). - -EXAMPLE - - xSPServiceAppPool MainServiceAppPool - { - Name = "SharePoint Service Applications" - ServiceAccount = "Demo\ServiceAccount" - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt b/Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt deleted file mode 100644 index 54e28c49c..000000000 --- a/Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt +++ /dev/null @@ -1,29 +0,0 @@ -NAME - xSPServiceInstance - -PARAMETERS - Name (Key, string) - InstallAccount (Write, String) - Ensure (Required, string, Allowed values: Present, Absent) - -DESCRIPTION - -This resource is used to specify if a specific service should be running (Ensure = "Present") or not running (Ensure = "Absent") on the current server. -The name is the display name of the service as shown in the Central Admin website. - -**Examples** - - xSPServiceInstance ManagedMetadataServiceInstance - { - Name = "Managed Metadata Web Service" - Ensure = "Present" - InstallAccount = $InstallAccount - } - - xSPServiceInstance StopBCSServiceInstance - { - Name = "Business Data Connectivity Service" - Ensure = "Absent" - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt b/Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt deleted file mode 100644 index ac4c84fe8..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt +++ /dev/null @@ -1,26 +0,0 @@ -NAME - xSPSessionStateService - -PARAMETERS - DatabaseName (Key, string) - DatabaseServer (Key, string) - Enabled (Required, boolean) - SessionTimeout (Write, uint32) - InstallAccount (Write, String) - -DESCRIPTION - -This resource will provision a state service app to the local farm. -Specify the name of the database server and database name to provision the app with, and optionally include the session timeout value. -If session timeout is not provided it will default to 60. - -EXAMPLE - - xSPSessionStateService StateServiceApp - { - DatabaseName = "SP_StateService" - DatabaseServer = "SQL.test.domain" - Enabled = $true - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSite.help.txt b/Modules/xSharePoint/en-US/about_xSPSite.help.txt deleted file mode 100644 index 86229eb8a..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSite.help.txt +++ /dev/null @@ -1,38 +0,0 @@ -NAME - xSPSite - -PARAMETERS - Url (Key, string) - OwnerAlias (Required, string) - CompatibilityLevel (Write, uint32) - ContentDatabase (Write, string) - Description (Write, string) - HostHeaderWebApplication (Write, string) - Language (Write, uint32) - Name (Write, string) - OwnerEmail (Write, string) - QuotaTemplate (Write, string) - SecondaryEmail (Write, string) - SecondaryOwnerAlias (Write, string) - Template (Write, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource will provision a site collection to the current farm, based on the settings that are passed through. -These settings map to the New-SPSite cmdlet and accept the same values and types. - -The current version of xSharePoint is only able to check for the existence of a site collection, the additional parameters are not checked for yet, but will be in a later release - -EXAMPLE - - xSPSite TeamSite - { - Url = "http://sharepoint.contoso.com" - OwnerAlias = "CONTOSO\ExampleUser" - HostHeaderWebApplication = "http://spsites.contoso.com" - Name = "Team Sites" - Template = "STS#0" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt deleted file mode 100644 index 8549522bb..000000000 --- a/Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt +++ /dev/null @@ -1,24 +0,0 @@ -NAME - xSPStateServiceApp - -PARAMETERS - Name (Key, string) - DatabaseCredentials (Write, String) - DatabaseName (Required, string) - DatabaseServer (Write, string) - InstallAccount (Write, String) - -DESCRIPTION - -This resource provisions an instance of the state service in to the local farm. -The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. - -EXAMPLE - - xSPStateServiceApp StateServiceApp - { - Name = "State Service Application" - DatabaseName = "SP_State" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt deleted file mode 100644 index de49e3053..000000000 --- a/Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt +++ /dev/null @@ -1,27 +0,0 @@ -NAME - xSPSubscriptionSettingsServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, String) - DatabaseName (Write, string) - DatabaseServer (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to provision and manage an instance of the App Management Services Service Application. -It will identify an instance of the subscription settings service app through the application display name. -Currently the resource will provision the app if it does not yet exist, and will change the service account associated to the app if it does not match the configuration. -Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. - -EXAMPLE - - xSPSubscriptionSettingsServiceApp SubscriptionSettingsServiceApp - { - Name = "Subscription Settings Service Application" - AppPool = "SharePoint web services" - DatabaseServer = "SQL01.contoso.com" - DatabaseName = "SP_ManagedMetadata" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt b/Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt deleted file mode 100644 index 4bc7d8751..000000000 --- a/Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt +++ /dev/null @@ -1,38 +0,0 @@ -NAME - xSPTimerJobState - -PARAMETERS - Name (Key, String) - WebApplication (Write, String) - Enabled (Write, Boolean) - Schedule (Write, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to configure a timer job and make sure it is in a specific state. -The resource can be used to enable or disabled the job and configure the schedule of the job. - -The schedule parameter has to be written in the SPSchedule format (https://technet.microsoft.com/en-us/library/ff607916.aspx). -Examples are: - - Every 5 minutes between 0 and 59 - - Hourly between 0 and 59 - - Daily at 15:00:00 - - Weekly between Fri 22:00:00 and Sun 06:00:00 - - Monthly at 15 15:00:00 - - Yearly at Jan 1 15:00:00 - -NOTE: Make sure you use the internal timer job name, not the display name! -Use "Get-SPTimerJob -WebApplication "http://servername" | select Name, DisplayName" to find the internal name for each Timer Job. - -EXAMPLE - - xSPTimerJobState DisableTimerJob_DeadSiteDelete - { - Name = "job-dead-site-delete" - WebApplication = "http://sites.sharepoint.contoso.com" - Enabled = $true - Schedule ="weekly at sat 5:00" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt b/Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt deleted file mode 100644 index b37395cc5..000000000 --- a/Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt +++ /dev/null @@ -1,32 +0,0 @@ -NAME - xSPUsageApplication - -PARAMETERS - Name (Key, string) - InstallAccount (Write, String) - DatabaseName (Write, string) - DatabaseServer (Write, string) - DatabaseCredentials (Write, String) - FailoverDatabaseServer (Write, string) - UsageLogCutTime (Write, uint32) - UsageLogLocation (Write, string) - UsageLogMaxFileSizeKB (Write, uint32) - UsageLogMaxSpaceGB (Write, uint32) - -DESCRIPTION - -This resource provisions an instance of the usage and health monitoring service application. -The database settings are only used for initial provisioning, but the usage settings can be changed and will be enforced as the resource is executed. - -EXAMPLE - - xSPUsageApplication UsageApplication - { - Name = "Usage Service Application" - DatabaseName = "SP_Usage" - UsageLogCutTime = 5 - UsageLogLocation = "L:\UsageLogs" - UsageLogMaxFileSizeKB = 1024 - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPUserProfileServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPUserProfileServiceApp.help.txt deleted file mode 100644 index a8ed83351..000000000 --- a/Modules/xSharePoint/en-US/about_xSPUserProfileServiceApp.help.txt +++ /dev/null @@ -1,40 +0,0 @@ -NAME - xSPUserProfileServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, string) - FarmAccount (Required, String) - InstallAccount (Write, String) - MySiteHostLocation (Write, string) - ProfileDBName (Write, string) - ProfileDBServer (Write, string) - SocialDBName (Write, string) - SocialDBServer (Write, string) - SyncDBName (Write, string) - SyncDBServer (Write, string) - -DESCRIPTION - -This resource will provision an instance of the user profile service to the farm. -It creates the required databases using the parameters that are passed in to it (although these are only used during the initial provisioning). -The farm account is used during the provisioning of the service only (in the set method), and the install account is used in the get and test methods. -This is done to ensure that the databases are created with the correct schema owners and allow the user profile sync service to operate correctly. - -EXAMPLE - - xSPUserProfileServiceApp UserProfileServiceApp - { - Name = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - MySiteHostLocation = "http://my.sharepoint.contoso.local" - ProfileDBName = "SP_UserProfiles" - ProfileDBServer = "SQL.contoso.local\SQLINSTANCE" - SocialDBName = "SP_Social" - SocialDBServer = "SQL.contoso.local\SQLINSTANCE" - SyncDBName = "SP_ProfileSync" - SyncDBServer = "SQL.contoso.local\SQLINSTANCE" - FarmAccount = $FarmAccount - PsDscRunAsCredential = $SetupAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPUserProfileSyncService.help.txt b/Modules/xSharePoint/en-US/about_xSPUserProfileSyncService.help.txt deleted file mode 100644 index bed8e8027..000000000 --- a/Modules/xSharePoint/en-US/about_xSPUserProfileSyncService.help.txt +++ /dev/null @@ -1,26 +0,0 @@ -NAME - xSPUserProfileSyncService - -PARAMETERS - UserProfileServiceAppName (Key, string) - Ensure (Required, string, Allowed values: Present, Absent) - FarmAccount (Required, String) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is responsible for ensuring that the user profile sync service has been provisioned (Ensure = "Present") or is not running (Ensure = "Absent") on the current server. -This resource uses the InstallAccount to validate the current state only, the set method which will do the provisioning uses the FarmAccount to do the actual work - this means that CredSSP authentication will need to be permitted to allow a connection to the local server. -To allow successful provisioning the farm account must be in the local administrators group, however it is not best practice to leave this account in the Administrators group. -Therefore this resource will add the FarmAccount credential to the local administrators group at the beginning of the set method, and then remove it once it has completed its work. - -EXAMPLE - - xSPUserProfileSyncService UserProfileSyncService - { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - InstallAccount = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt deleted file mode 100644 index 94f927edf..000000000 --- a/Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt +++ /dev/null @@ -1,18 +0,0 @@ -NAME - xSPVisioServiceApp - -PARAMETERS - Name (Key, string) - ApplicationPool (Write, string) - -DESCRIPTION - -This resource is responsible for creating Visio Graphics Service Application instances within the local SharePoint farm. -The resource will provision and configure the Visio Graphics Service Application. -EXAMPLE - xSPVisioServiceApp VisioServices - { - Name = "Visio Graphics Service Application" - ApplicationPool = "SharePoint Web Services" - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt deleted file mode 100644 index 67267f06d..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt +++ /dev/null @@ -1,30 +0,0 @@ -NAME - xSPWebAppBlockedFileTypes - -PARAMETERS - Url (Key, string) - Blocked[] (write, string) - EnsureBlocked[] (write, string) - EnsureAllowed[] (write, string) - InstallAccount (Write, string) - -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 - - xSPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes - { - Url = "Shttp://exmaple.contoso.local" - EnsureBlocked = @("exe", "dll", "msi") - EnsureAllowed = @("pdf", "docx", "xlsx") - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt deleted file mode 100644 index 9ac055e73..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt +++ /dev/null @@ -1,39 +0,0 @@ -NAME - xSPWebAppGeneralSettings - -PARAMETERS - Url (Key, string) - TimeZone (write, uint32) - Alerts (write, boolean) - AlertsLimit (write, uint32) - RSS (write, boolean) - BlogAPI (write, boolean) - BlogAPIAuthenticated (write, boolean) - BrowserFileHandling (write, String, Allowed values: Strict, Permissive) - SecurityValidation (write, boolean) - RecycleBinEnabled (write, boolean) - RecycleBinCleanupEnabled (write, boolean) - RecycleBinRetentionPeriod (write, uint32) - SecondStageRecycleBinQuota (write, uint32) - MaximumUploadSize (write, uint32) - CustomerExperienceProgram (write, boolean) - PresenceEnabled (write, boolean) - InstallAccount (Write, string) - -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 - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt deleted file mode 100644 index 2d468d42c..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt +++ /dev/null @@ -1,24 +0,0 @@ -NAME - xSPWebAppPolicy - -PARAMETERS - WebAppUrl (Key, string) - UserName (Key, string) - PermissionLevel (Write, string, Allowed values: Deny All, Deny Write, Full Read, Full Control) - ActAsSystemUser (Write, boolean) - InstallAccount (Write, String) - -DESCRIPTION - -This resource is used to set the "super user" and "super reader" cache accounts for the specified web application object (as described in the TechNet article [Configure object cache user accounts in SharePoint Server 2013](https://technet.microsoft.com/en-us/library/ff758656.aspx)). - -EXAMPLE - - xSPCacheAccounts SetCacheAccounts - { - WebAppUrl = "http://sharepoint.contoso.com" - SuperUserAlias = "DEMO\svcSPSuperUser" - SuperReaderAlias = "DEMO\svcSPReader" - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt deleted file mode 100644 index 9119180e2..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt +++ /dev/null @@ -1,28 +0,0 @@ -NAME - xSPWebAppSiteUseAndDeletion - -PARAMETERS - Url (Key, string) - SendUnusedSiteCollectionNotifications (write, boolean) - UnusedSiteNotificationPeriod (write, uint32) - AutomaticallyDeleteUnusedSiteCollections (write, boolean) - UnusedSiteNotificationsBeforeDeletion (write, uint32) - InstallAccount (Write, string) - -DESCRIPTION - -This resource is responsible for controlling the Site Use and Deletion settings on a specific web application. -You can enable or disable the Site Use and Deletion feature, specify the amount of days after which the alerts are being send, if sites have to be deleted automatically and if so after how many days this has to be done. - -EXAMPLE - - xSPWebAppSiteUseAndDeletion ConfigureSiteUseAndDeletion - { - Url = "http://example.contoso.local" - SendUnusedSiteCollectionNotifications = $true - UnusedSiteNotificationPeriod = 90 - AutomaticallyDeleteUnusedSiteCollections = $true - UnusedSiteNotificationsBeforeDeletion = 24 - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt deleted file mode 100644 index b56203227..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt +++ /dev/null @@ -1,42 +0,0 @@ -NAME - xSPWebAppThrottlingSettings - -PARAMETERS - Url (Key, string) - ListViewThreshold (write, uint32) - AllowObjectModelOverride (write, boolean) - AdminThreshold (write, uint32) - ListViewLookupThreshold (write, uint32) - HappyHourEnabled (write, boolean) - HappyHour (Write, string) - UniquePermissionThreshold (write, uint32) - RequestThrottling (write, boolean) - ChangeLogEnabled (write, boolean) - ChangeLogExpiryDays (write, uint32) - EventHandlersEnabled (write, boolean) - InstallAccount (Write, string) - -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 - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt b/Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt deleted file mode 100644 index 1b8513563..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt +++ /dev/null @@ -1,26 +0,0 @@ -NAME - xSPWebAppWorkflowSettings - -PARAMETERS - Url (Key, string) - ExternalWorkflowParticipantsEnabled (write, boolean) - UserDefinedWorkflowsEnabled (write, boolean) - EmailToNoPermissionWorkflowParticipantsEnable (write, boolean) - InstallAccount (Write, string) - -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 - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt b/Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt deleted file mode 100644 index 0810cc7c8..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt +++ /dev/null @@ -1,38 +0,0 @@ -NAME - xSPWebApplication - -PARAMETERS - Name (Key, string) - ApplicationPool (Required, string) - ApplicationPoolAccount (Required, string) - Url (Required, string) - AllowAnonymous (Write, boolean) - AuthenticationMethod (Write, string, Allowed values: NTLM, Kerberos) - DatabaseName (Write, string) - DatabaseServer (Write, string) - HostHeader (Write, string) - Path (Write, string) - Port (Write, string) - InstallAccount (Write, string) - -DESCRIPTION - -This resource is responsible for creating a web application within the local SharePoint farm. -The resource will provision the web application with all of the current settings, and then ensure that it stays part of the correct application pool beyond that (additional checking and setting of properties will be added in future releases). - -EXAMPLE - - xSPWebApplication HostNameSiteCollectionWebApp - { - Name = "SharePoint Sites" - ApplicationPool = "SharePoint Sites" - ApplicationPoolAccount = "CONTOSO\svcSPWebApp" - AllowAnonymous = $false - AuthenticationMethod = "NTLM" - DatabaseName = "SP_Content_01" - DatabaseServer = "SQL.contoso.local\SQLINSTANCE" - Url = "http://example.contoso.local" - Port = 80 - PsDscRunAsCredential = $InstallAccount - } - diff --git a/Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt b/Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt deleted file mode 100644 index fbbcf2846..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt +++ /dev/null @@ -1,31 +0,0 @@ -NAME - xSPWebApplicationAppDomain - -PARAMETERS - WebApplication (Key, string) - string (Key, , Allowed values: Internet, Intranet, Extranet, Custom) - AppDomain (Required, string) - Port (Write, string) - SSL (Write, boolean) - InstallAccount (Write, String) - -DESCRIPTION - -This resource will configure the App Domain at a specific zone for the given Web Application. -The configuration is done per zone on the specified web application, allowing for the setting of unique app domains for each extension of a web application. -The app prefix should still be set using the xSPAppDomain resource before this is applied to customise a specific zone. - - -EXAMPLE - - xSPWebApplicationAppDomain Domain - { - AppDomain = "contosointranetapps.com" - WebApplication ="http://portal.contoso.com"; - Zone = "Default"; - Port = 80; - SSL = $false; - PsDscRunAsCredential = $InstallAccount - } - - From c4f7feb99ac4bb8338cdeee1d08276378ef0886b Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sat, 23 Jan 2016 13:59:39 +0100 Subject: [PATCH 41/91] Store changes --- .../DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 index e718c87ec..42378274b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -30,8 +30,9 @@ function Get-TargetResource if ($params.AllContentDatabases) { if ($params.Members) { - # Check if the members are configured on all databases + Write-Verbose -Verbose "Looping through content databases" foreach ($contentDatabase in (Get-SPContentDatabase)) { + Write-Verbose -Verbose "Checking content database $contentDatabase" $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id foreach ($member in $params.Members) { if (-not $dbShellAdmins.UserName.Contains($member)) { @@ -42,7 +43,6 @@ function Get-TargetResource } if ($params.MembersToInclude) { - # Check if the members are configured on all databases foreach ($contentDatabase in (Get-SPContentDatabase)) { $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id foreach ($member in $params.MembersToInclude) { From faeef0bb0c22f01aaa2d757a15d02af0e72ab932 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sat, 23 Jan 2016 14:03:43 +0100 Subject: [PATCH 42/91] Updated the description in the MOF file --- .../MSFT_xSPHealthAnalyzerRuleState.schema.mof | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof index 8cb7c5a7f..bb98f043b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof @@ -1,9 +1,8 @@ /* **Description** -This resource is used to set the global antivirus settings for the local farm. -These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. -Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. +This resource is used to configure Health Analyzer rules for the local farm. +The resource is able to enable/disable and configure the specified rule. **Example** From 10bfd356c5b6bc63efa42b3c457a14a13cb4f79c Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sat, 23 Jan 2016 14:13:40 +0100 Subject: [PATCH 43/91] Deleted help file. --- ...about_xSPWordAutomationServiceApp.help.txt | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt diff --git a/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt b/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt deleted file mode 100644 index 933d67d21..000000000 --- a/Modules/xSharePoint/en-US/about_xSPWordAutomationServiceApp.help.txt +++ /dev/null @@ -1,68 +0,0 @@ -NAME - xSPWordAutomationServiceApp - -PARAMETERS - Name (Key, string) - Ensure (Required, string) - Values "Present", "Absent" - ApplicationPool (Write, string) - DatabaseName (Write, string) - DatabaseServer (Write, string) - SupportedFileFormats (Write, string[]) - Values docx", "doc", "mht", "rtf", "xml" - DisableEmbeddedFonts (Write, boolean) - MaximumMemoryUsage (Write, uint32) - RecycleThreshold (Write, uint32) - DisableBinaryFileScan (Write, boolean) - ConversionProcesses (Write, uint32) - JobConversionFrequency (Write, uint32) - NumberOfConversionsPerProcess (Write, uint32) - TimeBeforeConversionIsMonitored (Write, uint32) - MaximumConversionAttempts (Write, uint32) - MaximumSyncConversionRequests (Write, uint32) - KeepAliveTimeout (Write, uint32) - MaximumConversionTime (Write, uint32) - InstallAccount (Write, string) - -DESCRIPTION - -The resource is able to provision, unprovision and configure the Word Automation Service Application. -All settings that you can configure on the Service Application administration page are configurable using this resource. - -Important: -When you specify Ensure=Present, the Application Pool and DatabaseName parameters are required. -When you specify Ensure=Absent, no other parameters are allowed (with the exception of Name, InstallAccount or PsDscRunAsCredential). - -EXAMPLE - -Make sure the service application exists and has a specific configuration - - xSPWordAutomationServiceApp Word Automation - { - Name = "Word Automation Service Application" - Ensure = "Present" - ApplicationPool = "SharePoint Web Services" - DatabaseName = "WordAutomation_DB" - DatabaseServer = "SQLServer" - SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" - DisableEmbeddedFonts = $false - MaximumMemoryUsage = 100 - RecycleThreshold = 100 - DisableBinaryFileScan = $false - ConversionProcesses = 8 - JobConversionFrequency = 15 (in minutes) - NumberOfConversionsPerProcess = 12 - TimeBeforeConversionIsMonitored = 5 (in minutes) - MaximumConversionAttempts = 2 - MaximumSyncConversionRequests = 25 - KeepAliveTimeout = 30 (in seconds) - MaximumConversionTime = 300 (in seconds) - PsDscRunAsCredential = $InstallAccount - } - -Make sure the service application does not exist and remove when it does - - xSPWordAutomationServiceApp Word Automation - { - Name = "Word Automation Service Application" - Ensure = "Absent" - PsDscRunAsCredential = $InstallAccount - } From dcbea74ababda1dc6a8530b5d7a5883c26f909db Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Sat, 23 Jan 2016 14:22:47 +0100 Subject: [PATCH 44/91] Change to check if Pester test ValidateSet now works --- .../MSFT_xSPHealthAnalyzerRuleState.psm1 | 6 +++--- .../MSFT_xSPHealthAnalyzerRuleState.schema.mof | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 index 6249d3cfe..df59ec179 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 @@ -6,7 +6,7 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers","Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -72,7 +72,7 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers","Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -134,7 +134,7 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.Boolean] $Enabled, - [parameter(Mandatory = $false)] [ValidateSet("All Servers", "Any Server")] [System.String] $RuleScope, + [parameter(Mandatory = $false)] [ValidateSet("All Servers","Any Server")] [System.String] $RuleScope, [parameter(Mandatory = $false)] [ValidateSet("Hourly","Daily","Weekly","Monthly","OnDemandOnly")] [System.String] $Schedule, [parameter(Mandatory = $false)] [System.Boolean] $FixAutomatically, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof index bb98f043b..d2d87b8b8 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof @@ -22,7 +22,7 @@ class MSFT_xSPHealthAnalyzerRuleState : OMI_BaseResource { [Key] String Name; [Required] Boolean Enabled; - [Write, ValueMap{"All Servers", "Any Server"}, Values{"All Servers", "Any Server"}] String RuleScope; + [Write, ValueMap{"All Servers","Any Server"}, Values{"All Servers","Any Server"}] String RuleScope; [Write, ValueMap{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}, Values{"Hourly","Daily","Weekly","Monthly","OnDemandOnly"}] String Schedule; [Write] Boolean FixAutomatically; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; From 03e69ad8bc04cb0578c52e3dbd1d93c17bdbb0f0 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:04:11 +1100 Subject: [PATCH 45/91] updating method declarations, adding ValidateSet. Also made permission exception message more meaningful --- .../MSFT_xSPUserProfileProperty.psm1 | 8 ++++---- .../MSFT_xSPUserProfileProperty.schema.mof | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index fe4ab9357..0aed548b4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -8,7 +8,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , @@ -124,7 +124,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , @@ -180,7 +180,7 @@ function Set-TargetResource $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) if($null -eq $userProfileConfigManager) { #if config manager returns when ups is available then isuee is permissions - throw "account running process needs permissions" + throw "account running process need admin permission on service application" } $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() @@ -354,7 +354,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 53af9bfed..0b95e4bcf 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -10,8 +10,6 @@ If no DisplayOrder is added then SharePoint adds it as the last property of sect Length is only relevant if Field type is "String". -This DSC resource doesn't currently supports metadata properties - **Example** xSPUserProfileProperty WorkEmailProperty { From d2c71938b7a17f5e35de0744b0f9f8c9ed8e1578 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:07:32 +1100 Subject: [PATCH 46/91] removing 'todo:' note. implementation was done :D --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 index fc99dbd41..634f9dab7 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -48,7 +48,7 @@ function Get-TargetResource $domainController = $namingContext.PreferredDomainControllers | select -First 1 return @{ UserProfileService = $UserProfileService - Forest = $connection.Server #"contoso.com" #TODO: GetCorrect Forest + Forest = $connection.Server Name = $namingContext.DisplayName Credentials = $accountCredentials IncludedOUs = $namingContext.ContainersIncluded From 0cc418b7fc17bfee7179c996ab7642f8322a9c11 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:09:32 +1100 Subject: [PATCH 47/91] updating method declarations --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 index 634f9dab7..aec961a41 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -13,7 +13,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String] $Server, [parameter(Mandatory = $false)] [System.String] $Force, [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, - [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [System.String] $ConnectionType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -77,7 +77,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String] $Server, [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, [parameter(Mandatory = $false)] [System.Boolean] $Force, - [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [System.String] $ConnectionType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -208,7 +208,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String] $Server, [parameter(Mandatory = $false)] [System.String] $Force, [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, - [parameter(Mandatory = $false)] [System.String] $ConnectionType, + [parameter(Mandatory = $false)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [System.String] $ConnectionType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) From 8cae8e591828f073116653ad016013bc5502db02 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:20:47 +1100 Subject: [PATCH 48/91] updated unit tests, (commiting and pushing so I can sync from box with SP and PEster) --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 9 ++++++--- .../xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 index aec961a41..ba1da9d5b 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -32,8 +32,9 @@ function Get-TargetResource else { - #what if permission isn't granted ? - $context = Get-xSharePointServiceContext $ups.ServiceApplicationProxyGroup + $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url + $context = Get-SPServiceContext -Site $caURL + $upcm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileConfigManager $context $connection = $upcm.ConnectionManager | Where-Object { $_.DisplayName -eq $params.Name} @@ -94,7 +95,9 @@ function Set-TargetResource if ($null -eq $ups) { throw "User Profile Service Application $($params.UserProfileService) not found" } - $context = Get-xSharePointServiceContext $ups.ServiceApplicationProxyGroup + $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url + $context = Get-SPServiceContext -Site $caURL + Write-Verbose -Message "retrieving UserProfileConfigManager " $upcm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager $context diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 index e2ff74848..c7f181dcc 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 @@ -45,7 +45,12 @@ Describe "xSPUserProfileSyncConnection" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" - + Mock Get-SPWebApplication { + return @{ + Url="http://ca" + IsAdministrationWebApplication=$true + } + } $connection = @{ DisplayName = "Contoso" Server = "contoso.com" From fafcff99b024fa8c1c6de1d509890ee5d8225454 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:23:58 +1100 Subject: [PATCH 49/91] fixing dadatype --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 index ba1da9d5b..34fbc93fa 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -11,7 +11,7 @@ function Get-TargetResource [parameter(Mandatory = $true)] [System.String[]] $IncludedOUs, [parameter(Mandatory = $false)] [System.String[]] $ExcludedOUs, [parameter(Mandatory = $false)] [System.String] $Server, - [parameter(Mandatory = $false)] [System.String] $Force, + [parameter(Mandatory = $false)] [System.Boolean] $Force, [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, [parameter(Mandatory = $false)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [System.String] $ConnectionType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -209,7 +209,7 @@ function Test-TargetResource [parameter(Mandatory = $true)] [System.String[]] $IncludedOUs, [parameter(Mandatory = $false)] [System.String[]] $ExcludedOUs, [parameter(Mandatory = $false)] [System.String] $Server, - [parameter(Mandatory = $false)] [System.String] $Force, + [parameter(Mandatory = $false)] [System.Boolean] $Force, [parameter(Mandatory = $false)] [System.Boolean] $UseSSL, [parameter(Mandatory = $false)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [System.String] $ConnectionType, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount From 3b361afccb0dda601ab27d4dc8133ed8e2b76fd1 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:32:16 +1100 Subject: [PATCH 50/91] updating spaces via visual studio --- .../MSFT_xSPUserProfileSyncConnection.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 index 34fbc93fa..5241db9cd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1 @@ -33,7 +33,7 @@ function Get-TargetResource { $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url - $context = Get-SPServiceContext -Site $caURL + $context = Get-SPServiceContext -Site $caURL $upcm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileConfigManager $context From 846eda0129576ef947816284eb47a4573e230674 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:37:07 +1100 Subject: [PATCH 51/91] reverting key files --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 11 ----------- Modules/xSharePoint/xSharePoint.psd1 | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 185a83acc..66d422341 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -32,17 +32,6 @@ function Get-xSharePointContentService() { return [Microsoft.SharePoint.Administration.SPWebService]::ContentService } -function Get-xSharePointUserProfileSubTypeManager { - [CmdletBinding()] - param - ( - $context - ) - [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - - return [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) -} - function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" $fullPath = Get-Item $pathToSearch | Sort-Object { $_.Directory } -Descending | Select-Object -First 1 diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index c891e5e64..669d2a1f9 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -79,8 +79,7 @@ CmdletsToExport = @("Invoke-xSharePointCommand", "Test-xSharePointRunAsCredential", "Test-xSharePointUserIsLocalAdmin", "Test-xSharePointSpecificParameters", - "Set-xSharePointObjectPropertyIfValueExists", - "Get-xSharePointUserProfileSubTypeManager") + "Set-xSharePointObjectPropertyIfValueExists") # Variables to export from this module VariablesToExport = '*' From 1ff067b6cbf729ec263ad5a3a20e899080ecf573 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:38:54 +1100 Subject: [PATCH 52/91] spaces... --- ...SharePoint.xSPUserProfileSyncConnection.Tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 index c7f181dcc..f624d7b08 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 @@ -45,12 +45,12 @@ Describe "xSPUserProfileSyncConnection" { Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" - Mock Get-SPWebApplication { - return @{ - Url="http://ca" - IsAdministrationWebApplication=$true - } - } + Mock Get-SPWebApplication { + return @{ + Url="http://ca" + IsAdministrationWebApplication=$true + } + } $connection = @{ DisplayName = "Contoso" Server = "contoso.com" From ad2fd47a15d11b8d73b2cb9fe8cfc19970bb8183 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:42:02 +1100 Subject: [PATCH 53/91] Revert "updating method declarations, adding ValidateSet. Also made permission exception message more meaningful" This reverts commit 03e69ad8bc04cb0578c52e3dbd1d93c17bdbb0f0. --- .../MSFT_xSPUserProfileProperty.psm1 | 8 ++++---- .../MSFT_xSPUserProfileProperty.schema.mof | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 0aed548b4..fe4ab9357 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -8,7 +8,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , @@ -124,7 +124,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , @@ -180,7 +180,7 @@ function Set-TargetResource $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) if($null -eq $userProfileConfigManager) { #if config manager returns when ups is available then isuee is permissions - throw "account running process need admin permission on service application" + throw "account running process needs permissions" } $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() @@ -354,7 +354,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , [parameter(Mandatory = $true)] [System.string ] $UserProfileService , [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Type , [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 0b95e4bcf..53af9bfed 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -10,6 +10,8 @@ If no DisplayOrder is added then SharePoint adds it as the last property of sect Length is only relevant if Field type is "String". +This DSC resource doesn't currently supports metadata properties + **Example** xSPUserProfileProperty WorkEmailProperty { From 100452b26e2b9167e9e5e2f1de9f7e30bd2a6911 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 22:46:07 +1100 Subject: [PATCH 54/91] removed commented out code --- .../xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 0acfcfd6c..9b41de9ee 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -3,10 +3,6 @@ param( [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) ) -#(Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url -#C:\Users\camilo\Source\Repos\xSharePoint\Modules\xSharePoint\DSCResources\MSFT_xSPUserProfileProperty\ -#C:\Users\camilo\Source\Repos\xSharePoint\Tests\xSharePoint -#.\xSharePoint.xSPUserProfileProperty.Tests.ps1 Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 $ErrorActionPreference = 'stop' From 22dd108d272406630b8b4fae6e56025069097296 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Sun, 24 Jan 2016 23:19:50 +1100 Subject: [PATCH 55/91] removing commented out code --- .../xSharePoint.xSPUserProfileProperty.Tests.ps1 | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 9b41de9ee..9b51da485 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -269,16 +269,7 @@ Describe "xSPUserProfileProperty" { Mock Invoke-xSharePointCommand { return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope } - -<# Mock Get-xSharePointUserProfileSubTypeManager{ - $properties = @() - return @()| Add-Member ScriptMethod GetProfileSubtype { - $Global:UpsSubTypeMgrGetProfileSubtypeCalled=$true; - return $false; - } -PassThru - - } - #> + Mock New-PSSession { return $null } -ModuleName "xSharePoint.Util" $propertyMappingItem = @{ @@ -302,7 +293,6 @@ Describe "xSPUserProfileProperty" { $Global:UpsMappingAddNewMappingCalled=$true; return $true; } -PassThru - #} -PassThru -Force $connection = @{ DisplayName = "Contoso" Server = "contoso.com" @@ -333,7 +323,6 @@ Describe "xSPUserProfileProperty" { $Global:xSPUPSAddActiveDirectoryConnectionCalled =$true } -PassThru - #$ConnnectionManager.add($connection) Mock New-Object -MockWith { $ProfilePropertyManager = @{"Contoso" = $connection} | Add-Member ScriptMethod GetCoreProperties { @@ -362,8 +351,6 @@ Describe "xSPUserProfileProperty" { ConnectionManager= @($connection) #New-Object System.Collections.ArrayList } - #$userProfileServiceValidConnection.ConnectionManager.Add($connection); - Mock Get-SPServiceApplication { return $userProfileServiceValidConnection } From ddae4060b04e605f08196f6356d1b826a79aa672 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 25 Jan 2016 10:17:24 +1100 Subject: [PATCH 56/91] fixing mof --- .../MSFT_xSPUserProfileProperty.schema.mof | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index 53af9bfed..ef4539735 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -10,7 +10,7 @@ If no DisplayOrder is added then SharePoint adds it as the last property of sect Length is only relevant if Field type is "String". -This DSC resource doesn't currently supports metadata properties +This Resource doesn't currently support removing existing user profile properties **Example** xSPUserProfileProperty WorkEmailProperty @@ -48,8 +48,8 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource [Key] string Name ; [write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [required] string UserProfileService; - [required] string DisplayName ; - [Required, ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] string Type; + [write] string DisplayName ; + [write, ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] string Type; [write] string Description ; [write, ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; [write, ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; From 54fe9f063b78b9e66867e8c31858d888f6446e11 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 25 Jan 2016 10:28:02 +1100 Subject: [PATCH 57/91] mof x methods conflicts --- .../MSFT_xSPUserProfileProperty.psm1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index fe4ab9357..0124aacc9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -128,7 +128,6 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , @@ -358,7 +357,6 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , @@ -381,7 +379,7 @@ function Test-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Testing for user profile property $Name" if ($null -eq $CurrentValues) { return $false } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name","DisplayName","Type", "Description", "PolicySetting", "PrivacySetting","AllowUserEdit", "MappingConnectionName","MappingPropertyName", "MappingDirection", "Length", "DisplayOrder", "IsEventLog", "IsVisibleOnEditor", "IsVisibleOnViewer","IsUserEditable", "IsAlias", "IsSearchabe", "UserOverridePrivacy", "TermGroup", "TermStore", "TermSet") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Name","DisplayName","Type", "Description", "PolicySetting", "PrivacySetting","MappingConnectionName","MappingPropertyName", "MappingDirection", "Length", "DisplayOrder", "IsEventLog", "IsVisibleOnEditor", "IsVisibleOnViewer","IsUserEditable", "IsAlias", "IsSearchabe", "UserOverridePrivacy", "TermGroup", "TermStore", "TermSet") } Export-ModuleMember -Function *-TargetResource From 6d17eee16d802772d756eb70a8c4eafd354864b9 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 25 Jan 2016 10:34:28 +1100 Subject: [PATCH 58/91] still fixing mof --- .../MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 0124aacc9..507257220 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -12,7 +12,6 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.string ] $Description , [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.Boolean] $AllowUserEdit , [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , [parameter(Mandatory = $false)] [System.string ] $MappingDirection , From 01333c68c45bb343ef56a80ccc881b62ee811328 Mon Sep 17 00:00:00 2001 From: Camilo Date: Mon, 25 Jan 2016 04:29:13 +0000 Subject: [PATCH 59/91] fixing mof schema issues. --- .../MSFT_xSPUserProfileProperty.psm1 | 132 +++++++++--------- .../MSFT_xSPUserProfileProperty.schema.mof | 8 +- .../MSFT_xSPWebApplicationAppDomain.psm1 | 24 ++-- ...MSFT_xSPWebApplicationAppDomain.schema.mof | 2 +- 4 files changed, 83 insertions(+), 83 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 507257220..1323b61a0 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -4,29 +4,29 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $true)] [System.string] $Name , [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileService , - [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , - [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , - [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , - [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.Int32] $Length , - [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , - [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , - [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , - [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, - [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , - [parameter(Mandatory = $false)] [System.string ] $TermStore , - [parameter(Mandatory = $false)] [System.string ] $TermGroup , - [parameter(Mandatory = $false)] [System.string ] $TermSet , + [parameter(Mandatory = $true)] [System.string] $UserProfileService , + [parameter(Mandatory = $false)] [System.string] $DisplayName , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")] [System.string] $Type , + [parameter(Mandatory = $false)] [System.string] $Description , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string] $PrivacySetting , + [parameter(Mandatory = $false)] [System.string] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string] $MappingDirection , + [parameter(Mandatory = $false)] [System.uint32] $Length , + [parameter(Mandatory = $false)] [System.uint32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , + [parameter(Mandatory = $false)] [System.string] $TermStore , + [parameter(Mandatory = $false)] [System.string] $TermGroup , + [parameter(Mandatory = $false)] [System.string] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -119,29 +119,29 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $true)] [System.string ] $Name , [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileService , - [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , - [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , - [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , - [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.Int32] $Length , - [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , - [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , - [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , - [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, - [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , - [parameter(Mandatory = $false)] [System.string ] $TermStore , - [parameter(Mandatory = $false)] [System.string ] $TermGroup , - [parameter(Mandatory = $false)] [System.string ] $TermSet , + [parameter(Mandatory = $true)] [System.string ] $UserProfileService , + [parameter(Mandatory = $false)] [System.string ] $DisplayName , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")][System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Description , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string ] $MappingDirection , + [parameter(Mandatory = $false)] [System.uint32] $Length , + [parameter(Mandatory = $false)] [System.uint32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , + [parameter(Mandatory = $false)] [System.string ] $TermStore , + [parameter(Mandatory = $false)] [System.string ] $TermGroup , + [parameter(Mandatory = $false)] [System.string ] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -348,29 +348,29 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.string ] $Name , + [parameter(Mandatory = $true)] [System.string ] $Name , [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.string ] $Ensure , - [parameter(Mandatory = $true)] [System.string ] $UserProfileService , - [parameter(Mandatory = $false)] [System.string ] $DisplayName , - [parameter(Mandatory = $false)] [System.string ] $Type , - [parameter(Mandatory = $false)] [System.string ] $Description , - [parameter(Mandatory = $false)] [ValidateSet("Mandatory", "Optin","Optout", "Disabled")] [System.string ] $PolicySetting , - [parameter(Mandatory = $false)] [ValidateSet("Public", "Contacts", "Organization", "Manager", "Private")] [System.string ] $PrivacySetting , - [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , - [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , - [parameter(Mandatory = $false)] [System.string ] $MappingDirection , - [parameter(Mandatory = $false)] [System.Int32] $Length , - [parameter(Mandatory = $false)] [System.Int32] $DisplayOrder , - [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , - [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , - [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , - [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , - [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, - [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , - [parameter(Mandatory = $false)] [System.string ] $TermStore , - [parameter(Mandatory = $false)] [System.string ] $TermGroup , - [parameter(Mandatory = $false)] [System.string ] $TermSet , + [parameter(Mandatory = $true)] [System.string ] $UserProfileService , + [parameter(Mandatory = $false)] [System.string ] $DisplayName , + [parameter(Mandatory = $false)] [ValidateSet("BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL")][System.string ] $Type , + [parameter(Mandatory = $false)] [System.string ] $Description , + [parameter(Mandatory = $false)] [ValidateSet("Mandatory","Optin","Optout","Disabled")] [System.string ] $PolicySetting , + [parameter(Mandatory = $false)] [ValidateSet("Public","Contacts","Organization","Manager","Private")] [System.string ] $PrivacySetting , + [parameter(Mandatory = $false)] [System.string ] $MappingConnectionName , + [parameter(Mandatory = $false)] [System.string ] $MappingPropertyName , + [parameter(Mandatory = $false)] [System.string ] $MappingDirection , + [parameter(Mandatory = $false)] [System.uint32] $Length , + [parameter(Mandatory = $false)] [System.uint32] $DisplayOrder , + [parameter(Mandatory = $false)] [System.Boolean] $IsEventLog , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnEditor , + [parameter(Mandatory = $false)] [System.Boolean] $IsVisibleOnViewer , + [parameter(Mandatory = $false)] [System.Boolean] $IsUserEditable , + [parameter(Mandatory = $false)] [System.Boolean] $IsAlias , + [parameter(Mandatory = $false)] [System.Boolean] $IsSearchable, + [parameter(Mandatory = $false)] [System.Boolean] $UserOverridePrivacy , + [parameter(Mandatory = $false)] [System.string ] $TermStore , + [parameter(Mandatory = $false)] [System.string ] $TermGroup , + [parameter(Mandatory = $false)] [System.string ] $TermSet , [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof index ef4539735..bfc1c65a1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof @@ -49,10 +49,10 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource [write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [required] string UserProfileService; [write] string DisplayName ; - [write, ValueMap{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}, Values{"BigInteger", "Binary", "Boolean", "Date", "DateNoYear", "DateTime", "Email", "Float", "Guid", "HTML", "Integer", "Person", "String", "StringMultiValue", "TimeZone", "URL"}] string Type; + [write, ValueMap{"BigInteger","Binary","Boolean","Date","DateNoYear","DateTime","Email","Float","Guid","HTML","Integer","Person","String","StringMultiValue","TimeZone","URL"}, Values{"BigInteger","Binary","Boolean","Date","DateNoYear","DateTime","Email","Float","Guid","HTML","Integer","Person","String","StringMultiValue","TimeZone","URL"}] string Type; [write] string Description ; - [write, ValueMap{"Mandatory", "Optin","Optout", "Disabled"}, Values{"Mandatory", "Optin","Optout", "Disabled"}] string PolicySetting; - [write, ValueMap{"Public", "Contacts", "Organization", "Manager", "Private"}, Values{"Public", "Contacts", "Organization", "Manager", "Private"}] string PrivacySetting ; + [write, ValueMap{"Mandatory","Optin","Optout","Disabled"}, Values{"Mandatory","Optin","Optout","Disabled"}] string PolicySetting; + [write, ValueMap{"Public","Contacts","Organization","Manager","Private"}, Values{"Public","Contacts","Organization","Manager","Private"}] string PrivacySetting ; [write] string MappingConnectionName ; [write] string MappingPropertyName ; [write] string MappingDirection ; @@ -66,7 +66,7 @@ class MSFT_xSPUserProfileProperty : OMI_BaseResource [write] boolean IsSearchable; [write] boolean UserOverridePrivacy ; [write] string TermStore ; - [write] string TermSetGroup; + [write] string TermGroup; [write] string TermSet; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 index 82f6f374b..7b6c73ebf 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.psm1 @@ -4,10 +4,10 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [parameter(Mandatory = $true)] [System.String] $AppDomain, - [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, - [parameter(Mandatory = $false)] [System.UInt32] $Port, + [parameter(Mandatory = $true)] [System.String] $AppDomain, + [parameter(Mandatory = $true)] [System.String] $WebApplication, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount @@ -40,10 +40,10 @@ function Set-TargetResource [CmdletBinding()] param ( - [parameter(Mandatory = $true)] [System.String] $AppDomain, - [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, - [parameter(Mandatory = $false)] [System.UInt32] $Port, + [parameter(Mandatory = $true)] [System.String] $AppDomain, + [parameter(Mandatory = $true)] [System.String] $WebApplication, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -78,10 +78,10 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [parameter(Mandatory = $true)] [System.String] $AppDomain, - [parameter(Mandatory = $true)] [System.String] $WebApplication, - [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, - [parameter(Mandatory = $false)] [System.UInt32] $Port, + [parameter(Mandatory = $true)] [System.String] $AppDomain, + [parameter(Mandatory = $true)] [System.String] $WebApplication, + [parameter(Mandatory = $true)] [System.String] [ValidateSet("Default","Internet","Intranet","Extranet","Custom")] $Zone, + [parameter(Mandatory = $false)] [System.String] $Port, [parameter(Mandatory = $false)] [System.Boolean] $SSL, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof index 979b41d1e..f16a1e137 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWebApplicationAppDomain/MSFT_xSPWebApplicationAppDomain.schema.mof @@ -23,7 +23,7 @@ The app prefix should still be set using the xSPAppDomain resource before this i class MSFT_xSPWebApplicationAppDomain : OMI_BaseResource { [Key] string WebApplication; - [Key, ValueMap{"Internet","Intranet","Extranet", "Custom"}, Values{"Internet","Intranet","Extranet", "Custom"}] string Zone; + [Key, ValueMap{"Default","Internet","Intranet","Extranet","Custom"}, Values{"Default","Internet","Intranet","Extranet","Custom"}] string Zone; [Required] string AppDomain; [Write] string Port; [Write] boolean SSL; From 9a3114a20d5981275bd05098691888cabfcc7e06 Mon Sep 17 00:00:00 2001 From: Camilo Date: Mon, 25 Jan 2016 04:34:49 +0000 Subject: [PATCH 60/91] still merging :( --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 12 ++++++++++++ Modules/xSharePoint/xSharePoint.psd1 | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 66d422341..188c0c314 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -32,6 +32,18 @@ function Get-xSharePointContentService() { return [Microsoft.SharePoint.Administration.SPWebService]::ContentService } + +function Get-xSharePointUserProfileSubTypeManager { + [CmdletBinding()] + param + ( + $context + ) + [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null + + return [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) +} + function Get-xSharePointInstalledProductVersion() { $pathToSearch = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\*\ISAPI\Microsoft.SharePoint.dll" $fullPath = Get-Item $pathToSearch | Sort-Object { $_.Directory } -Descending | Select-Object -First 1 diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index 669d2a1f9..c891e5e64 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -79,7 +79,8 @@ CmdletsToExport = @("Invoke-xSharePointCommand", "Test-xSharePointRunAsCredential", "Test-xSharePointUserIsLocalAdmin", "Test-xSharePointSpecificParameters", - "Set-xSharePointObjectPropertyIfValueExists") + "Set-xSharePointObjectPropertyIfValueExists", + "Get-xSharePointUserProfileSubTypeManager") # Variables to export from this module VariablesToExport = '*' From 9db65e7f1f281094af878f6578d49a47b8315e02 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 25 Jan 2016 22:58:26 +1100 Subject: [PATCH 61/91] allowing property to be created without ad property mapping --- .../MSFT_xSPUserProfileProperty.psm1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index 507257220..123ef11c1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -191,10 +191,7 @@ function Set-TargetResource $userProfileSubTypeProperties = $userProfileSubType.Properties - $syncConnection = $userProfileConfigManager.ConnectionManager | Where-Object { $_.DisplayName -eq $params.MappingConnectionName} - if($null -eq $syncConnection ) { - throw "connection not found" - } + #endregion $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) @@ -309,6 +306,10 @@ function Set-TargetResource #region mapping #Set-Mapping if($params.ContainsKey("MappingConnectionName") -and $params.ContainsKey("MappingPropertyName")){ + $syncConnection = $userProfileConfigManager.ConnectionManager | Where-Object { $_.DisplayName -eq $params.MappingConnectionName} + if($null -eq $syncConnection ) { + throw "connection not found" + } $syncConnection = $userProfileConfigManager.ConnectionManager| Where-Object { $_.DisplayName -eq $params.MappingConnectionName} #$userProfileConfigManager.ConnectionManager[$params.MappingConnectionName] $currentMapping = $syncConnection.PropertyMapping.Item($params.Name) From 0124ffdd52f25b13f97fa8039e2944ffb815cc1d Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Mon, 25 Jan 2016 23:07:55 +1100 Subject: [PATCH 62/91] updating unit tests to reflect updated flow --- Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 9b51da485..840653806 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -430,7 +430,7 @@ Describe "xSPUserProfileProperty" { {Set-TargetResource @testParamsNewProperty} | should throw "connection not found" $Global:xSPUPGetProfileSubtypeCalled | Should be $true - $Global:xSPUPGetPropertyByNameCalled | Should be $false + $Global:xSPUPGetPropertyByNameCalled | Should be $true $Global:xSPUPSMappingItemCalled | Should be $false } From fe24b58e6bad732005390ec1216e14de7e418630 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Tue, 26 Jan 2016 14:52:12 +0100 Subject: [PATCH 63/91] Refactor due to changed MOF structure and use of CIMInstance class --- .../MSFT_xSPShellAdmins.psm1 | 322 ++++++++++++------ .../MSFT_xSPShellAdmins.schema.mof | 23 ++ 2 files changed, 243 insertions(+), 102 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 index 42378274b..c7eed7b2a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -8,6 +8,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String[]] $Members, [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ContentDatabases, [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -20,6 +21,10 @@ function Get-TargetResource throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" } + if ($ContentDatabases -and $AllContentDatabases) { + throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" + } + Write-Verbose -Message "Getting all Shell Admins" $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { @@ -28,51 +33,26 @@ function Get-TargetResource $shellAdmins = Get-SPShellAdmin $allContentDatabases = $true - if ($params.AllContentDatabases) { - if ($params.Members) { - Write-Verbose -Verbose "Looping through content databases" - foreach ($contentDatabase in (Get-SPContentDatabase)) { - Write-Verbose -Verbose "Checking content database $contentDatabase" - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id - foreach ($member in $params.Members) { - if (-not $dbShellAdmins.UserName.Contains($member)) { - $allContentDatabases = $false - } - } - } - } - - if ($params.MembersToInclude) { - foreach ($contentDatabase in (Get-SPContentDatabase)) { - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id - foreach ($member in $params.MembersToInclude) { - if (-not $dbShellAdmins.UserName.Contains($member)) { - $allContentDatabases = $false - } - } - } - } - - if ($params.MembersToExclude) { - foreach ($contentDatabase in (Get-SPContentDatabase)) { - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id - foreach ($member in $params.MembersToExclude) { - if ($dbShellAdmins.UserName.Contains($member)) { - $allContentDatabases = $false - } - } - } - } - } else { - $allContentDatabases = $false - } + $cdbPermissions = @() + Write-Verbose -Verbose "Looping through content databases" + foreach ($contentDatabase in (Get-SPContentDatabase)) { + Write-Verbose -Verbose "Checking content database $contentDatabase" + $cdbPermission = @{} + + $cdbPermission.Name = $contentDatabase.Name + $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + $cdbPermission.Members = $dbShellAdmins.UserName + + $cdbPermissions += $cdbPermission + } return @{ Name = $params.Name Members = $shellAdmins.UserName MembersToInclude = $params.MembersToInclude MembersToExclude = $params.MembersToExclude - AllContentDatabases = $allContentDatabases + ContentDatabases = $cdbPermissions + AllContentDatabases = $params.AllContentDatabases InstallAccount = $params.InstallAccount } } @@ -103,6 +83,10 @@ function Set-TargetResource throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" } + if ($ContentDatabases -and $AllContentDatabases) { + throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" + } + $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] @@ -127,65 +111,111 @@ function Set-TargetResource } } } + } - if ($params.AllContentDatabases) { - foreach ($contentDatabase in (Get-SPContentDatabase)) { - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + if ($params.MembersToInclude) { + foreach ($member in $params.MembersToInclude) { + if (-not $shellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member + } + } + } - $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members + if ($params.MembersToExclude) { + foreach ($member in $params.MembersToInclude) { + if ($shellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -UserName $member -Confirm:$false + } + } + } - if ($differences -eq $null) { - Write-Verbose "Shell Admins for database $($contentDatabase.Name) group matches. No further processing required" - } else { - Write-Verbose "Shell Admins for database $($contentDatabase.Name) group does not match. Perform corrective action" + if ($params.ContentDatabases) { + # The ContentDatabases parameter is set + # Compare the configuration against the actual set and correct any issues + + foreach ($contentDatabase in $params.ContentDatabases) { + # Check if configured database exists, throw error if not + Write-Verbose "Processing Content Database: $($contentDatabase.Name)" + + $currentCDB = Get-SPContentDatabase | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() } + if ($currentCDB -ne $null) { + $dbShellAdmins = Get-SPShellAdmins -database $currentCDB.Id + if ($contentDatabase.Members) { + $differences = Compare-Object -ReferenceObject $currentCDB.Members -DifferenceObject $dbShellAdmins.UserName ForEach ($difference in $differences) { if ($difference.SideIndicator -eq "=>") { # Add account $user = $difference.InputObject - Add-SPShellAdmin -UserName $user -Database $contentDatabase.Id + Add-SPShellAdmin -database $currentCDB.Id -UserName $user } elseif ($difference.SideIndicator -eq "<=") { # Remove account $user = $difference.InputObject - Remove-SPShellAdmin -UserName $user -Database $contentDatabase.Id -Confirm:$false + Remove-SPShellAdmin -database $currentCDB.Id -UserName $user -Confirm:$false } } } - } - } - } - if ($params.MembersToInclude) { - foreach ($member in $params.MembersToInclude) { - if (-not $shellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -UserName $member - } + if ($contentDatabase.MembersToInclude) { + ForEach ($member in $contentDatabase.MembersToInclude) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member + } + } + } - if ($params.AllContentDatabases) { - foreach ($contentDatabase in (Get-SPContentDatabase)) { - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id - if (-not $dbShellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -UserName $member -Database $contentDatabase.Id + if ($contentDatabase.MembersToExclude) { + ForEach ($member in $contentDatabase.MembersToExclude) { + if ($shellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -UserName $member -Confirm:$false + } } } + } else { + throw "Specified database does not exist" } } } - if ($params.MembersToExclude) { - foreach ($member in $params.MembersToInclude) { - if ($shellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Confirm:$false + if ($params.AllContentDatabases) { + foreach ($contentDatabase in (Get-SPContentDatabase)) { + $dbShellAdmins = Get-SPShellAdmin -database $contentDatabase.Id + if ($params.Members) { + $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members + + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches. No further processing required" + } else { + Write-Verbose "Shell Admins group does not match. Perform corrective action" + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -UserName $user + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -UserName $user -Confirm:$false + } + } + } + } + + if ($params.MembersToInclude) { + foreach ($member in $params.MembersToInclude) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member + } + } } - if ($params.AllContentDatabases) { - foreach ($contentDatabase in (Get-SPContentDatabase)) { - $dbShellAdmins = Get-SPShellAdmin -Database $contentDatabase.Id + if ($params.MembersToExclude) { + foreach ($member in $params.MembersToInclude) { if ($dbShellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Database $contentDatabase.Id -Confirm:$false + Remove-SPShellAdmin -UserName $member -Confirm:$false } } } - } + } } } } @@ -205,7 +235,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) - Write-Verbose -Message "Testing Farm Administrator settings" + Write-Verbose -Message "Testing Shell Admin settings" if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" @@ -215,53 +245,141 @@ function Test-TargetResource throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" } + if ($ContentDatabases -and $AllContentDatabases) { + throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" + } + + # Start checking $CurrentValues = Get-TargetResource @PSBoundParameters if ($null -eq $CurrentValues) { return $false } - - if ($CurrentValues.AllContentDatabases -eq $AllContentDatabases) { - if ($Members) { - Write-Verbose "Processing Members parameter" - $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members - if ($differences -eq $null) { - Write-Verbose "Shell Admins group matches" - return $true - } else { - Write-Verbose "Shell Admins group does not match" + if ($Members) { + Write-Verbose "Processing Members parameter" + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members + + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches" + } else { + Write-Verbose "Shell Admins group does not match" + return $false + } + } + + if ($MembersToInclude) { + Write-Verbose "Processing MembersToInclude parameter" + ForEach ($member in $MembersToInclude) { + if (-not($CurrentValues.Members.Contains($member))) { + Write-Verbose "$member is not a Shell Admin. Set result to false" return $false + } else { + Write-Verbose "$member is already a Shell Admin. Skipping" } } + } - $result = $true - if ($MembersToInclude) { - Write-Verbose "Processing MembersToInclude parameter" - ForEach ($member in $MembersToInclude) { - if (-not($CurrentValues.Members.Contains($member))) { - Write-Verbose "$member is not a Shell Admin. Set result to false" - $result = $false + if ($MembersToExclude) { + Write-Verbose "Processing MembersToExclude parameter" + ForEach ($member in $MembersToExclude) { + if ($CurrentValues.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } + } + } + + if ($AllContentDatabases) { + # The AllContentDatabases parameter is set + # Check the Members group against all databases + + foreach ($contentDatabase in $CurrentValues.ContentDatabases) { + # Check if configured database exists, throw error if not + Write-Verbose "Processing Content Database: $($contentDatabase.Name)" + + if ($Members) { + $differences = Compare-Object -ReferenceObject $contentDatabase.Members -DifferenceObject $Members + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches" } else { - Write-Verbose "$member is already a Shell Admin. Skipping" + Write-Verbose "Shell Admins group does not match" + return $false } } - } - if ($MembersToExclude) { - Write-Verbose "Processing MembersToExclude parameter" - ForEach ($member in $MembersToExclude) { - if ($CurrentValues.Members.Contains($member)) { - Write-Verbose "$member is a Shell Admin. Set result to false" - $result = $false - } else { - Write-Verbose "$member is not a Shell Admin. Skipping" + if ($MembersToInclude) { + ForEach ($member in $MembersToInclude) { + if (-not($contentDatabase.Members.Contains($member))) { + Write-Verbose "$member is not a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is already a Shell Admin. Skipping" + } + } + } + + if ($MembersToExclude) { + ForEach ($member in $MembersToExclude) { + if ($contentDatabase.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } } } } + } + + if ($ContentDatabases) { + # The ContentDatabases parameter is set + # Compare the configuration against the actual set + + foreach ($contentDatabase in $ContentDatabases) { + # Check if configured database exists, throw error if not + Write-Verbose "Processing Content Database: $($contentDatabase.Name)" - return $result - } else { - return $false + $currentCDB = $CurrentValues.ContentDatabases | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() } + if ($currentCDB -ne $null) { + if ($contentDatabase.Members) { + $differences = Compare-Object -ReferenceObject $currentCDB.Members -DifferenceObject $contentDatabase.Members + if ($differences -eq $null) { + Write-Verbose "Shell Admins group matches" + } else { + Write-Verbose "Shell Admins group does not match" + return $false + } + } + + if ($contentDatabase.MembersToInclude) { + ForEach ($member in $contentDatabase.MembersToInclude) { + if (-not($currentCDB.Members.Contains($member))) { + Write-Verbose "$member is not a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is already a Shell Admin. Skipping" + } + } + } + + if ($contentDatabase.MembersToExclude) { + ForEach ($member in $contentDatabase.MembersToExclude) { + if ($currentCDB.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } + } + } + } else { + throw "Specified database does not exist" + } + } } + + return $true } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof index 3a30fe8e5..18532bee3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof @@ -14,8 +14,30 @@ The "MembersToInclude" and "MembersToExclude" properties will allow you to contr Members = "CONTOSO\user1", "CONTOSO\user2" AllContentDatabases = $true } + + xSPShellAdmins ShellAdmins + { + Name = "Shell Admins" + Members = "CONTOSO\user1", "CONTOSO\user2" + ContentDatabases = [{ + Name = "SharePoint_Content" + Members = "CONTOSO\user3", "CONTOSO\user4" + }, { + Name = "SharePoint_Content2" + Members = "CONTOSO\user5", "CONTOSO\user6" + }] + } */ +[ClassVersion("1.0.0")] +Class MSFT_xSPContentDatabasePermissions +{ + [write]String Name; + [Write] String Members[]; + [Write] String MembersToInclude[]; + [Write] String MembersToExclude[]; +}; + [ClassVersion("1.0.0.0"), FriendlyName("xSPShellAdmins")] class MSFT_xSPShellAdmins : OMI_BaseResource { @@ -23,6 +45,7 @@ class MSFT_xSPShellAdmins : OMI_BaseResource [Write] String Members[]; [Write] String MembersToInclude[]; [Write] String MembersToExclude[]; + [Write, EmbeddedInstance("MSFT_xSPContentDatabasePermissions")] String ContentDatabases; [Write] Boolean AllContentDatabases; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From f77fab000074b1e47333a9e1a7c3263b60acf225 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 27 Jan 2016 15:27:39 +0100 Subject: [PATCH 64/91] Bugfixes during testing, commit for final test --- .../MSFT_xSPShellAdmins.psm1 | 184 ++++++++++++------ .../MSFT_xSPShellAdmins.schema.mof | 25 ++- 2 files changed, 139 insertions(+), 70 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 index c7eed7b2a..2b1e91a4c 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -8,7 +8,7 @@ function Get-TargetResource [parameter(Mandatory = $false)] [System.String[]] $Members, [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, - [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance] $ContentDatabases, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases, [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -34,9 +34,7 @@ function Get-TargetResource $allContentDatabases = $true $cdbPermissions = @() - Write-Verbose -Verbose "Looping through content databases" foreach ($contentDatabase in (Get-SPContentDatabase)) { - Write-Verbose -Verbose "Checking content database $contentDatabase" $cdbPermission = @{} $cdbPermission.Name = $contentDatabase.Name @@ -69,6 +67,7 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.String[]] $Members, [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases, [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -93,38 +92,55 @@ function Set-TargetResource $shellAdmins = Get-SPShellAdmin if ($params.Members) { - $differences = Compare-Object -ReferenceObject $shellAdmins.UserName -DifferenceObject $params.Members + Write-Verbose -Verbose "Processing Members" + if ($shellAdmins) { + $differences = Compare-Object -ReferenceObject $shellAdmins.UserName -DifferenceObject $params.Members - if ($differences -eq $null) { - Write-Verbose "Shell Admins group matches. No further processing required" - } else { - Write-Verbose "Shell Admins group does not match. Perform corrective action" - ForEach ($difference in $differences) { - if ($difference.SideIndicator -eq "=>") { - # Add account - $user = $difference.InputObject - Add-SPShellAdmin -UserName $user - } elseif ($difference.SideIndicator -eq "<=") { - # Remove account - $user = $difference.InputObject - Remove-SPShellAdmin -UserName $user -Confirm:$false + if ($differences -eq $null) { + Write-Verbose -Verbose "Shell Admins group matches. No further processing required" + } else { + Write-Verbose -Verbose "Shell Admins group does not match. Perform corrective action" + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -UserName $user + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -UserName $user -Confirm:$false + } } } + } else { + foreach ($member in $params.Members) { + Add-SPShellAdmin -UserName $member + } } } if ($params.MembersToInclude) { - foreach ($member in $params.MembersToInclude) { - if (-not $shellAdmins.UserName.Contains($member)) { + Write-Verbose -Verbose "Processing MembersToInclude" + if ($shellAdmins) { + foreach ($member in $params.MembersToInclude) { + if (-not $shellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -UserName $member + } + } + } else { + foreach ($member in $params.MembersToInclude) { Add-SPShellAdmin -UserName $member } } } if ($params.MembersToExclude) { - foreach ($member in $params.MembersToInclude) { - if ($shellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Confirm:$false + Write-Verbose -Verbose "Processing MembersToExclude" + if (-not $shellAdmins) { + foreach ($member in $params.MembersToInclude) { + if ($shellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -UserName $member -Confirm:$false + } } } } @@ -135,38 +151,56 @@ function Set-TargetResource foreach ($contentDatabase in $params.ContentDatabases) { # Check if configured database exists, throw error if not - Write-Verbose "Processing Content Database: $($contentDatabase.Name)" + Write-Verbose -Verbose "Processing Content Database: $($contentDatabase.Name)" $currentCDB = Get-SPContentDatabase | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() } if ($currentCDB -ne $null) { - $dbShellAdmins = Get-SPShellAdmins -database $currentCDB.Id + $dbShellAdmins = Get-SPShellAdmin -database $currentCDB.Id + if ($contentDatabase.Members) { - $differences = Compare-Object -ReferenceObject $currentCDB.Members -DifferenceObject $dbShellAdmins.UserName - ForEach ($difference in $differences) { - if ($difference.SideIndicator -eq "=>") { - # Add account - $user = $difference.InputObject - Add-SPShellAdmin -database $currentCDB.Id -UserName $user - } elseif ($difference.SideIndicator -eq "<=") { - # Remove account - $user = $difference.InputObject - Remove-SPShellAdmin -database $currentCDB.Id -UserName $user -Confirm:$false + Write-Verbose -Verbose "Processing Members" + if ($dbShellAdmins) { + $differences = Compare-Object -ReferenceObject $contentDatabase.Members -DifferenceObject $dbShellAdmins.UserName + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "<=") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -database $currentCDB.Id -UserName $user + } elseif ($difference.SideIndicator -eq "=>") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -database $currentCDB.Id -UserName $user -Confirm:$false + } + } + } else { + Foreach ($member in $contentDatabase.Members) { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member } } } if ($contentDatabase.MembersToInclude) { - ForEach ($member in $contentDatabase.MembersToInclude) { - if (-not $dbShellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -UserName $member + Write-Verbose -Verbose "Processing MembersToInclude" + if ($dbShellAdmins) { + ForEach ($member in $contentDatabase.MembersToInclude) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member + } + } + } else { + ForEach ($member in $contentDatabase.MembersToInclude) { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member } } } if ($contentDatabase.MembersToExclude) { - ForEach ($member in $contentDatabase.MembersToExclude) { - if ($shellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Confirm:$false + Write-Verbose -Verbose "Processing MembersToExclude" + if ($dbShellAdmins) { + ForEach ($member in $contentDatabase.MembersToExclude) { + if ($dbShellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -database $currentCDB.Id -UserName $member -Confirm:$false + } } } } @@ -180,38 +214,54 @@ function Set-TargetResource foreach ($contentDatabase in (Get-SPContentDatabase)) { $dbShellAdmins = Get-SPShellAdmin -database $contentDatabase.Id if ($params.Members) { - $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members + Write-Verbose -Verbose "PRocessing CDB: $($contentDatabase.Name)" + if ($dbShellAdmins) { + $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members - if ($differences -eq $null) { - Write-Verbose "Shell Admins group matches. No further processing required" - } else { - Write-Verbose "Shell Admins group does not match. Perform corrective action" - ForEach ($difference in $differences) { - if ($difference.SideIndicator -eq "=>") { - # Add account - $user = $difference.InputObject - Add-SPShellAdmin -UserName $user - } elseif ($difference.SideIndicator -eq "<=") { - # Remove account - $user = $difference.InputObject - Remove-SPShellAdmin -UserName $user -Confirm:$false + if ($differences -eq $null) { + Write-Verbose -Verbose "Shell Admins group matches. No further processing required" + } else { + Write-Verbose -Verbose "Shell Admins group does not match. Perform corrective action" + ForEach ($difference in $differences) { + if ($difference.SideIndicator -eq "=>") { + # Add account + $user = $difference.InputObject + Add-SPShellAdmin -database $contentDatabase.Id -UserName $user + } elseif ($difference.SideIndicator -eq "<=") { + # Remove account + $user = $difference.InputObject + Remove-SPShellAdmin -database $contentDatabase.Id -UserName $user -Confirm:$false + } } } + } else { + Foreach ($member in $params.Members) { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + } } } if ($params.MembersToInclude) { - foreach ($member in $params.MembersToInclude) { - if (-not $dbShellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -UserName $member + if ($dbShellAdmins) { + foreach ($member in $params.MembersToInclude) { + if (-not $dbShellAdmins.UserName.Contains($member)) { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + } + } + } else { + foreach ($member in $params.MembersToInclude) { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member } + } } if ($params.MembersToExclude) { - foreach ($member in $params.MembersToInclude) { - if ($dbShellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Confirm:$false + if (-not $dbShellAdmins) { + foreach ($member in $params.MembersToInclude) { + if ($dbShellAdmins.UserName.Contains($member)) { + Remove-SPShellAdmin -database $contentDatabase.Id -UserName $member -Confirm:$false + } } } } @@ -231,6 +281,7 @@ function Test-TargetResource [parameter(Mandatory = $false)] [System.String[]] $Members, [parameter(Mandatory = $false)] [System.String[]] $MembersToInclude, [parameter(Mandatory = $false)] [System.String[]] $MembersToExclude, + [parameter(Mandatory = $false)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases, [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount ) @@ -256,6 +307,8 @@ function Test-TargetResource if ($Members) { Write-Verbose "Processing Members parameter" + if ($CurrentValues.Members) { return $false } + $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members if ($differences -eq $null) { @@ -268,6 +321,8 @@ function Test-TargetResource if ($MembersToInclude) { Write-Verbose "Processing MembersToInclude parameter" + if ($CurrentValues.Members) { return $false } + ForEach ($member in $MembersToInclude) { if (-not($CurrentValues.Members.Contains($member))) { Write-Verbose "$member is not a Shell Admin. Set result to false" @@ -299,6 +354,8 @@ function Test-TargetResource Write-Verbose "Processing Content Database: $($contentDatabase.Name)" if ($Members) { + if ($contentDatabase.Members) { return $false } + $differences = Compare-Object -ReferenceObject $contentDatabase.Members -DifferenceObject $Members if ($differences -eq $null) { Write-Verbose "Shell Admins group matches" @@ -309,6 +366,8 @@ function Test-TargetResource } if ($MembersToInclude) { + if ($contentDatabase.Members) { return $false } + ForEach ($member in $MembersToInclude) { if (-not($contentDatabase.Members.Contains($member))) { Write-Verbose "$member is not a Shell Admin. Set result to false" @@ -343,6 +402,8 @@ function Test-TargetResource $currentCDB = $CurrentValues.ContentDatabases | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() } if ($currentCDB -ne $null) { if ($contentDatabase.Members) { + if ($currentCDB.Members) { return $false } + $differences = Compare-Object -ReferenceObject $currentCDB.Members -DifferenceObject $contentDatabase.Members if ($differences -eq $null) { Write-Verbose "Shell Admins group matches" @@ -353,6 +414,8 @@ function Test-TargetResource } if ($contentDatabase.MembersToInclude) { + if ($currentCDB.Members) { return $false } + ForEach ($member in $contentDatabase.MembersToInclude) { if (-not($currentCDB.Members.Contains($member))) { Write-Verbose "$member is not a Shell Admin. Set result to false" @@ -384,4 +447,3 @@ function Test-TargetResource Export-ModuleMember -Function *-TargetResource - diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof index 18532bee3..5efb58bbd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof @@ -19,20 +19,27 @@ The "MembersToInclude" and "MembersToExclude" properties will allow you to contr { Name = "Shell Admins" Members = "CONTOSO\user1", "CONTOSO\user2" - ContentDatabases = [{ - Name = "SharePoint_Content" - Members = "CONTOSO\user3", "CONTOSO\user4" - }, { - Name = "SharePoint_Content2" - Members = "CONTOSO\user5", "CONTOSO\user6" - }] + ContentDatabases = @( + @(MSFT_xSPContentDatabasePermissions { + Name = "SharePoint_Content_1" + Members = "CONTOSO\user2", "CONTOSO\user3" + }) + @(MSFT_xSPContentDatabasePermissions { + Name = "SharePoint_Content_2" + Members = "CONTOSO\user3", "CONTOSO\user4" + }) + ) } + +################ Import-DSCResource -Module xSharePoint is required to import the custom class!! +################ Note: If the farm account is the owner of a database, you cannot add it to the Shell Admins (common with AllContentDatabases parameter). Workaround: Change database owner. + */ [ClassVersion("1.0.0")] Class MSFT_xSPContentDatabasePermissions { - [write]String Name; + [Write] String Name; [Write] String Members[]; [Write] String MembersToInclude[]; [Write] String MembersToExclude[]; @@ -45,7 +52,7 @@ class MSFT_xSPShellAdmins : OMI_BaseResource [Write] String Members[]; [Write] String MembersToInclude[]; [Write] String MembersToExclude[]; - [Write, EmbeddedInstance("MSFT_xSPContentDatabasePermissions")] String ContentDatabases; + [Write, EmbeddedInstance("MSFT_xSPContentDatabasePermissions")] String ContentDatabases[]; [Write] Boolean AllContentDatabases; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From 7ec4b78e5d4b0954d6fd120be2187de81b252bae Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 28 Jan 2016 09:44:08 +1100 Subject: [PATCH 65/91] addressing Brian's requests. (meaningful msg, unreleased section). --- .../MSFT_xSPUserProfileProperty.psm1 | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 index c4532499a..2f77a9432 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 @@ -178,7 +178,7 @@ function Set-TargetResource $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) if($null -eq $userProfileConfigManager) { #if config manager returns when ups is available then isuee is permissions - throw "account running process needs permissions" + throw "account running process needs admin permissions on the user profile service application" } $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties() diff --git a/README.md b/README.md index 05403ad08..3da85860f 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ Additional detailed documentation is included on the wiki on GitHub. ### Unreleased * Added xSPWordAutomationServiceApp resources - * Added xSPHealthAnalyzerRuleState resources + * Added xSPUserProfileProperty ### 0.9.0.0 From fb2467d5aeefe79a7f2d35102062f5ea0aee5515 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 28 Jan 2016 09:51:42 +1100 Subject: [PATCH 66/91] adding unreleased section and fixing Method declaration(making parameters Pascal case( --- .../xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 2 +- README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 7c5c1c49d..0f1cc88a3 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -32,7 +32,7 @@ function Get-xSharePointServiceContext { param ( [parameter(Mandatory = $true,Position=1)] - $proxyGroup + $ProxyGroup ) Write-Verbose "Getting SPContext for Proxy group $($proxyGroup)" return [Microsoft.SharePoint.SPServiceContext]::GetContext($proxyGroup,[Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default) diff --git a/README.md b/README.md index 05403ad08..91fa4ff55 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ Additional detailed documentation is included on the wiki on GitHub. * Added xSPHealthAnalyzerRuleState resources + * Added xSPUserProfileSyncConnection ### 0.9.0.0 * Added xSPAppCatalog, xSPAppDomain, xSPWebApplicationAppDomain, xSPSessionStateService, xSPDesignerSettings, xSPQuotaTemplate, xSPWebAppSiteUseAndDeletion, xSPSearchTopology, xSPSearchIndexPartition, xSPWebAppPolicy and xSPTimerJobState resources From 8b4d2d2e5d66862ba62a1263998c64d5abc10623 Mon Sep 17 00:00:00 2001 From: Camilo Borges Date: Thu, 28 Jan 2016 23:28:33 +1100 Subject: [PATCH 67/91] adding extra parameters to xSPWorkManagementApp. Unit tests updated but no test done. --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 111 +++++++++++++++--- ...SFT_xSPWorkManagementServiceApp.schema.mof | 13 ++ README.md | 2 + ...oint.xSPWorkManagementServiceApp.Tests.ps1 | 57 +++++++-- 4 files changed, 159 insertions(+), 24 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index a7b441f40..cce08b404 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -6,7 +6,14 @@ function Get-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenSearchQueries, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfSubscriptionSyncsPerEwsSyncRun, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) Write-Verbose -Message "Getting Work management service app '$Name'" @@ -40,36 +47,99 @@ function Set-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenSearchQueries, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfSubscriptionSyncsPerEwsSyncRun, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) $result = Get-TargetResource @PSBoundParameters - + $setParameters = @( + "ApplicationPool", + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch" + ) + $newParamters = @( + "ApplicationPool", + "Name" + ) if ($result -eq $null) { Write-Verbose -Message "Creating work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters, $newParameters ) -ScriptBlock { $params = $args[0] - - - $appService = New-SPWorkManagementServiceApplication @params + $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} + $newParams = $params.GetEnumerator() | ? {$args[2] -contains $_.Name} + $appService = New-SPWorkManagementServiceApplication @newParams New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches + } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes + } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } + $setParams.Add("Confirm", $false) + Set-SPWorkManagementServiceApplicationProxy @setPArams | Out-Null } - } - else { - if ($ApplicationPool -ne $result.ApplicationPool) { + + #} + }else { + if ($Ensure -eq "Absent") { + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + Remove-SPServiceApplication $appService + }else{ Write-Verbose -Message "Updating Work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters ) -ScriptBlock { + $params = $args[0] + $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} + #$appService = Get-SPServiceApplication -Name $params.Name ` + # | Where-Object { $_.TypeName -eq "Work Management Service Application" } + $setParams.Add("Confirm", $false) + <#$appPool=$null + if($setParams.ContainsKey("ApplicationPool")){ + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + $setParams.ApplicationPool = $appPool + }#> + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches + } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes + } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } + + Set-SPWorkManagementServiceApplication @setPArams | Out-Null + } + <# Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - $AppService = Get-SPServiceApplication -Name $params.Name ` + $appService = Get-SPServiceApplication -Name $params.Name ` | Where-Object { $_.TypeName -eq "Work Management Service Application" } $AppService.ApplicationPool = $appPool $AppService.Update() - } + }#> } } } +#} + + function Test-TargetResource { @@ -79,13 +149,26 @@ function Test-TargetResource ( [parameter(Mandatory = $true)] [System.String] $Name, [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, + [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenSearchQueries, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfSubscriptionSyncsPerEwsSyncRun, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, + [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) Write-Verbose -Message "Testing for App management Service Application '$Name'" $CurrentValues = Get-TargetResource @PSBoundParameters + if ($null -eq $CurrentValues) { return $false + }else{ + if($Ensure -eq "Absent") + { #Ensure = Absent doesn't care state + return $true + } + } - if ($null -eq $CurrentValues) { return $false } return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof index 1c086a6c0..4ea910359 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof @@ -6,19 +6,32 @@ It will identify an instance of the work management service application through Currently the resource will provision the app if it does not yet exist, and will change the application pool associated to the app if it does not match the configuration. +Remarks +- Parameters MinimumTimeBetweenEwsSyncSubscriptionSearches, MinimumTimeBetweenProviderRefreshes, MinimumTimeBetweenSearchQueries are in Minutes + + + **Example** xSPWorkManagementServiceApp WorkManagementServiceApp { Name = "App Management Service Application" AppPool = "SharePoint web services" + MinimumTimeBetweenEwsSyncSubscriptionSearches = 10 } */ [ClassVersion("1.0.0.0"), FriendlyName("WorkManagementServiceApp")] class MSFT_WorkManagementServiceApp : OMI_BaseResource { [Key] string Name; + [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Required] String ApplicationPool; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Write] System.UInt32 MinimumTimeBetweenEwsSyncSubscriptionSearches; + [Write] System.UInt32 MinimumTimeBetweenProviderRefreshes; + [Write] System.UInt32 MinimumTimeBetweenSearchQueries; + [Write] System.UInt32 NumberOfSubscriptionSyncsPerEwsSyncRun; + [Write] System.UInt32 NumberOfUsersEwsSyncWillProcessAtOnce; + [Write] System.UInt32 NumberOfUsersPerEwsSyncBatch; }; diff --git a/README.md b/README.md index 05403ad08..6d45e84f8 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ Additional detailed documentation is included on the wiki on GitHub. * Added xSPWordAutomationServiceApp resources * Added xSPHealthAnalyzerRuleState resources + + * Added xSPWorkManagementApp ### 0.9.0.0 diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 index e7acac80d..84463a967 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 @@ -18,6 +18,17 @@ Describe "xSPWorkManagement" { Name = "Test Work Management App" ApplicationPool = "Test App Pool" } + $testParamsComplete = @{ + Name = "Test Work Management App" + ApplicationPool = "Test App Pool" + MinimumTimeBetweenEwsSyncSubscriptionSearches =10 + MinimumTimeBetweenProviderRefreshes=10 + MinimumTimeBetweenSearchQueries=10 + NumberOfSubscriptionSyncsPerEwsSyncRun=5 + NumberOfUsersEwsSyncWillProcessAtOnce=5 + NumberOfUsersPerEwsSyncBatch=500 + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -31,6 +42,8 @@ Describe "xSPWorkManagement" { Mock Get-SPServiceApplication { return $null } Mock New-SPWorkManagementServiceApplication { } + Mock Set-SPWorkManagementServiceApplication { } + Mock New-SPWorkManagementServiceApplicationProxy { } It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty @@ -48,6 +61,9 @@ Describe "xSPWorkManagement" { } Context "When service applications exist in the current farm but the specific Work Management app does not" { + Mock Set-SPWorkManagementServiceApplication { } + Mock New-SPWorkManagementServiceApplication { } + Mock New-SPWorkManagementServiceApplicationProxy { } Mock Get-SPServiceApplication { return @(@{ TypeName = "Some other service app type" @@ -56,6 +72,7 @@ Describe "xSPWorkManagement" { It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Set-SPWorkManagementServiceApplication -ParameterFilter { $Name -eq $testParams.Name } } } @@ -85,23 +102,43 @@ Describe "xSPWorkManagement" { TypeName = "Work Management Service Application" DisplayName = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } - })| Add-Member ScriptMethod Update { - $Global:xSPServiceApplicationUpdateCalled = $true - } -PassThru + }) } - Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } } + Mock Set-SPWorkManagementServiceApplication { } It "returns false when the Test method is called" { - Test-TargetResource @testParams | Should Be $false + Test-TargetResource @testParamsComplete | Should Be $false } It "calls the update service app cmdlet from the set method" { - $Global:xSPServiceApplicationUpdateCalled = $false - Set-TargetResource @testParams - Assert-MockCalled Get-SPServiceApplicationPool - $Global:xSPServiceApplicationUpdateCalled | Should be $true - + Set-TargetResource @testParamsComplete + Assert-MockCalled Set-SPWorkManagementServiceApplication + Assert-MockCalled Get-SPWorkManagementServiceApplication } } + Context "When a service application exists and Ensure equals 'absent'" { + $testParamsAbsent = @{ + Name = "Test Work Management App" + Ensure = "Absent" + } + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParamsAbsent.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + }) + } + Mock Remove-SPServiceApplication{ } + + It "returns false when the Test method is called" { + Test-TargetResource $testParamsAbsent | Should Be $false + } + + It "calls the update service app cmdlet from the set method" { + Set-TargetResource $testParamsAbsent + Assert-MockCalled Remove-SPServiceApplication + } + } + } } From 6dee6dc37172de06d29e1fee93295dcd64f2321f Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 28 Jan 2016 15:04:20 +0100 Subject: [PATCH 68/91] Created tests and fixed some more bugs. Now ready for PR. --- .../MSFT_xSPShellAdmins.psm1 | 139 ++-- Tests/Tests.pssproj | 1 + .../xSharePoint.xSPShellAdmins.Tests.ps1 | 704 ++++++++++++++++++ 3 files changed, 797 insertions(+), 47 deletions(-) create mode 100644 Tests/xSharePoint/xSharePoint.xSPShellAdmins.Tests.ps1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 index 2b1e91a4c..c90d1f0ad 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -14,15 +14,32 @@ function Get-TargetResource ) if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { - Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + Write-Verbose -Verbose "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + return $null } - if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { - throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + if ($ContentDatabases) { + foreach ($contentDatabase in $ContentDatabases) { + if ($contentDatabase.Members -and (($contentDatabase.MembersToInclude) -or ($contentDatabase.MembersToExclude))) { + Write-Verbose -Verbose "ContentDatabases: Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + return $null + } + + if (!$contentDatabase.Members -and !$contentDatabase.MembersToInclude -and !$contentDatabase.MembersToExclude) { + Write-Verbose -Verbose "ContentDatabases: At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + return $null + } + } + } else { + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + Write-Verbose -Verbose "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + return $null + } } if ($ContentDatabases -and $AllContentDatabases) { - throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" + Write-Verbose -Verbose "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" + return $null } Write-Verbose -Message "Getting all Shell Admins" @@ -30,6 +47,13 @@ function Get-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + try { + $spFarm = Get-SPFarm + } catch { + Write-Verbose -Verbose "No local SharePoint farm was detected. Health Analyzer Rule settings will not be applied" + return $null + } + $shellAdmins = Get-SPShellAdmin $allContentDatabases = $true @@ -78,8 +102,20 @@ function Set-TargetResource Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" } - if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { - throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + if ($ContentDatabases) { + foreach ($contentDatabase in $ContentDatabases) { + if ($contentDatabase.Members -and (($contentDatabase.MembersToInclude) -or ($contentDatabase.MembersToExclude))) { + throw "ContentDatabases: Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + + if (!$contentDatabase.Members -and !$contentDatabase.MembersToInclude -and !$contentDatabase.MembersToExclude) { + throw "ContentDatabases: At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + } + } else { + if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { + throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } } if ($ContentDatabases -and $AllContentDatabases) { @@ -89,6 +125,13 @@ function Set-TargetResource $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] + try { + $spFarm = Get-SPFarm + } catch { + throw "No local SharePoint farm was detected. Health Analyzer Rule settings will not be applied" + return + } + $shellAdmins = Get-SPShellAdmin if ($params.Members) { @@ -136,8 +179,8 @@ function Set-TargetResource if ($params.MembersToExclude) { Write-Verbose -Verbose "Processing MembersToExclude" - if (-not $shellAdmins) { - foreach ($member in $params.MembersToInclude) { + if ($shellAdmins) { + foreach ($member in $params.MembersToExclude) { if ($shellAdmins.UserName.Contains($member)) { Remove-SPShellAdmin -UserName $member -Confirm:$false } @@ -146,6 +189,7 @@ function Set-TargetResource } if ($params.ContentDatabases) { + Write-Verbose "Processing ContentDatabases parameter" # The ContentDatabases parameter is set # Compare the configuration against the actual set and correct any issues @@ -211,10 +255,12 @@ function Set-TargetResource } if ($params.AllContentDatabases) { + Write-Verbose "Processing AllContentDatabases parameter" + foreach ($contentDatabase in (Get-SPContentDatabase)) { $dbShellAdmins = Get-SPShellAdmin -database $contentDatabase.Id if ($params.Members) { - Write-Verbose -Verbose "PRocessing CDB: $($contentDatabase.Name)" + Write-Verbose -Verbose "Processing Content Database: $($contentDatabase.Name)" if ($dbShellAdmins) { $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members @@ -257,8 +303,8 @@ function Set-TargetResource } if ($params.MembersToExclude) { - if (-not $dbShellAdmins) { - foreach ($member in $params.MembersToInclude) { + if ($dbShellAdmins) { + foreach ($member in $params.MembersToExclude) { if ($dbShellAdmins.UserName.Contains($member)) { Remove-SPShellAdmin -database $contentDatabase.Id -UserName $member -Confirm:$false } @@ -287,18 +333,6 @@ function Test-TargetResource ) Write-Verbose -Message "Testing Shell Admin settings" - - if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) { - Throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" - } - - if (!$Members -and !$MembersToInclude -and !$MembersToExclude) { - throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" - } - - if ($ContentDatabases -and $AllContentDatabases) { - throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter" - } # Start checking $CurrentValues = Get-TargetResource @PSBoundParameters @@ -307,7 +341,7 @@ function Test-TargetResource if ($Members) { Write-Verbose "Processing Members parameter" - if ($CurrentValues.Members) { return $false } + if (-not $CurrentValues.Members) { return $false } $differences = Compare-Object -ReferenceObject $CurrentValues.Members -DifferenceObject $Members @@ -321,7 +355,7 @@ function Test-TargetResource if ($MembersToInclude) { Write-Verbose "Processing MembersToInclude parameter" - if ($CurrentValues.Members) { return $false } + if (-not $CurrentValues.Members) { return $false } ForEach ($member in $MembersToInclude) { if (-not($CurrentValues.Members.Contains($member))) { @@ -335,12 +369,14 @@ function Test-TargetResource if ($MembersToExclude) { Write-Verbose "Processing MembersToExclude parameter" - ForEach ($member in $MembersToExclude) { - if ($CurrentValues.Members.Contains($member)) { - Write-Verbose "$member is a Shell Admin. Set result to false" - return $false - } else { - Write-Verbose "$member is not a Shell Admin. Skipping" + if ($CurrentValues.Members) { + ForEach ($member in $MembersToExclude) { + if ($CurrentValues.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } } } } @@ -348,13 +384,14 @@ function Test-TargetResource if ($AllContentDatabases) { # The AllContentDatabases parameter is set # Check the Members group against all databases + Write-Verbose "Processing AllContentDatabases parameter" foreach ($contentDatabase in $CurrentValues.ContentDatabases) { # Check if configured database exists, throw error if not Write-Verbose "Processing Content Database: $($contentDatabase.Name)" if ($Members) { - if ($contentDatabase.Members) { return $false } + if (-not $contentDatabase.Members) { return $false } $differences = Compare-Object -ReferenceObject $contentDatabase.Members -DifferenceObject $Members if ($differences -eq $null) { @@ -366,7 +403,7 @@ function Test-TargetResource } if ($MembersToInclude) { - if ($contentDatabase.Members) { return $false } + if (-not $contentDatabase.Members) { return $false } ForEach ($member in $MembersToInclude) { if (-not($contentDatabase.Members.Contains($member))) { @@ -379,12 +416,14 @@ function Test-TargetResource } if ($MembersToExclude) { - ForEach ($member in $MembersToExclude) { - if ($contentDatabase.Members.Contains($member)) { - Write-Verbose "$member is a Shell Admin. Set result to false" - return $false - } else { - Write-Verbose "$member is not a Shell Admin. Skipping" + if ($contentDatabase.Members) { + ForEach ($member in $MembersToExclude) { + if ($contentDatabase.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } } } } @@ -394,6 +433,7 @@ function Test-TargetResource if ($ContentDatabases) { # The ContentDatabases parameter is set # Compare the configuration against the actual set + Write-Verbose "Processing ContentDatabases parameter" foreach ($contentDatabase in $ContentDatabases) { # Check if configured database exists, throw error if not @@ -402,7 +442,8 @@ function Test-TargetResource $currentCDB = $CurrentValues.ContentDatabases | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() } if ($currentCDB -ne $null) { if ($contentDatabase.Members) { - if ($currentCDB.Members) { return $false } + Write-Verbose "Processing Members parameter" + if (-not $currentCDB.Members) { return $false } $differences = Compare-Object -ReferenceObject $currentCDB.Members -DifferenceObject $contentDatabase.Members if ($differences -eq $null) { @@ -414,7 +455,8 @@ function Test-TargetResource } if ($contentDatabase.MembersToInclude) { - if ($currentCDB.Members) { return $false } + Write-Verbose "Processing MembersToInclude parameter" + if (-not $currentCDB.Members) { return $false } ForEach ($member in $contentDatabase.MembersToInclude) { if (-not($currentCDB.Members.Contains($member))) { @@ -427,12 +469,15 @@ function Test-TargetResource } if ($contentDatabase.MembersToExclude) { - ForEach ($member in $contentDatabase.MembersToExclude) { - if ($currentCDB.Members.Contains($member)) { - Write-Verbose "$member is a Shell Admin. Set result to false" - return $false - } else { - Write-Verbose "$member is not a Shell Admin. Skipping" + Write-Verbose "Processing MembersToExclude parameter" + if ($currentCDB.Members) { + ForEach ($member in $contentDatabase.MembersToExclude) { + if ($currentCDB.Members.Contains($member)) { + Write-Verbose "$member is a Shell Admin. Set result to false" + return $false + } else { + Write-Verbose "$member is not a Shell Admin. Skipping" + } } } } diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj index ca695e6e9..52a4652c5 100644 --- a/Tests/Tests.pssproj +++ b/Tests/Tests.pssproj @@ -67,6 +67,7 @@ + diff --git a/Tests/xSharePoint/xSharePoint.xSPShellAdmins.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPShellAdmins.Tests.ps1 new file mode 100644 index 000000000..dfd3b342c --- /dev/null +++ b/Tests/xSharePoint/xSharePoint.xSPShellAdmins.Tests.ps1 @@ -0,0 +1,704 @@ +[CmdletBinding()] +param( + [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve) +) + +$ErrorActionPreference = 'stop' +Set-StrictMode -Version latest + +$RepoRoot = (Resolve-Path $PSScriptRoot\..\..).Path +$Global:CurrentSharePointStubModule = $SharePointCmdletModule + +$ModuleName = "MSFT_xSPShellAdmins" +Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources\$ModuleName\$ModuleName.psm1") + +Describe "xSPShellAdmins" { + InModuleScope $ModuleName { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + } + Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") + + + Mock Invoke-xSharePointCommand { + return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope + } + + Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + + Context "The server is not part of SharePoint farm" { + Mock Get-SPFarm { throw "Unable to detect local farm" } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "throws an exception in the set method to say there is no local farm" { + { Set-TargetResource @testParams } | Should throw "No local SharePoint farm was detected" + } + } + + Context "Members and MembersToInclude parameters used simultaniously - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + MembersToInclude = "contoso\user1", "contoso\user2" + } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + } + + Context "None of the Members, MembersToInclude and MembersToExclude parameters are used - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + } + + Context "Members and MembersToInclude parameters used simultaniously - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + Members = "contoso\user1", "contoso\user2" + MembersToInclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "ContentDatabases: Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters" + } + } + + Context "None of the Members, MembersToInclude and MembersToExclude parameters are used - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + } -ClientOnly) + ) + } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Be $null + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "ContentDatabases: At least one of the following parameters must be specified: Members, MembersToInclude, MembersToExclude" + } + } + + Context "Specified content database does not exist - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso3" + Members = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + It "return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + { Test-TargetResource @testParams } | Should throw "Specified database does not exist" + } + + It "should throw an exception in the set method" { + { Set-TargetResource @testParams } | Should throw "Specified database does not exist" + } + } + + Context "AllContentDatabases parameter is used and permissions do not match" { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + AllContentDatabases = $true + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user3","contoso\user4" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + Mock Add-SPShellAdmin {} + Mock Remove-SPShellAdmin {} + + It "return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Add-SPShellAdmin + Assert-MockCalled Remove-SPShellAdmin + } + } + + Context "AllContentDatabases parameter is used and permissions do not match" { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + AllContentDatabases = $true + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + + It "return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "returns false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured Members do not match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user3","contoso\user4" } + } + } + Mock Add-SPShellAdmin {} + Mock Remove-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Add-SPShellAdmin + Assert-MockCalled Remove-SPShellAdmin + } + } + + Context "Configured Members match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + Members = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1", "contoso\user2" } + } + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured Members do not match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + Members = "contoso\user1", "contoso\user2" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + Members = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user3","contoso\user4" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + Mock Add-SPShellAdmin {} + Mock Remove-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Add-SPShellAdmin + Assert-MockCalled Remove-SPShellAdmin + } + } + + Context "Configured Members match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + Members = "contoso\user1", "contoso\user2" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + Members = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured MembersToInclude do not match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + MembersToInclude = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user3","contoso\user4" } + } + } + + Mock Add-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Add-SPShellAdmin + } + } + + Context "Configured MembersToInclude match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + MembersToInclude = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1", "contoso\user2", "contoso\user3" } + } + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured MembersToInclude do not match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + MembersToInclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + MembersToInclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user3","contoso\user4" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + Mock Add-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Add-SPShellAdmin + } + } + + Context "Configured MembersToInclude match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + MembersToInclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + MembersToInclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user1","contoso\user2", "contoso\user3" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured MembersToExclude do not match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + MembersToExclude = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Remove-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Remove-SPShellAdmin + } + } + + Context "Configured MembersToExclude match the actual members - General permissions" { + $testParams = @{ + Name = "ShellAdmins" + MembersToExclude = "contoso\user1", "contoso\user2" + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{} + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user3", "contoso\user4" } + } + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context "Configured MembersToExclude do not match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + MembersToExclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + MembersToExclude = "contoso\user1", "contoso\user2" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + Mock Remove-SPShellAdmin {} + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "should throw an exception in the set method" { + Set-TargetResource @testParams + Assert-MockCalled Remove-SPShellAdmin + } + } + + Context "Configured MembersToExclude match the actual members - ContentDatabase permissions" { + $testParams = @{ + Name = "ShellAdmins" + ContentDatabases = @( + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso1" + MembersToExclude = "contoso\user3", "contoso\user4" + } -ClientOnly) + (New-CimInstance -ClassName MSFT_xSPContentDatabasePermissions -Property @{ + Name = "SharePoint_Content_Contoso2" + MembersToExclude = "contoso\user5", "contoso\user6" + } -ClientOnly) + ) + } + Mock Get-SPShellAdmin { + if ($database) { + # Database parameter used, return database permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } else { + # Database parameter not used, return general permissions + return @{ UserName = "contoso\user1","contoso\user2" } + } + } + Mock Get-SPContentDatabase { + return @( + @{ + Name = "SharePoint_Content_Contoso1" + Id = "F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4" + }, + @{ + Name = "SharePoint_Content_Contoso2" + Id = "936DA01F-9ABD-4d9d-80C7-02AF85C822A8" + } + ) + } + + It "should return null from the get method" { + Get-TargetResource @testParams | Should Not BeNullOrEmpty + } + + It "should return false from the test method" { + Test-TargetResource @testParams | Should Be $true + } + } + } +} From 137d7713fc331140af807fd6a74ce4b98143e063 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 28 Jan 2016 15:25:42 +0100 Subject: [PATCH 69/91] Updated description in MOF file --- .../MSFT_xSPShellAdmins.psm1 | 126 +++++++++++++++--- .../MSFT_xSPShellAdmins.schema.mof | 36 +++-- 2 files changed, 130 insertions(+), 32 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 index c90d1f0ad..5ece3beff 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 @@ -147,17 +147,32 @@ function Set-TargetResource if ($difference.SideIndicator -eq "=>") { # Add account $user = $difference.InputObject - Add-SPShellAdmin -UserName $user + try { + Add-SPShellAdmin -UserName $user + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } elseif ($difference.SideIndicator -eq "<=") { # Remove account $user = $difference.InputObject - Remove-SPShellAdmin -UserName $user -Confirm:$false + try { + Remove-SPShellAdmin -UserName $user -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } } else { foreach ($member in $params.Members) { - Add-SPShellAdmin -UserName $member + try { + Add-SPShellAdmin -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } @@ -167,12 +182,22 @@ function Set-TargetResource if ($shellAdmins) { foreach ($member in $params.MembersToInclude) { if (-not $shellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -UserName $member + try { + Add-SPShellAdmin -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } else { foreach ($member in $params.MembersToInclude) { - Add-SPShellAdmin -UserName $member + try { + Add-SPShellAdmin -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } @@ -182,7 +207,12 @@ function Set-TargetResource if ($shellAdmins) { foreach ($member in $params.MembersToExclude) { if ($shellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -UserName $member -Confirm:$false + try { + Remove-SPShellAdmin -UserName $member -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } @@ -209,16 +239,31 @@ function Set-TargetResource if ($difference.SideIndicator -eq "<=") { # Add account $user = $difference.InputObject - Add-SPShellAdmin -database $currentCDB.Id -UserName $user + try { + Add-SPShellAdmin -database $currentCDB.Id -UserName $user + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } elseif ($difference.SideIndicator -eq "=>") { # Remove account $user = $difference.InputObject - Remove-SPShellAdmin -database $currentCDB.Id -UserName $user -Confirm:$false + try { + Remove-SPShellAdmin -database $currentCDB.Id -UserName $user -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } else { Foreach ($member in $contentDatabase.Members) { - Add-SPShellAdmin -database $currentCDB.Id -UserName $member + try { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } @@ -228,12 +273,22 @@ function Set-TargetResource if ($dbShellAdmins) { ForEach ($member in $contentDatabase.MembersToInclude) { if (-not $dbShellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -database $currentCDB.Id -UserName $member + try { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } else { ForEach ($member in $contentDatabase.MembersToInclude) { - Add-SPShellAdmin -database $currentCDB.Id -UserName $member + try { + Add-SPShellAdmin -database $currentCDB.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } @@ -243,7 +298,12 @@ function Set-TargetResource if ($dbShellAdmins) { ForEach ($member in $contentDatabase.MembersToExclude) { if ($dbShellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -database $currentCDB.Id -UserName $member -Confirm:$false + try { + Remove-SPShellAdmin -database $currentCDB.Id -UserName $member -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } @@ -272,17 +332,32 @@ function Set-TargetResource if ($difference.SideIndicator -eq "=>") { # Add account $user = $difference.InputObject - Add-SPShellAdmin -database $contentDatabase.Id -UserName $user + try { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $user + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } elseif ($difference.SideIndicator -eq "<=") { # Remove account $user = $difference.InputObject - Remove-SPShellAdmin -database $contentDatabase.Id -UserName $user -Confirm:$false + try { + Remove-SPShellAdmin -database $contentDatabase.Id -UserName $user -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } } else { Foreach ($member in $params.Members) { - Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + try { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } @@ -291,12 +366,22 @@ function Set-TargetResource if ($dbShellAdmins) { foreach ($member in $params.MembersToInclude) { if (-not $dbShellAdmins.UserName.Contains($member)) { - Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + try { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } } else { foreach ($member in $params.MembersToInclude) { - Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + try { + Add-SPShellAdmin -database $contentDatabase.Id -UserName $member + } catch { + throw "Error while setting the Shell Admin. The Shell Admin permissions will not be applied. Error details: $($_.Exception.Message)" + return + } } } @@ -306,7 +391,12 @@ function Set-TargetResource if ($dbShellAdmins) { foreach ($member in $params.MembersToExclude) { if ($dbShellAdmins.UserName.Contains($member)) { - Remove-SPShellAdmin -database $contentDatabase.Id -UserName $member -Confirm:$false + try { + Remove-SPShellAdmin -database $contentDatabase.Id -UserName $member -Confirm:$false + } catch { + throw "Error while removing the Shell Admin. The Shell Admin permissions will not be revoked. Error details: $($_.Exception.Message)" + return + } } } } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof index 5efb58bbd..9080577a5 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof @@ -5,6 +5,17 @@ This resource is used to manage the users with Shell Admin permissions. There are a number of approaches to how this can be implemented. The "Members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. +The "ContentDatabases" and "AllContentDatabases" properties will allow you to control the permissions on Content Databases. + +Requirements: +At least one of the Members, MemberToInclude or MembersToExclude properties needs to be specified. +Do not combine the Members property with the MemberToInclude and MembersToExclude properties. +Do not combine the ContentDatabase property with the AllContentDatabases property. + +Notes: +1.) If a content database is created using the Central Admin, the farm account is the owner of that content database in SQL Server. +When this is true, you cannot add it to the Shell Admins (common for AllContentDatabases parameter) and the resource will throw an error. +Workaround: Change database owner in SQL Server. **Example** @@ -31,29 +42,26 @@ The "MembersToInclude" and "MembersToExclude" properties will allow you to contr ) } -################ Import-DSCResource -Module xSharePoint is required to import the custom class!! -################ Note: If the farm account is the owner of a database, you cannot add it to the Shell Admins (common with AllContentDatabases parameter). Workaround: Change database owner. - */ [ClassVersion("1.0.0")] Class MSFT_xSPContentDatabasePermissions { - [Write] String Name; - [Write] String Members[]; - [Write] String MembersToInclude[]; - [Write] String MembersToExclude[]; + [Write, Description("Name of the Content Database")] String Name; + [Write, Description("Exact list of accounts that will have to get Shell Admin permissions")] String Members[]; + [Write, Description("List of all accounts that must be in the Shell Admins group")] String MembersToInclude[]; + [Write, Description("List of all accounts that are not allowed to have Shell Admin permissions")] String MembersToExclude[]; }; [ClassVersion("1.0.0.0"), FriendlyName("xSPShellAdmins")] class MSFT_xSPShellAdmins : OMI_BaseResource { - [Key] String Name; - [Write] String Members[]; - [Write] String MembersToInclude[]; - [Write] String MembersToExclude[]; - [Write, EmbeddedInstance("MSFT_xSPContentDatabasePermissions")] String ContentDatabases[]; - [Write] Boolean AllContentDatabases; - [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; + [Key, Description("Name for the config, used for administration purposes")] String Name; + [Write, Description("Exact list of accounts that will have to get Shell Admin permissions")] String Members[]; + [Write, Description("List of all accounts that must be in the Shell Admins group")] String MembersToInclude[]; + [Write, Description("List of all accounts that are not allowed to have Shell Admin permissions")] String MembersToExclude[]; + [Write, Description("Shell Admin configuration of Content Databases"), EmbeddedInstance("MSFT_xSPContentDatabasePermissions")] String ContentDatabases[]; + [Write, Description("Specify if all content databases must get the same config as the general config")] Boolean AllContentDatabases; + [Write, Description("The account under which the resource has to run, required for PowerShell v4"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; From e2bc561679ea0487882d5e231d0af0e78ca0849a Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Thu, 28 Jan 2016 20:07:14 +0100 Subject: [PATCH 70/91] Updated Readme.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 05403ad08..5be1cb07b 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPAppCatalog - xSPAppDomain - xSPAppManagementServiceApp - - xBCSServiceApp + - xSPBCSServiceApp - xSPCacheAccounts - xSPCreateFarm - xSPDesignerSettings @@ -44,6 +44,7 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPDistributedCacheService - xSPFarmAdministrators - xSPFeature + - xSPHealthAnalyzerRuleState - xSPInstall - xSPInstallPreReqs - xSPJoinFarm @@ -60,10 +61,11 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPServiceAppPool - xSPServiceInstance - xSPSessionStateService + - xSPShellAdmin - xSPSite - xSPStateServiceApp - - xSPTimerJobState - xSPSubscriptionSettingsServiceApp + - xSPTimerJobState - xSPUsageApplication - xSPUserProfileServiceApp - xSPUserProfileSyncService @@ -76,6 +78,7 @@ Below is a list of DSC resource types that are currently provided by xSharePoint - xSPWebAppSiteUseAndDeletion - xSPWebAppThrottlingSettings - xSPWebAppWorkflowSettings + - xSPWordAutomationServiceApp ## Preview status @@ -89,10 +92,9 @@ Additional detailed documentation is included on the wiki on GitHub. ## Version History -### Unreleased - * Added xSPWordAutomationServiceApp resources +### Unreleased - * Added xSPHealthAnalyzerRuleState resources + * Added xSPWordAutomationServiceApp, xSPHealthAnalyzerRuleState and xSPShellAdmin resources ### 0.9.0.0 From fe21ff75399cd8772fb4dd6fd9a5f2b17010341f Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:02:17 +0000 Subject: [PATCH 71/91] unit tests --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 139 ++++++++---------- ...SFT_xSPWorkManagementServiceApp.schema.mof | 4 +- ...oint.xSPWorkManagementServiceApp.Tests.ps1 | 72 +++++---- 3 files changed, 103 insertions(+), 112 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index cce08b404..3cf5042e9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -5,8 +5,8 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -46,8 +46,8 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -56,89 +56,66 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) - - $result = Get-TargetResource @PSBoundParameters - $setParameters = @( - "ApplicationPool", - "MinimumTimeBetweenEwsSyncSubscriptionSearches", - "MinimumTimeBetweenProviderRefreshes", - "MinimumTimeBetweenSearchQueries", - "Name", - "NumberOfSubscriptionSyncsPerEwsSyncRun", - "NumberOfUsersEwsSyncWillProcessAtOnce", - "NumberOfUsersPerEwsSyncBatch" - ) - $newParamters = @( - "ApplicationPool", - "Name" - ) - if ($result -eq $null) { - Write-Verbose -Message "Creating work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters, $newParameters ) -ScriptBlock { + if($Ensure -ne "Absent" -and $ApplicationPool -eq $null){ + throw "Parameter ApplicationPool is required unless service is being removed(Ensure='Absent')" + } + <# + if ($Ensure -eq "Absent") { + if($result -ne $null){ + Write-Verbose -Message "Removing Work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} - $newParams = $params.GetEnumerator() | ? {$args[2] -contains $_.Name} - $appService = New-SPWorkManagementServiceApplication @newParams - New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null - if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { - $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches - } - if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { - $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes } - if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { - $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries - } - $setParams.Add("Confirm", $false) - Set-SPWorkManagementServiceApplicationProxy @setPArams | Out-Null } - - #} - }else { - if ($Ensure -eq "Absent") { - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } + }#> + Write-Verbose -Message "Creating work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + + if($appService -ne $null -and $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent") + { + #remove existing app + Remove-SPServiceApplication $appService - }else{ - Write-Verbose -Message "Updating Work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters ) -ScriptBlock { - $params = $args[0] - $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} - #$appService = Get-SPServiceApplication -Name $params.Name ` - # | Where-Object { $_.TypeName -eq "Work Management Service Application" } - $setParams.Add("Confirm", $false) - <#$appPool=$null - if($setParams.ContainsKey("ApplicationPool")){ - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - $setParams.ApplicationPool = $appPool - }#> - if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { - $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches - } - if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { - $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes - } - if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { - $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries - } + return; + } elseif ( $appService -eq $null){ + $newParams = @{} + $newParams.Add("Name", $params.Name) + $newParams.Add("ApplicationPool", $params.ApplicationPool) - Set-SPWorkManagementServiceApplication @setPArams | Out-Null - } - <# - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } - $AppService.ApplicationPool = $appPool - $AppService.Update() - }#> + $appService = New-SPWorkManagementServiceApplication @newParams + New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null + + } + $setParams = @{} + if ($params.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { $setParams.Add("MinimumTimeBetweenEwsSyncSubscriptionSearches", $params.MinimumTimeBetweenEwsSyncSubscriptionSearches) } + if ($params.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { $setParams.Add("MinimumTimeBetweenProviderRefreshes", $params.MinimumTimeBetweenProviderRefreshes) } + if ($params.ContainsKey("MinimumTimeBetweenSearchQueries")) { $setParams.Add("MinimumTimeBetweenSearchQueries", $params.MinimumTimeBetweenSearchQueries) } + if ($params.ContainsKey("NumberOfSubscriptionSyncsPerEwsSyncRun")) { $setParams.Add("NumberOfSubscriptionSyncsPerEwsSyncRun", $params.NumberOfSubscriptionSyncsPerEwsSyncRun) } + if ($params.ContainsKey("NumberOfUsersEwsSyncWillProcessAtOnce")) { $setParams.Add("NumberOfUsersEwsSyncWillProcessAtOnce", $params.NumberOfUsersEwsSyncWillProcessAtOnce) } + if ($params.ContainsKey("NumberOfUsersPerEwsSyncBatch")) { $setParams.Add("NumberOfUsersPerEwsSyncBatch", $params.NumberOfUsersPerEwsSyncBatch) } + + $setParams.Add("Name", $params.Name) + $setParams.Add("ApplicationPool", $params.ApplicationPool) + + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches + } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } + $setParams.Add("Confirm", $false) + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + + $appService | Set-SPWorkManagementServiceApplication @setPArams | Out-Null } } -#} - function Test-TargetResource @@ -148,8 +125,8 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof index 4ea910359..2589307f4 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof @@ -24,8 +24,8 @@ Remarks class MSFT_WorkManagementServiceApp : OMI_BaseResource { [Key] string Name; - [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; - [Required] String ApplicationPool; + [Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [Write] String ApplicationPool; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] System.UInt32 MinimumTimeBetweenEwsSyncSubscriptionSearches; [Write] System.UInt32 MinimumTimeBetweenProviderRefreshes; diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 index 84463a967..90492e164 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 @@ -37,6 +37,29 @@ Describe "xSPWorkManagement" { } Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + Context "When a service application exists and Ensure equals 'absent'" { + $testParamsAbsent = @{ + Name = "Test Work Management App" + Ensure = "Absent" + } + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParamsAbsent.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + }) + } + Mock Remove-SPServiceApplication{ } + + It "returns true when the Test method is called" { + Test-TargetResource @testParamsAbsent | Should Be $true + } + + It "calls the remove service app cmdlet from the set method" { + Set-TargetResource @testParamsAbsent + Assert-MockCalled Remove-SPServiceApplication + } + } Context "When no service applications exist in the current farm" { @@ -64,14 +87,28 @@ Describe "xSPWorkManagement" { Mock Set-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplicationProxy { } - - Mock Get-SPServiceApplication { return @(@{ - TypeName = "Some other service app type" - }) } - + $Global:GetSpServiceApplicationCalled=$false + Mock Get-SPServiceApplication { + if($Global:GetSpServiceApplicationCalled -eq $false){ + $Global:GetSpServiceApplicationCalled=$true; + return @(@{ + TypeName = "Some other service app type" + }) + } + return @(@{ + TypeName = "Work Management Service Application" + }) + } + + It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "creates new app from the Get method" { + Set-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } Assert-MockCalled Set-SPWorkManagementServiceApplication -ParameterFilter { $Name -eq $testParams.Name } } @@ -113,30 +150,7 @@ Describe "xSPWorkManagement" { It "calls the update service app cmdlet from the set method" { Set-TargetResource @testParamsComplete Assert-MockCalled Set-SPWorkManagementServiceApplication - Assert-MockCalled Get-SPWorkManagementServiceApplication - } - } - Context "When a service application exists and Ensure equals 'absent'" { - $testParamsAbsent = @{ - Name = "Test Work Management App" - Ensure = "Absent" - } - Mock Get-SPServiceApplication { - return @(@{ - TypeName = "Work Management Service Application" - DisplayName = $testParamsAbsent.Name - ApplicationPool = @{ Name = "Wrong App Pool Name" } - }) - } - Mock Remove-SPServiceApplication{ } - - It "returns false when the Test method is called" { - Test-TargetResource $testParamsAbsent | Should Be $false - } - - It "calls the update service app cmdlet from the set method" { - Set-TargetResource $testParamsAbsent - Assert-MockCalled Remove-SPServiceApplication + Assert-MockCalled Get-SPServiceApplication } } From 6303122ad7fffaf02e835da1ef115da13dc8fd7b Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:19:01 +0000 Subject: [PATCH 72/91] adding AdminSettings to Get-Resource, and updating test --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 3 ++- .../MSFT_xSPWorkManagementServiceApp.psm1 | 16 +++++++++++++++- ...xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 7 +++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 67f1275dd..600a8e747 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -63,7 +63,8 @@ function Set-TargetResource } if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - New-SPSubscriptionSettingsServiceApplication @newParams + $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams + $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp } } else { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 3cf5042e9..22d92fc75 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -32,6 +32,12 @@ function Get-TargetResource $returnVal = @{ Name = $serviceApp.DisplayName ApplicationPool = $serviceApp.ApplicationPool.Name + MinimumTimeBetweenEwsSyncSubscriptionSearches = $serviceApp.AdminSettings.MinimumTimeBetweenEwsSyncSubscriptionSearches.TotalMinutes + MinimumTimeBetweenProviderRefreshes= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + MinimumTimeBetweenSearchQueries= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + NumberOfSubscriptionSyncsPerEwsSyncRun= $serviceApp.AdminSettings.NumberOfSubscriptionSyncsPerEwsSyncRun + NumberOfUsersEwsSyncWillProcessAtOnce= $serviceApp.AdminSettings.NumberOfUsersEwsSyncWillProcessAtOnce + NumberOfUsersPerEwsSyncBatch= $serviceApp.AdminSettings.NumberOfUsersPerEwsSyncBatch } return $returnVal } @@ -146,7 +152,15 @@ function Test-TargetResource } } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool", + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch" + ) } Export-ModuleMember -Function *-TargetResource diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index f8b3edc53..a3c587a8c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -33,7 +33,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - + Mock New-SPSubscriptionSettingsServiceApplicationProxy {} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -46,6 +46,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } @@ -120,7 +121,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } - Context "When a service app needs to be created and no database paramsters are provided" { + Context "When a service app needs to be created and no database parameters are provided" { $testParams = @{ Name = "Test App" ApplicationPool = "Test App Pool" @@ -128,10 +129,12 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } + Mock New-SPSubscriptionSettingsServiceApplicationProxy { } it "should not throw an exception in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } } From c9addc3784cac9cbf4c17e69aa586d6dc39c43e2 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:27:11 +0000 Subject: [PATCH 73/91] adding proxy and updating tests --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 3 ++- .../xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 67f1275dd..1bcdd0765 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -63,7 +63,8 @@ function Set-TargetResource } if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - New-SPSubscriptionSettingsServiceApplication @newParams + $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams + $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp -DefaultProxyGroup } } else { diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index f8b3edc53..f17275154 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -33,7 +33,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - + Mock New-SPSubscriptionSettingsServiceApplicationProxy {} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -46,6 +46,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } @@ -120,7 +121,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } - Context "When a service app needs to be created and no database paramsters are provided" { + Context "When a service app needs to be created and no database parameters are provided" { $testParams = @{ Name = "Test App" ApplicationPool = "Test App Pool" @@ -128,11 +129,13 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } + Mock New-SPSubscriptionSettingsServiceApplicationProxy { } it "should not throw an exception in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } } -} +} \ No newline at end of file From 05f085cce76a82ff43a9819ced7c8566f95a0ff2 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:27:50 +0000 Subject: [PATCH 74/91] Revert "unit tests" This reverts commit fe21ff75399cd8772fb4dd6fd9a5f2b17010341f. --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 139 ++++++++++-------- ...SFT_xSPWorkManagementServiceApp.schema.mof | 4 +- ...oint.xSPWorkManagementServiceApp.Tests.ps1 | 72 ++++----- 3 files changed, 112 insertions(+), 103 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 22d92fc75..5fddcc7f1 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -5,8 +5,8 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $false)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -52,8 +52,8 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $false)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -62,66 +62,89 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) - if($Ensure -ne "Absent" -and $ApplicationPool -eq $null){ - throw "Parameter ApplicationPool is required unless service is being removed(Ensure='Absent')" - } - <# - if ($Ensure -eq "Absent") { - if($result -ne $null){ - Write-Verbose -Message "Removing Work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - } - } - }#> - Write-Verbose -Message "Creating work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } - - if($appService -ne $null -and $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent") - { - #remove existing app - - Remove-SPServiceApplication $appService - return; - } elseif ( $appService -eq $null){ - $newParams = @{} - $newParams.Add("Name", $params.Name) - $newParams.Add("ApplicationPool", $params.ApplicationPool) + $result = Get-TargetResource @PSBoundParameters + $setParameters = @( + "ApplicationPool", + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch" + ) + $newParamters = @( + "ApplicationPool", + "Name" + ) + if ($result -eq $null) { + Write-Verbose -Message "Creating work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters, $newParameters ) -ScriptBlock { + $params = $args[0] + $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} + $newParams = $params.GetEnumerator() | ? {$args[2] -contains $_.Name} $appService = New-SPWorkManagementServiceApplication @newParams New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null - + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches + } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes + } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } + $setParams.Add("Confirm", $false) + Set-SPWorkManagementServiceApplicationProxy @setPArams | Out-Null } - $setParams = @{} - if ($params.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { $setParams.Add("MinimumTimeBetweenEwsSyncSubscriptionSearches", $params.MinimumTimeBetweenEwsSyncSubscriptionSearches) } - if ($params.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { $setParams.Add("MinimumTimeBetweenProviderRefreshes", $params.MinimumTimeBetweenProviderRefreshes) } - if ($params.ContainsKey("MinimumTimeBetweenSearchQueries")) { $setParams.Add("MinimumTimeBetweenSearchQueries", $params.MinimumTimeBetweenSearchQueries) } - if ($params.ContainsKey("NumberOfSubscriptionSyncsPerEwsSyncRun")) { $setParams.Add("NumberOfSubscriptionSyncsPerEwsSyncRun", $params.NumberOfSubscriptionSyncsPerEwsSyncRun) } - if ($params.ContainsKey("NumberOfUsersEwsSyncWillProcessAtOnce")) { $setParams.Add("NumberOfUsersEwsSyncWillProcessAtOnce", $params.NumberOfUsersEwsSyncWillProcessAtOnce) } - if ($params.ContainsKey("NumberOfUsersPerEwsSyncBatch")) { $setParams.Add("NumberOfUsersPerEwsSyncBatch", $params.NumberOfUsersPerEwsSyncBatch) } - - $setParams.Add("Name", $params.Name) - $setParams.Add("ApplicationPool", $params.ApplicationPool) + + #} + }else { + if ($Ensure -eq "Absent") { + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + Remove-SPServiceApplication $appService + }else{ + Write-Verbose -Message "Updating Work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters ) -ScriptBlock { + $params = $args[0] + $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} + #$appService = Get-SPServiceApplication -Name $params.Name ` + # | Where-Object { $_.TypeName -eq "Work Management Service Application" } + $setParams.Add("Confirm", $false) + <#$appPool=$null + if($setParams.ContainsKey("ApplicationPool")){ + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + $setParams.ApplicationPool = $appPool + }#> + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches + } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes + } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } - if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { - $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches - } - if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { - $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes - } - if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { - $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + Set-SPWorkManagementServiceApplication @setPArams | Out-Null + } + <# + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool + + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + $AppService.ApplicationPool = $appPool + $AppService.Update() + }#> } - $setParams.Add("Confirm", $false) - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } - - $appService | Set-SPWorkManagementServiceApplication @setPArams | Out-Null } } +#} + function Test-TargetResource @@ -131,8 +154,8 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $false)] [System.String] $ApplicationPool, - [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $true)] [System.String] $ApplicationPool, + [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof index 2589307f4..4ea910359 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof @@ -24,8 +24,8 @@ Remarks class MSFT_WorkManagementServiceApp : OMI_BaseResource { [Key] string Name; - [Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; - [Write] String ApplicationPool; + [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [Required] String ApplicationPool; [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; [Write] System.UInt32 MinimumTimeBetweenEwsSyncSubscriptionSearches; [Write] System.UInt32 MinimumTimeBetweenProviderRefreshes; diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 index 90492e164..84463a967 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 @@ -37,29 +37,6 @@ Describe "xSPWorkManagement" { } Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue - Context "When a service application exists and Ensure equals 'absent'" { - $testParamsAbsent = @{ - Name = "Test Work Management App" - Ensure = "Absent" - } - Mock Get-SPServiceApplication { - return @(@{ - TypeName = "Work Management Service Application" - DisplayName = $testParamsAbsent.Name - ApplicationPool = @{ Name = "Wrong App Pool Name" } - }) - } - Mock Remove-SPServiceApplication{ } - - It "returns true when the Test method is called" { - Test-TargetResource @testParamsAbsent | Should Be $true - } - - It "calls the remove service app cmdlet from the set method" { - Set-TargetResource @testParamsAbsent - Assert-MockCalled Remove-SPServiceApplication - } - } Context "When no service applications exist in the current farm" { @@ -87,28 +64,14 @@ Describe "xSPWorkManagement" { Mock Set-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplicationProxy { } - $Global:GetSpServiceApplicationCalled=$false - Mock Get-SPServiceApplication { - if($Global:GetSpServiceApplicationCalled -eq $false){ - $Global:GetSpServiceApplicationCalled=$true; - return @(@{ - TypeName = "Some other service app type" - }) - } - return @(@{ - TypeName = "Work Management Service Application" - }) - } - - + + Mock Get-SPServiceApplication { return @(@{ + TypeName = "Some other service app type" + }) } + It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } - } - - It "creates new app from the Get method" { - Set-TargetResource @testParams | Should BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } Assert-MockCalled Set-SPWorkManagementServiceApplication -ParameterFilter { $Name -eq $testParams.Name } } @@ -150,7 +113,30 @@ Describe "xSPWorkManagement" { It "calls the update service app cmdlet from the set method" { Set-TargetResource @testParamsComplete Assert-MockCalled Set-SPWorkManagementServiceApplication - Assert-MockCalled Get-SPServiceApplication + Assert-MockCalled Get-SPWorkManagementServiceApplication + } + } + Context "When a service application exists and Ensure equals 'absent'" { + $testParamsAbsent = @{ + Name = "Test Work Management App" + Ensure = "Absent" + } + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParamsAbsent.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + }) + } + Mock Remove-SPServiceApplication{ } + + It "returns false when the Test method is called" { + Test-TargetResource $testParamsAbsent | Should Be $false + } + + It "calls the update service app cmdlet from the set method" { + Set-TargetResource $testParamsAbsent + Assert-MockCalled Remove-SPServiceApplication } } From b7c9ce791f9ca6689bc8e13cac7d25034e7ed276 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:30:19 +0000 Subject: [PATCH 75/91] updating file, to add adminsettings back in --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 142 ++++++++---------- 1 file changed, 59 insertions(+), 83 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 5fddcc7f1..7bbc8629a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -5,8 +5,8 @@ function Get-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -52,8 +52,8 @@ function Set-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -62,89 +62,66 @@ function Set-TargetResource [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersEwsSyncWillProcessAtOnce, [parameter(Mandatory = $false)] [System.UInt32] $NumberOfUsersPerEwsSyncBatch ) - - $result = Get-TargetResource @PSBoundParameters - $setParameters = @( - "ApplicationPool", - "MinimumTimeBetweenEwsSyncSubscriptionSearches", - "MinimumTimeBetweenProviderRefreshes", - "MinimumTimeBetweenSearchQueries", - "Name", - "NumberOfSubscriptionSyncsPerEwsSyncRun", - "NumberOfUsersEwsSyncWillProcessAtOnce", - "NumberOfUsersPerEwsSyncBatch" - ) - $newParamters = @( - "ApplicationPool", - "Name" - ) - if ($result -eq $null) { - Write-Verbose -Message "Creating work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters, $newParameters ) -ScriptBlock { + if($Ensure -ne "Absent" -and $ApplicationPool -eq $null){ + throw "Parameter ApplicationPool is required unless service is being removed(Ensure='Absent')" + } + <# + if ($Ensure -eq "Absent") { + if($result -ne $null){ + Write-Verbose -Message "Removing Work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} - $newParams = $params.GetEnumerator() | ? {$args[2] -contains $_.Name} - $appService = New-SPWorkManagementServiceApplication @newParams - New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null - if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { - $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches - } - if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { - $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes } - if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { - $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries - } - $setParams.Add("Confirm", $false) - Set-SPWorkManagementServiceApplicationProxy @setPArams | Out-Null } - - #} - }else { - if ($Ensure -eq "Absent") { - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } + }#> + Write-Verbose -Message "Creating work management Service Application $Name" + Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $params = $args[0] + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + + if($appService -ne $null -and $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent") + { + #remove existing app + Remove-SPServiceApplication $appService - }else{ - Write-Verbose -Message "Updating Work management Service Application $Name" - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $setParameters ) -ScriptBlock { - $params = $args[0] - $setParams = $params.GetEnumerator() | ? {$args[1] -contains $_.Name} - #$appService = Get-SPServiceApplication -Name $params.Name ` - # | Where-Object { $_.TypeName -eq "Work Management Service Application" } - $setParams.Add("Confirm", $false) - <#$appPool=$null - if($setParams.ContainsKey("ApplicationPool")){ - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - $setParams.ApplicationPool = $appPool - }#> - if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { - $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches - } - if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { - $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes - } - if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { - $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries - } + return; + } elseif ( $appService -eq $null){ + $newParams = @{} + $newParams.Add("Name", $params.Name) + $newParams.Add("ApplicationPool", $params.ApplicationPool) - Set-SPWorkManagementServiceApplication @setPArams | Out-Null - } - <# - Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { - $params = $args[0] - $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - - $appService = Get-SPServiceApplication -Name $params.Name ` - | Where-Object { $_.TypeName -eq "Work Management Service Application" } - $AppService.ApplicationPool = $appPool - $AppService.Update() - }#> + $appService = New-SPWorkManagementServiceApplication @newParams + New-SPWorkManagementServiceApplicationProxy -Name "$($params.Name) Proxy" -DefaultProxyGroup -ServiceApplication $appService -ea Stop | Out-Null + + } + $setParams = @{} + if ($params.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { $setParams.Add("MinimumTimeBetweenEwsSyncSubscriptionSearches", $params.MinimumTimeBetweenEwsSyncSubscriptionSearches) } + if ($params.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { $setParams.Add("MinimumTimeBetweenProviderRefreshes", $params.MinimumTimeBetweenProviderRefreshes) } + if ($params.ContainsKey("MinimumTimeBetweenSearchQueries")) { $setParams.Add("MinimumTimeBetweenSearchQueries", $params.MinimumTimeBetweenSearchQueries) } + if ($params.ContainsKey("NumberOfSubscriptionSyncsPerEwsSyncRun")) { $setParams.Add("NumberOfSubscriptionSyncsPerEwsSyncRun", $params.NumberOfSubscriptionSyncsPerEwsSyncRun) } + if ($params.ContainsKey("NumberOfUsersEwsSyncWillProcessAtOnce")) { $setParams.Add("NumberOfUsersEwsSyncWillProcessAtOnce", $params.NumberOfUsersEwsSyncWillProcessAtOnce) } + if ($params.ContainsKey("NumberOfUsersPerEwsSyncBatch")) { $setParams.Add("NumberOfUsersPerEwsSyncBatch", $params.NumberOfUsersPerEwsSyncBatch) } + + $setParams.Add("Name", $params.Name) + $setParams.Add("ApplicationPool", $params.ApplicationPool) + + if ($setParams.ContainsKey("MinimumTimeBetweenEwsSyncSubscriptionSearches")) { + $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches = New-TimeSpan -Days $setParams.MinimumTimeBetweenEwsSyncSubscriptionSearches } + if ($setParams.ContainsKey("MinimumTimeBetweenProviderRefreshes")) { + $setParams.MinimumTimeBetweenProviderRefreshes = New-TimeSpan -Days $setParams.MinimumTimeBetweenProviderRefreshes + } + if ($setParams.ContainsKey("MinimumTimeBetweenSearchQueries")) { + $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries + } + $setParams.Add("Confirm", $false) + $appService = Get-SPServiceApplication -Name $params.Name ` + | Where-Object { $_.TypeName -eq "Work Management Service Application" } + + $appService | Set-SPWorkManagementServiceApplication @setPArams | Out-Null } } -#} - function Test-TargetResource @@ -154,8 +131,8 @@ function Test-TargetResource param ( [parameter(Mandatory = $true)] [System.String] $Name, - [parameter(Mandatory = $true)] [System.String] $ApplicationPool, - [parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, + [parameter(Mandatory = $false)] [System.String] $ApplicationPool, + [parameter(Mandatory = $false)] [ValidateSet("Present","Absent")] [System.String] $Ensure, [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenEwsSyncSubscriptionSearches, [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenProviderRefreshes, @@ -171,7 +148,7 @@ function Test-TargetResource }else{ if($Ensure -eq "Absent") { #Ensure = Absent doesn't care state - return $true + return $true } } @@ -187,4 +164,3 @@ function Test-TargetResource } Export-ModuleMember -Function *-TargetResource - From 739b291408f7ca494e21ccd88e9f4e7c9a926420 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:35:58 +0000 Subject: [PATCH 76/91] Revert "adding AdminSettings to Get-Resource, and updating test" This reverts commit 6303122ad7fffaf02e835da1ef115da13dc8fd7b. --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 3 +-- .../MSFT_xSPWorkManagementServiceApp.psm1 | 16 +--------------- ...xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 7 ++----- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 600a8e747..67f1275dd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -63,8 +63,7 @@ function Set-TargetResource } if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams - $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp + New-SPSubscriptionSettingsServiceApplication @newParams } } else { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 7bbc8629a..797b0ead3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -32,12 +32,6 @@ function Get-TargetResource $returnVal = @{ Name = $serviceApp.DisplayName ApplicationPool = $serviceApp.ApplicationPool.Name - MinimumTimeBetweenEwsSyncSubscriptionSearches = $serviceApp.AdminSettings.MinimumTimeBetweenEwsSyncSubscriptionSearches.TotalMinutes - MinimumTimeBetweenProviderRefreshes= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes - MinimumTimeBetweenSearchQueries= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes - NumberOfSubscriptionSyncsPerEwsSyncRun= $serviceApp.AdminSettings.NumberOfSubscriptionSyncsPerEwsSyncRun - NumberOfUsersEwsSyncWillProcessAtOnce= $serviceApp.AdminSettings.NumberOfUsersEwsSyncWillProcessAtOnce - NumberOfUsersPerEwsSyncBatch= $serviceApp.AdminSettings.NumberOfUsersPerEwsSyncBatch } return $returnVal } @@ -152,15 +146,7 @@ function Test-TargetResource } } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool", - "MinimumTimeBetweenEwsSyncSubscriptionSearches", - "MinimumTimeBetweenProviderRefreshes", - "MinimumTimeBetweenSearchQueries", - "Name", - "NumberOfSubscriptionSyncsPerEwsSyncRun", - "NumberOfUsersEwsSyncWillProcessAtOnce", - "NumberOfUsersPerEwsSyncBatch" - ) + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") } Export-ModuleMember -Function *-TargetResource diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index a3c587a8c..f8b3edc53 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -33,7 +33,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy {} + It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -46,7 +46,6 @@ Describe "xSPSubscriptionSettingsServiceApp" { It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication - Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } @@ -121,7 +120,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } - Context "When a service app needs to be created and no database parameters are provided" { + Context "When a service app needs to be created and no database paramsters are provided" { $testParams = @{ Name = "Test App" ApplicationPool = "Test App Pool" @@ -129,12 +128,10 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy { } it "should not throw an exception in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication - Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } } From e9135748c4fb2e9494ea58ee36f087e92026f2e7 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:36:17 +0000 Subject: [PATCH 77/91] Revert "Revert "adding AdminSettings to Get-Resource, and updating test"" This reverts commit 739b291408f7ca494e21ccd88e9f4e7c9a926420. --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 3 ++- .../MSFT_xSPWorkManagementServiceApp.psm1 | 16 +++++++++++++++- ...xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 7 +++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 67f1275dd..600a8e747 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -63,7 +63,8 @@ function Set-TargetResource } if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - New-SPSubscriptionSettingsServiceApplication @newParams + $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams + $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp } } else { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 797b0ead3..7bbc8629a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -32,6 +32,12 @@ function Get-TargetResource $returnVal = @{ Name = $serviceApp.DisplayName ApplicationPool = $serviceApp.ApplicationPool.Name + MinimumTimeBetweenEwsSyncSubscriptionSearches = $serviceApp.AdminSettings.MinimumTimeBetweenEwsSyncSubscriptionSearches.TotalMinutes + MinimumTimeBetweenProviderRefreshes= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + MinimumTimeBetweenSearchQueries= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + NumberOfSubscriptionSyncsPerEwsSyncRun= $serviceApp.AdminSettings.NumberOfSubscriptionSyncsPerEwsSyncRun + NumberOfUsersEwsSyncWillProcessAtOnce= $serviceApp.AdminSettings.NumberOfUsersEwsSyncWillProcessAtOnce + NumberOfUsersPerEwsSyncBatch= $serviceApp.AdminSettings.NumberOfUsersPerEwsSyncBatch } return $returnVal } @@ -146,7 +152,15 @@ function Test-TargetResource } } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool", + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch" + ) } Export-ModuleMember -Function *-TargetResource diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index f8b3edc53..a3c587a8c 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -33,7 +33,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - + Mock New-SPSubscriptionSettingsServiceApplicationProxy {} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -46,6 +46,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } @@ -120,7 +121,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } - Context "When a service app needs to be created and no database paramsters are provided" { + Context "When a service app needs to be created and no database parameters are provided" { $testParams = @{ Name = "Test App" ApplicationPool = "Test App Pool" @@ -128,10 +129,12 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } + Mock New-SPSubscriptionSettingsServiceApplicationProxy { } it "should not throw an exception in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication + Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } } From d9c71b698fb3f9a08826bb9a8f96fb00ae0cc030 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 02:37:43 +0000 Subject: [PATCH 78/91] Revert "adding AdminSettings to Get-Resource, and updating test" This reverts commit 6303122ad7fffaf02e835da1ef115da13dc8fd7b. --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 3 +-- .../MSFT_xSPWorkManagementServiceApp.psm1 | 16 +--------------- ...xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 7 ++----- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 600a8e747..67f1275dd 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -63,8 +63,7 @@ function Set-TargetResource } if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } - $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams - $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp + New-SPSubscriptionSettingsServiceApplication @newParams } } else { diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 7bbc8629a..797b0ead3 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -32,12 +32,6 @@ function Get-TargetResource $returnVal = @{ Name = $serviceApp.DisplayName ApplicationPool = $serviceApp.ApplicationPool.Name - MinimumTimeBetweenEwsSyncSubscriptionSearches = $serviceApp.AdminSettings.MinimumTimeBetweenEwsSyncSubscriptionSearches.TotalMinutes - MinimumTimeBetweenProviderRefreshes= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes - MinimumTimeBetweenSearchQueries= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes - NumberOfSubscriptionSyncsPerEwsSyncRun= $serviceApp.AdminSettings.NumberOfSubscriptionSyncsPerEwsSyncRun - NumberOfUsersEwsSyncWillProcessAtOnce= $serviceApp.AdminSettings.NumberOfUsersEwsSyncWillProcessAtOnce - NumberOfUsersPerEwsSyncBatch= $serviceApp.AdminSettings.NumberOfUsersPerEwsSyncBatch } return $returnVal } @@ -152,15 +146,7 @@ function Test-TargetResource } } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool", - "MinimumTimeBetweenEwsSyncSubscriptionSearches", - "MinimumTimeBetweenProviderRefreshes", - "MinimumTimeBetweenSearchQueries", - "Name", - "NumberOfSubscriptionSyncsPerEwsSyncRun", - "NumberOfUsersEwsSyncWillProcessAtOnce", - "NumberOfUsersPerEwsSyncBatch" - ) + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") } Export-ModuleMember -Function *-TargetResource diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index a3c587a8c..f8b3edc53 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -33,7 +33,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy {} + It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -46,7 +46,6 @@ Describe "xSPSubscriptionSettingsServiceApp" { It "creates a new service application in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication - Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } @@ -121,7 +120,7 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } - Context "When a service app needs to be created and no database parameters are provided" { + Context "When a service app needs to be created and no database paramsters are provided" { $testParams = @{ Name = "Test App" ApplicationPool = "Test App Pool" @@ -129,12 +128,10 @@ Describe "xSPSubscriptionSettingsServiceApp" { Mock Get-SPServiceApplication { return $null } Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy { } it "should not throw an exception in the set method" { Set-TargetResource @testParams Assert-MockCalled New-SPSubscriptionSettingsServiceApplication - Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy } } } From d6b95662f97ef5e386db464ec8ef6e385ec34f94 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 03:07:46 +0000 Subject: [PATCH 79/91] adding admin settings back in. and updating unit tests --- .../MSFT_xSPWorkManagementServiceApp.psm1 | 16 ++- ...oint.xSPWorkManagementServiceApp.Tests.ps1 | 108 ++++++++++++------ 2 files changed, 86 insertions(+), 38 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 index 797b0ead3..7bbc8629a 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1 @@ -32,6 +32,12 @@ function Get-TargetResource $returnVal = @{ Name = $serviceApp.DisplayName ApplicationPool = $serviceApp.ApplicationPool.Name + MinimumTimeBetweenEwsSyncSubscriptionSearches = $serviceApp.AdminSettings.MinimumTimeBetweenEwsSyncSubscriptionSearches.TotalMinutes + MinimumTimeBetweenProviderRefreshes= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + MinimumTimeBetweenSearchQueries= $serviceApp.AdminSettings.MinimumTimeBetweenProviderRefreshes.TotalMinutes + NumberOfSubscriptionSyncsPerEwsSyncRun= $serviceApp.AdminSettings.NumberOfSubscriptionSyncsPerEwsSyncRun + NumberOfUsersEwsSyncWillProcessAtOnce= $serviceApp.AdminSettings.NumberOfUsersEwsSyncWillProcessAtOnce + NumberOfUsersPerEwsSyncBatch= $serviceApp.AdminSettings.NumberOfUsersPerEwsSyncBatch } return $returnVal } @@ -146,7 +152,15 @@ function Test-TargetResource } } - return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool") + return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool", + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch" + ) } Export-ModuleMember -Function *-TargetResource diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 index 84463a967..41c39aa48 100644 --- a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 @@ -24,9 +24,9 @@ Describe "xSPWorkManagement" { MinimumTimeBetweenEwsSyncSubscriptionSearches =10 MinimumTimeBetweenProviderRefreshes=10 MinimumTimeBetweenSearchQueries=10 - NumberOfSubscriptionSyncsPerEwsSyncRun=5 - NumberOfUsersEwsSyncWillProcessAtOnce=5 - NumberOfUsersPerEwsSyncBatch=500 + NumberOfSubscriptionSyncsPerEwsSyncRun=10 + NumberOfUsersEwsSyncWillProcessAtOnce=10 + NumberOfUsersPerEwsSyncBatch=10 } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") @@ -37,6 +37,29 @@ Describe "xSPWorkManagement" { } Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue + Context "When a service application exists and Ensure equals 'absent'" { + $testParamsAbsent = @{ + Name = "Test Work Management App" + Ensure = "Absent" + } + Mock Get-SPServiceApplication { + return @(@{ + TypeName = "Work Management Service Application" + DisplayName = $testParamsAbsent.Name + ApplicationPool = @{ Name = "Wrong App Pool Name" } + }) + } + Mock Remove-SPServiceApplication{ } + + It "returns true when the Test method is called" { + Test-TargetResource @testParamsAbsent | Should Be $true + } + + It "calls the remove service app cmdlet from the set method" { + Set-TargetResource @testParamsAbsent + Assert-MockCalled Remove-SPServiceApplication + } + } Context "When no service applications exist in the current farm" { @@ -64,14 +87,28 @@ Describe "xSPWorkManagement" { Mock Set-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplication { } Mock New-SPWorkManagementServiceApplicationProxy { } - - Mock Get-SPServiceApplication { return @(@{ - TypeName = "Some other service app type" - }) } - + $Global:GetSpServiceApplicationCalled=$false + Mock Get-SPServiceApplication { + if($Global:GetSpServiceApplicationCalled -eq $false){ + $Global:GetSpServiceApplicationCalled=$true; + return @(@{ + TypeName = "Some other service app type" + }) + } + return @(@{ + TypeName = "Work Management Service Application" + }) + } + + It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + } + + It "creates new app from the Get method" { + Set-TargetResource @testParams | Should BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } Assert-MockCalled Set-SPWorkManagementServiceApplication -ParameterFilter { $Name -eq $testParams.Name } } @@ -81,18 +118,28 @@ Describe "xSPWorkManagement" { Mock Get-SPServiceApplication { return @(@{ TypeName = "Work Management Service Application" - DisplayName = $testParams.Name - ApplicationPool = @{ Name = $testParams.ApplicationPool } + DisplayName = $testParamsComplete.Name + ApplicationPool = @{ Name = $testParamsComplete.ApplicationPool } + AdminSettings = @{ + MinimumTimeBetweenEwsSyncSubscriptionSearches = (new-timespan -minutes 10) + MinimumTimeBetweenProviderRefreshes= (new-timespan -minutes 10) + MinimumTimeBetweenSearchQueries= (new-timespan -minutes 10) + NumberOfSubscriptionSyncsPerEwsSyncRun=10 + NumberOfUsersEwsSyncWillProcessAtOnce= 10 + NumberOfUsersPerEwsSyncBatch= 10 + + } + }) } It "returns values from the get method" { - Get-TargetResource @testParams | Should Not BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Get-TargetResource @testParamsComplete | Should Not BeNullOrEmpty + Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsComplete.Name } } It "returns true when the Test method is called" { - Test-TargetResource @testParams | Should Be $true + Test-TargetResource @testParamsComplete | Should Be $true } } @@ -102,6 +149,16 @@ Describe "xSPWorkManagement" { TypeName = "Work Management Service Application" DisplayName = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } + AdminSettings = @{ + MinimumTimeBetweenEwsSyncSubscriptionSearches = (new-timespan -minutes 10) + MinimumTimeBetweenProviderRefreshes= (new-timespan -minutes 10) + MinimumTimeBetweenSearchQueries= (new-timespan -minutes 10) + NumberOfSubscriptionSyncsPerEwsSyncRun=10 + NumberOfUsersEwsSyncWillProcessAtOnce= 10 + NumberOfUsersPerEwsSyncBatch= 10 + + } + }) } Mock Set-SPWorkManagementServiceApplication { } @@ -113,30 +170,7 @@ Describe "xSPWorkManagement" { It "calls the update service app cmdlet from the set method" { Set-TargetResource @testParamsComplete Assert-MockCalled Set-SPWorkManagementServiceApplication - Assert-MockCalled Get-SPWorkManagementServiceApplication - } - } - Context "When a service application exists and Ensure equals 'absent'" { - $testParamsAbsent = @{ - Name = "Test Work Management App" - Ensure = "Absent" - } - Mock Get-SPServiceApplication { - return @(@{ - TypeName = "Work Management Service Application" - DisplayName = $testParamsAbsent.Name - ApplicationPool = @{ Name = "Wrong App Pool Name" } - }) - } - Mock Remove-SPServiceApplication{ } - - It "returns false when the Test method is called" { - Test-TargetResource $testParamsAbsent | Should Be $false - } - - It "calls the update service app cmdlet from the set method" { - Set-TargetResource $testParamsAbsent - Assert-MockCalled Remove-SPServiceApplication + Assert-MockCalled Get-SPServiceApplication } } From 0a47c354c1ff7a33d7bae16337ae626642d3a6db Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 03:12:19 +0000 Subject: [PATCH 80/91] addressing @TravisEz13 notes. --- .../xSharePoint.Util/xSharePoint.Util.psm1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 188c0c314..cfa216be3 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -37,11 +37,11 @@ function Get-xSharePointUserProfileSubTypeManager { [CmdletBinding()] param ( - $context + $Context ) [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null - return [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context) + return [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($Context) } function Get-xSharePointInstalledProductVersion() { @@ -123,16 +123,16 @@ function Rename-xSharePointParamValue() { [CmdletBinding()] param ( - [parameter(Mandatory = $true,Position=1,ValueFromPipeline=$true)] $params, - [parameter(Mandatory = $true,Position=2)] $oldName, - [parameter(Mandatory = $true,Position=3)] $newName + [parameter(Mandatory = $true,Position=1,ValueFromPipeline=$true)] $Params, + [parameter(Mandatory = $true,Position=2)] $OldName, + [parameter(Mandatory = $true,Position=3)] $NewName ) - if ($params.ContainsKey($oldName)) { - $params.Add($newName, $params.$oldName) - $params.Remove($oldName) | Out-Null + if ($Params.ContainsKey($OldName)) { + $Params.Add($NewName, $Params.$OldName) + $Params.Remove($OldName) | Out-Null } - return $params + return $Params } function Remove-xSharePointUserToLocalAdmin() { From cdfcb00cad7d20d08b6c68e25a0901ce74e67a9b Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 03:16:12 +0000 Subject: [PATCH 81/91] adding extra line to the bottom of the test file --- Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index f8b3edc53..8bd16bcfd 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -136,3 +136,5 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } } + + From 3ff1aa8dd70d259a7e3adeafdf8e03368d85f9e1 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 03:24:12 +0000 Subject: [PATCH 82/91] fixing mixed up commits. --- .../MSFT_xSPSubscriptionSettingsServiceApp.psm1 | 2 +- .../xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 index 1bcdd0765..600a8e747 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSubscriptionSettingsServiceApp/MSFT_xSPSubscriptionSettingsServiceApp.psm1 @@ -64,7 +64,7 @@ function Set-TargetResource if ($params.ContainsKey("DatabaseName") -eq $true) { $newParams.Add("DatabaseName", $params.DatabaseName) } if ($params.ContainsKey("DatabaseServer") -eq $true) { $newParams.Add("DatabaseServer", $params.DatabaseServer) } $serviceApp = New-SPSubscriptionSettingsServiceApplication @newParams - $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp -DefaultProxyGroup + $proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp } } else { diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index f17275154..517a8eaf1 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -32,8 +32,8 @@ Describe "xSPSubscriptionSettingsServiceApp" { Context "When no service applications exist in the current farm" { Mock Get-SPServiceApplication { return $null } - Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy {} + Mock New-SPSubscriptionSettingsServiceApplication { return @{}} + Mock New-SPSubscriptionSettingsServiceApplicationProxy { return @{}} It "returns null from the Get method" { Get-TargetResource @testParams | Should BeNullOrEmpty Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } @@ -128,8 +128,8 @@ Describe "xSPSubscriptionSettingsServiceApp" { } Mock Get-SPServiceApplication { return $null } - Mock New-SPSubscriptionSettingsServiceApplication { } - Mock New-SPSubscriptionSettingsServiceApplicationProxy { } + Mock New-SPSubscriptionSettingsServiceApplication {return @{} } + Mock New-SPSubscriptionSettingsServiceApplicationProxy { return @{}} it "should not throw an exception in the set method" { Set-TargetResource @testParams From 1c639d3a1bf9679d13ca0f831eec5687d8bc3774 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 03:57:34 +0000 Subject: [PATCH 83/91] damn missing extra line --- .../xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 index 517a8eaf1..f875e5cbd 100644 --- a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 @@ -138,4 +138,5 @@ Describe "xSPSubscriptionSettingsServiceApp" { } } } -} \ No newline at end of file +} + From 8e394af7bad6fc42f307774803952ce0efaf4543 Mon Sep 17 00:00:00 2001 From: Camilo Date: Fri, 29 Jan 2016 04:31:23 +0000 Subject: [PATCH 84/91] fixing 'integrated' unit test issue. (exception calling add-type for connection after property also did) --- Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 | 2 +- .../xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 index 840653806..bb92b1017 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 @@ -76,7 +76,7 @@ Describe "xSPUserProfileProperty" { public enum ConnectionType { ActiveDirectory, BusinessDataCatalog }; public enum ProfileType { User}; } -"@ +"@ -ErrorAction SilentlyContinue } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 index f624d7b08..f51a75498 100644 --- a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 @@ -31,8 +31,9 @@ Describe "xSPUserProfileSyncConnection" { Add-Type @" namespace Microsoft.Office.Server.UserProfiles { public enum ConnectionType { ActiveDirectory, BusinessDataCatalog }; + public enum ProfileType { User}; } -"@ +"@ -ErrorAction SilentlyContinue } Import-Module (Join-Path ((Resolve-Path $PSScriptRoot\..\..).Path) "Modules\xSharePoint") From 14423f8eecbf11ef869cd102b74a432a2d073f39 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 19:01:06 +1100 Subject: [PATCH 85/91] Fixed issue with minrole in join farm --- .../DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index bde31be48..87444040f 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -76,8 +76,13 @@ function Set-TargetResource Write-Verbose -Message "Detected Version: SharePoint 2013" } 16 { - Write-Verbose -Message "Detected Version: SharePoint 2016" - $joinFarmArgs.Add("LocalServerRole", "Custom") + if ($params.ContainsKey("ServerRole") -eq $true) { + Write-Verbose -Message "Detected Version: SharePoint 2016 - configuring server as $($params.ServerRole)" + $newFarmArgs.Add("LocalServerRole", $params.ServerRole) + } else { + Write-Verbose -Message "Detected Version: SharePoint 2016 - no server role provided, configuring server without a specific role" + $newFarmArgs.Add("ServerRoleOptional", $true) + } } Default { throw [Exception] "An unknown version of SharePoint (Major version $_) was detected. Only versions 15 (SharePoint 2013) or 16 (SharePoint 2016) are supported." From 23bfe387f690b8a02afa9a54d97c2d79195be60d Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 19:02:36 +1100 Subject: [PATCH 86/91] Prepare for v0.10 release --- Modules/xSharePoint/xSharePoint.psd1 | 2 +- README.md | 3 ++- appveyor.yml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index c891e5e64..8a6a441af 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -12,7 +12,7 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '0.9.0.0' +ModuleVersion = '0.10.0.0' # ID used to uniquely identify this module GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' diff --git a/README.md b/README.md index 2aad957e6..3d065fa48 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,10 @@ Additional detailed documentation is included on the wiki on GitHub. ## Version History -### Unreleased +### 0.10.0.0 * Added xSPWordAutomationServiceApp, xSPHealthAnalyzerRuleState, xSPUserProfileProperty, xSPWorkManagementApp, xSPUserProfileSyncConnection and xSPShellAdmin resources + * Fixed issue with MinRole support in xSPJoinFarm ### 0.9.0.0 diff --git a/appveyor.yml b/appveyor.yml index b9a629f95..34b0ee083 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.9.{build}.0 +version: 0.10.{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.9.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest + (Get-Content $manifest -Raw).Replace("0.10.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 } From 94a175910a2c8f8785224a31647862a4972cac2c Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 19:49:30 +1100 Subject: [PATCH 87/91] Fixed typoe in change to right variable name --- .../DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 4 ++-- Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index 87444040f..43f27dad5 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -78,10 +78,10 @@ function Set-TargetResource 16 { if ($params.ContainsKey("ServerRole") -eq $true) { Write-Verbose -Message "Detected Version: SharePoint 2016 - configuring server as $($params.ServerRole)" - $newFarmArgs.Add("LocalServerRole", $params.ServerRole) + $joinFarmArgs.Add("LocalServerRole", $params.ServerRole) } else { Write-Verbose -Message "Detected Version: SharePoint 2016 - no server role provided, configuring server without a specific role" - $newFarmArgs.Add("ServerRoleOptional", $true) + $joinFarmArgs.Add("ServerRoleOptional", $true) } } Default { diff --git a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 index 81e26a8bf..8932c2508 100644 --- a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 @@ -61,7 +61,7 @@ Describe "xSPJoinFarm" { Assert-MockCalled Connect-SPConfigurationDatabase } 16 { - Assert-MockCalled Connect-SPConfigurationDatabase -ParameterFilter { $LocalServerRole -ne $null } + Assert-MockCalled Connect-SPConfigurationDatabase -ParameterFilter { $ServerRoleOptional -eq $true } } Default { throw [Exception] "A supported version of SharePoint was not used in testing" From d19387b3068c9829ce6c2f9adfe8e0fef75c8698 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 19:57:52 +1100 Subject: [PATCH 88/91] Removed redundant serverroleoptional parameter --- .../DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index 43f27dad5..1d6f2dfd8 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -81,7 +81,6 @@ function Set-TargetResource $joinFarmArgs.Add("LocalServerRole", $params.ServerRole) } else { Write-Verbose -Message "Detected Version: SharePoint 2016 - no server role provided, configuring server without a specific role" - $joinFarmArgs.Add("ServerRoleOptional", $true) } } Default { From fd83855103e2c253532d6110f2e57056e08693a3 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 20:03:46 +1100 Subject: [PATCH 89/91] Fixed test to remove redundant parameter --- Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 index 8932c2508..53002ab25 100644 --- a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 +++ b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 @@ -61,7 +61,7 @@ Describe "xSPJoinFarm" { Assert-MockCalled Connect-SPConfigurationDatabase } 16 { - Assert-MockCalled Connect-SPConfigurationDatabase -ParameterFilter { $ServerRoleOptional -eq $true } + Assert-MockCalled Connect-SPConfigurationDatabase } Default { throw [Exception] "A supported version of SharePoint was not used in testing" From cf658f729fabb3ecc6abca417fe6a2dcaf82305e Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 20:12:45 +1100 Subject: [PATCH 90/91] Rearranged to line up with structure for help generation --- .../MSFT_xSPShellAdmins.schema.mof | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof index abfda3562..5964bf97d 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof @@ -1,3 +1,11 @@ +[ClassVersion("1.0.0")] +Class MSFT_xSPContentDatabasePermissions +{ + [Key, Description("Name of the Content Database")] String Name; + [Write, Description("Exact list of accounts that will have to get Shell Admin permissions")] String Members[]; + [Write, Description("List of all accounts that must be in the Shell Admins group")] String MembersToInclude[]; + [Write, Description("List of all accounts that are not allowed to have Shell Admin permissions")] String MembersToExclude[]; +}; /* **Description** @@ -43,16 +51,6 @@ Workaround: Change database owner in SQL Server. } */ - -[ClassVersion("1.0.0")] -Class MSFT_xSPContentDatabasePermissions -{ - [Key, Description("Name of the Content Database")] String Name; - [Write, Description("Exact list of accounts that will have to get Shell Admin permissions")] String Members[]; - [Write, Description("List of all accounts that must be in the Shell Admins group")] String MembersToInclude[]; - [Write, Description("List of all accounts that are not allowed to have Shell Admin permissions")] String MembersToExclude[]; -}; - [ClassVersion("1.0.0.0"), FriendlyName("xSPShellAdmins")] class MSFT_xSPShellAdmins : OMI_BaseResource { From a3ee0d884f9bfb44d9527620f11301c1246e8cbc Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sat, 30 Jan 2016 20:56:04 +1100 Subject: [PATCH 91/91] Adding help files for release --- .../en-us/about_xSPAntivirusSettings.help.txt | 28 ++++++++ .../en-us/about_xSPAppCatalog.help.txt | 21 ++++++ .../en-us/about_xSPAppDomain.help.txt | 24 +++++++ .../about_xSPAppManagementServiceApp.help.txt | 27 ++++++++ .../en-us/about_xSPBCSServiceApp.help.txt | 28 ++++++++ .../en-us/about_xSPCacheAccounts.help.txt | 23 +++++++ .../en-us/about_xSPCreateFarm.help.txt | 38 ++++++++++ .../en-us/about_xSPDesignerSettings.help.txt | 45 ++++++++++++ ...bout_xSPDiagnosticLoggingSettings.help.txt | 54 +++++++++++++++ .../about_xSPDistributedCacheService.help.txt | 30 ++++++++ .../about_xSPFarmAdministrators.help.txt | 25 +++++++ .../en-us/about_xSPFeature.help.txt | 27 ++++++++ .../about_xSPHealthAnalyzerRuleState.help.txt | 28 ++++++++ .../en-us/about_xSPInstall.help.txt | 37 ++++++++++ .../en-us/about_xSPInstallPrereqs.help.txt | 69 +++++++++++++++++++ .../en-us/about_xSPJoinFarm.help.txt | 26 +++++++ .../en-us/about_xSPManagedAccount.help.txt | 26 +++++++ ...bout_xSPManagedMetaDataServiceApp.help.txt | 27 ++++++++ .../en-us/about_xSPManagedPath.help.txt | 28 ++++++++ .../about_xSPOutgoingEmailSettings.help.txt | 28 ++++++++ .../about_xSPPasswordChangeSettings.help.txt | 27 ++++++++ .../en-us/about_xSPQuotaTemplate.help.txt | 29 ++++++++ .../about_xSPSearchIndexPartition.help.txt | 35 ++++++++++ .../en-us/about_xSPSearchServiceApp.help.txt | 27 ++++++++ .../en-us/about_xSPSearchTopology.help.txt | 42 +++++++++++ .../about_xSPSecureStoreServiceApp.help.txt | 34 +++++++++ .../en-us/about_xSPServiceAppPool.help.txt | 22 ++++++ .../en-us/about_xSPServiceInstance.help.txt | 29 ++++++++ .../about_xSPSessionStateService.help.txt | 26 +++++++ .../en-us/about_xSPShellAdmins.help.txt | 56 +++++++++++++++ .../xSharePoint/en-us/about_xSPSite.help.txt | 38 ++++++++++ .../en-us/about_xSPStateServiceApp.help.txt | 24 +++++++ ...xSPSubscriptionSettingsServiceApp.help.txt | 27 ++++++++ .../en-us/about_xSPTimerJobState.help.txt | 38 ++++++++++ .../en-us/about_xSPUsageApplication.help.txt | 32 +++++++++ .../about_xSPUserProfileProperty.help.txt | 69 +++++++++++++++++++ .../about_xSPUserProfileServiceApp.help.txt | 40 +++++++++++ ...bout_xSPUserProfileSyncConnection.help.txt | 37 ++++++++++ .../about_xSPUserProfileSyncService.help.txt | 26 +++++++ .../en-us/about_xSPVisioServiceApp.help.txt | 18 +++++ .../about_xSPWebAppBlockedFileTypes.help.txt | 30 ++++++++ .../about_xSPWebAppGeneralSettings.help.txt | 39 +++++++++++ .../en-us/about_xSPWebAppPolicy.help.txt | 24 +++++++ ...about_xSPWebAppSiteUseAndDeletion.help.txt | 28 ++++++++ ...about_xSPWebAppThrottlingSettings.help.txt | 42 +++++++++++ .../about_xSPWebAppWorkflowSettings.help.txt | 26 +++++++ .../en-us/about_xSPWebApplication.help.txt | 38 ++++++++++ .../about_xSPWebApplicationAppDomain.help.txt | 31 +++++++++ ...about_xSPWordAutomationServiceApp.help.txt | 69 +++++++++++++++++++ 49 files changed, 1642 insertions(+) create mode 100644 Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPFeature.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPHealthAnalyzerRuleState.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPInstall.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPShellAdmins.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSite.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPUserProfileProperty.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPUserProfileServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPUserProfileSyncConnection.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPUserProfileSyncService.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt create mode 100644 Modules/xSharePoint/en-us/about_xSPWordAutomationServiceApp.help.txt diff --git a/Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt new file mode 100644 index 000000000..36c109a8e --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt @@ -0,0 +1,28 @@ +NAME + xSPAntivirusSettings + +PARAMETERS + ScanOnDownload (Key, Boolean) + ScanOnUpload (Write, Boolean) + AllowDownloadInfected (Write, Boolean) + AttemptToClean (Write, Boolean) + TimeoutDuration (Write, Uint16) + NumberOfThreads (Write, Uint16) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to set the global antivirus settings for the local farm. +These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. +Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. + +EXAMPLE + + xSPAntivirusSettings AVSettings + { + ScanOnDownload = $true + ScanOnUpload = $true + AllowDownloadInfected = $false + AttemptToClean = $false + } + diff --git a/Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt b/Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt new file mode 100644 index 000000000..2517b9435 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt @@ -0,0 +1,21 @@ +NAME + xSPAppCatalog + +PARAMETERS + SiteUrl (Key, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will ensure that a specific site collection is marked as the app catalog for the web application that the site is in. +The catalog site needs to have been created using the correct template (APPCATALOG#0). + +EXAMPLE + + xSPAppCatalog MainAppCatalog + { + SiteUrl = "https://content.sharepoint.contoso.com/sites/AppCatalog" + PsDscRunAsCredential = $SPSetupAccount + } + + diff --git a/Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt b/Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt new file mode 100644 index 000000000..0c0fb216e --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt @@ -0,0 +1,24 @@ +NAME + xSPAppDomain + +PARAMETERS + AppDomain (Key, string) + Prefix (Required, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will set the value for the app domain settings at the farm level. +You can set the domain name and the prefix that is to be used for app URLs. + + +EXAMPLE + + xSPAppDomain LocalFarmAppUrls + { + AppDomain = "contosointranetapps.com" + Prefix = "app" + PsDscRunAsCredential = $InstallAccount + } + + diff --git a/Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt new file mode 100644 index 000000000..907b721de --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt @@ -0,0 +1,27 @@ +NAME + xSPAppManagementServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, String) + DatabaseName (Write, string) + DatabaseServer (Write, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to provision and manage an instance of the App Management Services Service Application. +It will identify an instance of the app management service application through the application display name. +Currently the resource will provision the app if it does not yet exist, and will change the application pool associated to the app if it does not match the configuration. +Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. + +EXAMPLE + + xSPAppManagementServiceApp AppManagementServiceApp + { + Name = "App Management Service Application" + AppPool = "SharePoint web services" + DatabaseServer = "SQL01.contoso.com" + DatabaseName = "SP_ManagedMetadata" +} + diff --git a/Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt new file mode 100644 index 000000000..1ae922739 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt @@ -0,0 +1,28 @@ +NAME + xSPBCSServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, String) + DatabaseName (Write, string) + DatabaseServer (Write, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to provision and manage an instance of the Business Connectivity Services Service Application. +It will identify an instance of the BCS app through the application display name. +Currently the resource will provision the app if it does not yet exist, and will change the service account associated to the app if it does not match the configuration. +Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. + +EXAMPLE + + xSPBCSServiceApp BCSServiceApp + { + Name = "BCS Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseName = "SP_BCS" + DatabaseServer = $DatabaseServer + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt b/Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt new file mode 100644 index 000000000..ff8f5448e --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt @@ -0,0 +1,23 @@ +NAME + xSPCacheAccounts + +PARAMETERS + WebAppUrl (Key, string) + SuperUserAlias (Required, string) + SuperReaderAlias (Required, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to set the "super user" and "super reader" cache accounts for the specified web application object (as described in the TechNet article [Configure object cache user accounts in SharePoint Server 2013](https://technet.microsoft.com/en-us/library/ff758656.aspx)). + +EXAMPLE + + xSPCacheAccounts SetCacheAccounts + { + WebAppUrl = "http://sharepoint.contoso.com" + SuperUserAlias = "DEMO\svcSPSuperUser" + SuperReaderAlias = "DEMO\svcSPReader" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt b/Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt new file mode 100644 index 000000000..3a963643f --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt @@ -0,0 +1,38 @@ +NAME + xSPCreateFarm + +PARAMETERS + FarmConfigDatabaseName (Key, String) + DatabaseServer (Key, String) + FarmAccount (Required, String) + InstallAccount (Write, String) + Passphrase (Required, String) + AdminContentDatabaseName (Required, String) + CentralAdministrationPort (Write, uint32) + ServerRole (Write, string, Allowed values: Application, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, SpecialLoad, WebFrontEnd) + +DESCRIPTION + +This resource is used to provision a new SharePoint farm. +It should only be used on the first server in the farm to create the configuration database, all servers to join the farm after the first server creates the configuration database should use [xSPJoinFarm](xSPJoinFarm). +Once the config DB has been created, the resource will install local help collections, secure resources, activate features and provision the central admin site. + +The port of the Central Admin website can be set by using the CentralAdministrationPort property, if this is not defined the site will be provisioned on port 9999. +However this setting will not impact existing deployments that already have Central Admin provisioned on another port. +Also when a farm is created, the current behavior is to not enroll the server as a cache server (which is the default behavior of SharePoint). +This means you need to use [xSPDistributedCacheService](xSPDistributedCacheService) on at least one server in the farm to designate it as a cache server. + +EXAMPLE + + xSPCreateFarm CreateSPFarm + { + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + FarmConfigDatabaseName = "SP_Config" + Passphrase = "Example Passphrase" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SetupAccount + AdminContentDatabaseName = "SP_AdminContent" + CentralAdministrationPort = 2000 + ServerRole = Custom + } + diff --git a/Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt new file mode 100644 index 000000000..3f633ae0a --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt @@ -0,0 +1,45 @@ +NAME + xSPDesignerSettings + +PARAMETERS + Url (Key, string) + SettingsScope (Required, string, Allowed values: WebApplication, SiteCollection) + AllowSharePointDesigner (Write, Boolean) + AllowDetachPagesFromDefinition (Write, Boolean) + AllowCustomiseMasterPage (Write, Boolean) + AllowManageSiteURLStructure (Write, Boolean) + AllowCreateDeclarativeWorkflow (Write, Boolean) + AllowSavePublishDeclarativeWorkflow (Write, Boolean) + AllowSaveDeclarativeWorkflowAsTemplate (Write, Boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to set the SharePoint Designer settings for the local farm or site collections. +These settings will be used to control if users are allowed to make changes using SharePoint Designer. +Note that this will not prevent users from installing SharePoint Designer, just from using SharePoint Designer to connect to the farm. + +Settings can be applied against an entire web application, or a specific site collection. +Use the "SettingsScope" property to set it to either "WebApplication" or "SiteCollection" to define which you are targetting. + +Known issue: +When using PowerShell v4 or PowerShell v5 with the InstallAccount switch (instead of PsDscRunAsCredential), you cannot use the SettingsScope "SiteCollection". +Due to an issue with Remote PowerShell and SharePoint, changing the Site Collection settings results in an Access Denied error. +Consider implementing PowerShell v5 and switching to the PsDscRunAsCredential configuration. + +EXAMPLE + + xSPDesignerSettings MainWebAppSPDSettings + { + Url = "https://intranet.sharepoint.contoso.com" + SettingsScope = "WebApplication" + AllowSharePointDesigner = $false + AllowDetachPagesFromDefinition = $false + AllowCustomiseMasterPage = $false + AllowManageSiteURLStructure = $false + AllowCreateDeclarativeWorkflow = $false + AllowSavePublishDeclarativeWorkflow = $false + AllowSaveDeclarativeWorkflowAsTemplate = $false + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt new file mode 100644 index 000000000..e7aed4e26 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt @@ -0,0 +1,54 @@ +NAME + xSPDiagnosticLoggingSettings + +PARAMETERS + LogPath (Key, string) + LogSpaceInGB (Required, uint32) + AppAnalyticsAutomaticUploadEnabled (Write, boolean) + CustomerExperienceImprovementProgramEnabled (Write, boolean) + DaysToKeepLogs (Write, uint32) + DownloadErrorReportingUpdatesEnabled (Write, boolean) + ErrorReportingAutomaticUploadEnabled (Write, boolean) + ErrorReportingEnabled (Write, boolean) + EventLogFloodProtectionEnabled (Write, boolean) + EventLogFloodProtectionNotifyInterval (Write, uint32) + EventLogFloodProtectionQuietPeriod (Write, uint32) + EventLogFloodProtectionThreshold (Write, uint32) + EventLogFloodProtectionTriggerPeriod (Write, uint32) + LogCutInterval (Write, uint32) + LogMaxDiskSpaceUsageEnabled (Write, boolean) + ScriptErrorReportingDelay (Write, uint32) + ScriptErrorReportingEnabled (Write, boolean) + ScriptErrorReportingRequireAuth (Write, boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for configuring settings to do with the diagnostic (ULS) logging on servers in the farm. +These settings are applied to the diagnostic logging service for the farm and do not need to be applied to each server individually, the settings will be propagated throughout the farm when they are set. + +EXAMPLE + + xSPDiagnosticLoggingSettings ApplyDiagnosticLogSettings + { + PsDscRunAsCredential = $InstallAccount + LogPath = "L:\ULSLogs" + LogSpaceInGB = 10 + AppAnalyticsAutomaticUploadEnabled = $false + CustomerExperienceImprovementProgramEnabled = $true + DaysToKeepLogs = 7 + DownloadErrorReportingUpdatesEnabled = $false + ErrorReportingAutomaticUploadEnabled = $false + ErrorReportingEnabled = $false + EventLogFloodProtectionEnabled = $true + EventLogFloodProtectionNotifyInterval = 5 + EventLogFloodProtectionQuietPeriod = 2 + EventLogFloodProtectionThreshold = 5 + EventLogFloodProtectionTriggerPeriod = 2 + LogCutInterval = 15 + LogMaxDiskSpaceUsageEnabled = $true + ScriptErrorReportingDelay = 30 + ScriptErrorReportingEnabled = $true + ScriptErrorReportingRequireAuth = $true + } + diff --git a/Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt b/Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt new file mode 100644 index 000000000..8801f477f --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt @@ -0,0 +1,30 @@ +NAME + xSPDistributedCacheService + +PARAMETERS + Name (Key, String) + Ensure (Required, string, Allowed values: Present, Absent) + CacheSizeInMB (Required, UInt32) + ServiceAccount (Required, String) + InstallAccount (Write, String) + CreateFirewallRules (Required, Boolean) + +DESCRIPTION + +This resource is responsible for provisioning the distributed cache to the service it runs on. +This is required in your farm on at least one server (as the behavior of [xSPCreateFarm](xSPCreateFarm) and [xSPJoinFarm](xSPJoinFarm) is to not enroll every server as a cache server). +The service will be provisioned or de-provisioned based on the Ensure property, and when provisioned the CacheSizeInMB property and ServiceAccount property will be used to configure it. +The property createFirewallRules is used to determine if exceptions should be added to the windows firewall to allow communication between servers on the appropriate ports. + +EXAMPLE + + xSPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 8192 + ServiceAccount = "DEMO\ServiceAccount" + InstallAccount = $InstallAccount + CreateFirewallRules = $true + } + diff --git a/Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt b/Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt new file mode 100644 index 000000000..e93f8e886 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt @@ -0,0 +1,25 @@ +NAME + xSPFarmAdministrators + +PARAMETERS + Name (Key, String) + Members (Write, String) + MembersToInclude (Write, String) + MembersToExclude (Write, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to manage the membership of the farm administrators group. +There are a number of approaches to how this can be implemented. +The "members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. +The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. + +EXAMPLE + + xSPFarmAdministrators LocalFarmAdmins + { + Name = "Farm Administrators" + Members = @("CONTOSO\user1", "CONTOSO\user2") + } + diff --git a/Modules/xSharePoint/en-us/about_xSPFeature.help.txt b/Modules/xSharePoint/en-us/about_xSPFeature.help.txt new file mode 100644 index 000000000..819300593 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPFeature.help.txt @@ -0,0 +1,27 @@ +NAME + xSPFeature + +PARAMETERS + Name (Key, string) + FeatureScope (Required, string, Allowed values: Farm, WebApplication, Site, Web) + Url (Key, string) + InstallAccount (Write, String) + Ensure (Required, string, Allowed values: Present, Absent) + +DESCRIPTION + +This resource is used to make sure that a specific feature is either enabled or disabled at a given URL/scope. +The Ensure property will dictate if the feature should be on or off. +The name property is the name of the feature based on its folder name in the FEATURES folder in the SharePoint hive directory. + +EXAMPLE + + xSPFeature EnableViewFormsLockDown + { + Name = "ViewFormPagesLockDown" + Url = "http://www.contoso.com" + Ensure = "Present" + Scope = "Site" + PsDscRunAsCredential = $SetupAccuount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPHealthAnalyzerRuleState.help.txt b/Modules/xSharePoint/en-us/about_xSPHealthAnalyzerRuleState.help.txt new file mode 100644 index 000000000..46f3efb57 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPHealthAnalyzerRuleState.help.txt @@ -0,0 +1,28 @@ +NAME + xSPHealthAnalyzerRuleState + +PARAMETERS + Name (Key, String) + Enabled (Required, Boolean) + RuleScope (Write, String, Allowed values: All Servers, Any Server) + Schedule (Write, String, Allowed values: Hourly, Daily, Weekly, Monthly, OnDemandOnly) + FixAutomatically (Write, Boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to configure Health Analyzer rules for the local farm. +The resource is able to enable/disable and configure the specified rule. + +EXAMPLE + + xSPHealthAnalyzerRuleState DisableDiskSpaceRule + { + Name = "Drives are at risk of running out of free space." + Enabled = $true + RuleScope = "All Servers" + Schedule = "Daily" + FixAutomatically = $false + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPInstall.help.txt b/Modules/xSharePoint/en-us/about_xSPInstall.help.txt new file mode 100644 index 000000000..11fd1b24d --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPInstall.help.txt @@ -0,0 +1,37 @@ +NAME + xSPInstall + +PARAMETERS + BinaryDir (Key, String) + ProductKey (Required, String) + Ensure (Required, string, Allowed values: Present, Absent) + +DESCRIPTION + +This resource is used to install the SharePoint binaries. +The BinaryDir parameter should point to the path that setup.exe is located (not to setup.exe itself). +The ProductKey parameter is used to inject in to the configuration file and validate the license key during the installation process. +This module depends on the prerequisites already being installed, which can be done through the use of [xSPInstallPreReqs](xSPInstallPreReqs). + +EXAMPLE + + xSPInstall InstallBinaries + { + BinaryDir = "C:\SPInstall" + ProductKey = $ProductKey + } + +**Installing SharePoint Foundation 2013** + +Currently SharePoint Foundation is not supported by xSPInstall (see [Issue #81](https://github.com/PowerShell/xSharePoint/issues/81) for the details). A workaround for this is to use the package resource as demonstrated below. + + Package InstallSharePointFoundation + { + Ensure = "Present" + Name = "Microsoft SharePoint Foundation 2013 Core" + Path = "E:\SharePoint2013\Setup.exe" + Arguments = "/config E:\SharePoint2013\files\setupfarmsilent\config.xml" + ProductID = "90150000-1014-0000-1000-0000000FF1CE" + ReturnCode = 0 + } + diff --git a/Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt b/Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt new file mode 100644 index 000000000..2df04ba51 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt @@ -0,0 +1,69 @@ +NAME + xSPInstallPrereqs + +PARAMETERS + InstallerPath (Key, String) + OnlineMode (Required, Boolean) + SQLNCli (Write, String) + PowerShell (Write, String) + NETFX (Write, String) + IDFX (Write, String) + Sync (Write, String) + AppFabric (Write, String) + IDFX11 (Write, String) + MSIPCClient (Write, String) + WCFDataServices (Write, String) + KB2671763 (Write, String) + WCFDataServices56 (Write, String) + KB2898850 (Write, String) + MSVCRT11 (Write, String) + MSVCRT14 (Write, String) + KB3092423 (Write, String) + ODBC (Write, String) + DotNet452 (Write, String) + Ensure (Required, string, Allowed values: Present, Absent) + +DESCRIPTION + +This resource is responsible for ensuring the installation of all SharePoint prerequisites. +It makes use of the PrerequisiteInstaller.exe file that is part of the SharePoint binaries, and will install the required Windows features as well as additional software. +The OnlineMode boolean will tell the prerequisite installer which mode to run in, if it is online you do not need to list any other parameters for this resource. +If you do not use online mode, you must include all other parameters to specify where the installation files are located. +These additional parameters map directly to the options passed to prerequisiteinstaller.exe. + +Additionally, the process of installing the prerequisites on a Windows Server usually results in 2-3 restarts of the system being required. To ensure the DSC configuration is able to restart the server when needed, ensure the below settings for the local configuration manager are included in your DSC file. + + LocalConfigurationManager + { + RebootNodeIfNeeded = $true + } + +**Examples** + +Online example: + + xSPInstallPrereqs InstallPrerequisites + { + InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" + OnlineMode = $true + } + +Offline example: + + xSPInstallPrereqs InstallPrerequisites + { + InstallerPath = "C:\SPInstall\Prerequisiteinstaller.exe" + OnlineMode = $false + SQLNCli = "C:\SPInstall\prerequisiteinstallerfiles\sqlncli.msi" + PowerShell = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB2506143-x64.msu" + NETFX = "C:\SPInstall\prerequisiteinstallerfiles\dotNetFx45_Full_setup.exe" + IDFX = "C:\SPInstall\prerequisiteinstallerfiles\Windows6.1-KB974405-x64.msu" + Sync = "C:\SPInstall\prerequisiteinstallerfiles\Synchronization.msi" + AppFabric = "C:\SPInstall\prerequisiteinstallerfiles\WindowsServerAppFabricSetup_x64.exe" + IDFX11 = "C:\SPInstall\prerequisiteinstallerfiles\MicrosoftIdentityExtensions-64.msi" + MSIPCClient = "C:\SPInstall\prerequisiteinstallerfiles\setup_msipc_x64.msi" + WCFDataServices = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices.exe" + KB2671763 = "C:\SPInstall\prerequisiteinstallerfiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe" + WCFDataServices56 = "C:\SPInstall\prerequisiteinstallerfiles\WcfDataServices56.exe" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt b/Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt new file mode 100644 index 000000000..5c3151c05 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt @@ -0,0 +1,26 @@ +NAME + xSPJoinFarm + +PARAMETERS + FarmConfigDatabaseName (Key, string) + DatabaseServer (Key, string) + InstallAccount (Write, String) + Passphrase (Required, string) + ServerRole (Write, string, Allowed values: Application, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, SpecialLoad, WebFrontEnd) + +DESCRIPTION + +This resource will be responsible for joining a server to an existing SharePoint farm. +To create a new farm use the [xSPCreateFarm](xSPCreateFarm) resource on a different server to begin with, and then pass the same database server and configuration database name parameters to the additional servers using this resource. +After the server has joined the farm, the process will wait for 5 minutes to allow farm specific configuration to take place on the server, before allowing further DSC configuration to take place. + +EXAMPLE + + xSPJoinFarm JoinSPFarm + { + DatabaseServer = $DatabaseServer + FarmConfigDatabaseName = "SP_Config" + Passphrase = $FarmPassPhrase + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt new file mode 100644 index 000000000..b9a08d091 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt @@ -0,0 +1,26 @@ +NAME + xSPManagedAccount + +PARAMETERS + AccountName (Key, string) + Account (Required, String) + InstallAccount (Write, String) + EmailNotification (Write, Uint32) + PreExpireDays (Write, Uint32) + Schedule (Write, string) + +DESCRIPTION + +This resource will ensure a managed account is provisioned in to the SharePoint farm. +The Account object specific the credential to store (including username and password) to set as the managed account. +The settings for EmailNotification, PreExpireDays and Schedule all relate to enabling automatic password change for the managed account, leaving these option out of the resource will ensure that no automatic password changing from SharePoint occurs. + +EXAMPLE + + xSPManagedAccount WebPoolManagedAccount + { + AccountName = $WebPoolManagedAccount.UserName + Account = $WebPoolManagedAccount + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt new file mode 100644 index 000000000..ddf468d41 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt @@ -0,0 +1,27 @@ +NAME + xSPManagedMetaDataServiceApp + +PARAMETERS + Name (Key, string) + InstallAccount (Write, String) + ApplicationPool (Required, string) + DatabaseServer (Write, string) + DatabaseName (Write, string) + +DESCRIPTION + +Creates a managed metadata service application. +The application pool property specifies which application pool it should use, and will reset the application back to this pool if it is changed after its initial provisioning. +The database server and database name properties are only used during provisioning, and will not be altered as part of the ongoing operation of the DSC resource. + +EXAMPLE + + xSPManagedMetaDataServiceApp ManagedMetadataServiceApp + { + Name = "Managed Metadata Service Application" + InstallAccount = $InstallAccount + ApplicationPool = "SharePoint Service Applications" + DatabaseServer = $DatabaseServer + DatabaseName = "SP_ManagedMetadata" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt new file mode 100644 index 000000000..28e0a61f8 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt @@ -0,0 +1,28 @@ +NAME + xSPManagedPath + +PARAMETERS + WebAppUrl (Key, string) + InstallAccount (Write, String) + RelativeUrl (Key, string) + Explicit (Required, boolean) + HostHeader (Required, boolean) + +DESCRIPTION + +This resource is responsible for creating managed paths associated with a specific web application. +The WebAppUrl parameter is used to specify the web application to create the path against, and the RelativeUrl parameter lets you set the URL. +Explicit when set to true will create an explicit inclusion path, if set to false the path is created as wildcard inclusion. +If you are using host named site collections set HostHeader to true and the path will be created as a host header path to be applied for host named site collections. + +EXAMPLE + + xSPManagedPath TeamsManagedPath + { + WebAppUrl = "http://sharepoint.contoso.com" + InstallAccount = $InstallAccount + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + } + diff --git a/Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt new file mode 100644 index 000000000..a04ccfe2c --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt @@ -0,0 +1,28 @@ +NAME + xSPOutgoingEmailSettings + +PARAMETERS + WebAppUrl (key, string) + SMTPServer (Required, string) + FromAddress (Required, string) + ReplyToAddress (Required, string) + CharacterSet (Required, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to set the outgoing email settings for either a single web application, or the whole farm. +To configure the resource for a specific web app, use the URL of the web application for the WebAppUrl property, to change the settings for the whole farm use the URL of the central admin website instead. +It is possible to set the outgoing server, from address, reply to address and the character set to be used for emails. + +EXAMPLE + + xSPOutgoingEmailSettings FarmWideEmailSettings + { + WebAppUrl = "http://sharepoint1:2013" + SMTPServer = "smtp.contoso.com" + FromAddress = "sharepoint@contoso.com" + ReplyToAddress = "noreply@contoso.com" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt new file mode 100644 index 000000000..500f86ecb --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt @@ -0,0 +1,27 @@ +NAME + xSPPasswordChangeSettings + +PARAMETERS + MailAddress (key, string) + DaysBeforeExpiry (Write, Uint32) + PasswordChangeWaitTimeSeconds (Write, Uint32) + NumberOfRetries (Write, Uint32) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to control settings that relate to the automatic changing of passwords for managed accounts (where they opt-in to be managed by SharePoint). +These settings can be manually controlled through central administration, or configured in this resource. +The settings relate to email notifications of when passwords are reset, as well as behavior when a reset occurs such as a time out and number of retries. + +EXAMPLE + + xSPPasswordChangeSettings ManagedAccountPasswordResetSettings + { + MailAddress = "sharepoint@contoso.com" + DaysBeforeExpiry = "14" + PasswordChangeWaitTimeSeconds = "60" + NumberOfRetries = "3" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt b/Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt new file mode 100644 index 000000000..8e259c1c1 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt @@ -0,0 +1,29 @@ +NAME + xSPQuotaTemplate + +PARAMETERS + Name (Key, string) + StorageMaxInMB (Write, uint32) + StorageWarningInMB (Write, uint32) + MaximumUsagePointsSolutions (Write, uint32) + WarningUsagePointsSolutions (Write, uint32) + Ensure (Required, string, Allowed values: Present, Absent) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to configure quota templates in the farm. +These settings will be used to make sure a certain quota template exists or not. When it exists, it will also make sure the settings are configured as specified. + +EXAMPLE + + xSPQuotaTemplate TeamsiteTemplate + { + Name = "Teamsite" + StorageMaxInMB = 1024 + StorageWarningInMB = 512 + MaximumUsagePointsSolutions = 1000 + WarningUsagePointsSolutions = 800 + Ensure = "Present" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt new file mode 100644 index 000000000..1f04f5bb9 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt @@ -0,0 +1,35 @@ +NAME + xSPSearchIndexPartition + +PARAMETERS + Index (Key, Uint32) + Servers (Required, String) + RootDirectory (Write, String) + ServiceAppName (Required, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for creating search indexes. +It works by creating the index topology components and updating the topology from the server that runs this resource. +For this reason this resource only needs to run from one server and not from each server which will host the index component. +The search service application and existing search topology must be deployed before creating additional indexes. +The first index will be created through the use of the xSPSearchRoles resource. +Additional search index partitions can be created through using this resource. + +Note that for the search topology to apply correctly, the path specified for RootDirectory needs to exist on the server that is executing this resource. +For example, if the below example was executed on "Server1" it would also need to ensure that it was able to create the index path at I:\. +If no disk labeled I: was available on server1, this would fail, even though it will not hold an actual index component. + +EXAMPLE + + xSPSearchIndexPartition MainSearchPartition + { + Servers = @("Server2", "Server3") + Index = 1 + RootDirectory = "I:\SearchIndexes\1" + ServiceAppName = "Search Service Application" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xSPSearchRoles]LocalSearchRoles" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt new file mode 100644 index 000000000..e8a2d3cd5 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt @@ -0,0 +1,27 @@ +NAME + xSPSearchServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, string) + DatabaseName (Write, string) + DatabaseServer (Write, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for provisioning the search service application. +The current version lets you specify the database name and server, as well as the application pool. +If the application pool is changed the DSC resource will set it back as per what is set in the resource. +The database name parameter is used as the prefix for all search databases (so you will end up with one for the admin database which matches the name, and then "_analyticsreportingstore", "_crawlstore" and "_linkstore" databases as well). + +EXAMPLE + + xSPSearchServiceApp SearchServiceApp + { + Name = "Search Service Application" + DatabaseName = "SP_Search" + ApplicationPool = "SharePoint Service Applications" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt new file mode 100644 index 000000000..74352442f --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt @@ -0,0 +1,42 @@ +NAME + xSPSearchTopology + +PARAMETERS + ServiceAppName (Key, String) + Admin (Required, String) + Crawler (Required, String) + ContentProcessing (Required, String) + AnalyticsProcessing (Required, String) + QueryProcessing (Required, String) + IndexPartition (Required, String) + FirstPartitionDirectory (Required, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for provisioning a search topology in to the current farm. +It allows the configuration to dictate the search topology roles that the current server should be running. +Any combination of roles can be specified and the topology will be upaded to reflect the current servers new roles. +If this is the first server to apply topology to a farm, then at least one search index must be provided. +To this end, the FirstPartitionIndex, FirstPartitionDirectory and FirstPartitionServers allow configuring where the first index partition will belong. +This will behave the same as the xSPSearchIndexPartition resource. + +Note that for the search topology to apply correctly, the path specified for FirstPartitionDirectory needs to exist on the server that is executing this resource. +For example, if the below example was executed on "Server1" it would also need to ensure that it was able to create the index path at I:\. +If no disk labeled I: was available on server1, this would fail, even though it will not hold an actual index component. + +EXAMPLE + + xSPSearchRoles LocalSearchRoles + { + ServiceAppName = "Search Service Application" + Admin = @("Server1","Server2") + Crawler = @("Server1","Server2") + ContentProcessing = @("Server1","Server2") + AnalyticsProcessing = @("Server1","Server2") + QueryProcessing = @("Server3","Server4") + PsDscRunAsCredential = $SPSetupAccount + FirstPartitionDirectory = "I:\SearchIndexes\0" + IndexPartition = @("Server3","Server4") + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt new file mode 100644 index 000000000..0c4281926 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt @@ -0,0 +1,34 @@ +NAME + xSPSecureStoreServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, string) + AuditingEnabled (Required, boolean) + AuditlogMaxSize (Write, uint32) + DatabaseCredentials (Write, String) + DatabaseName (Write, string) + DatabaseServer (Write, string) + DatabaseAuthenticationType (Write, string, Allowed values: Windows, SQL) + FailoverDatabaseServer (Write, string) + PartitionMode (Write, boolean) + Sharing (Write, boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for provisioning and configuring the secure store service application. +The parameters passed in (except those related to database specifics) are validated and set when the resource is run, the database values are only used in provisioning of the service application. + +EXAMPLE + + xSPSecureStoreServiceApp SecureStoreServiceApp + { + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Service Applications" + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = "SP_SecureStore" + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt b/Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt new file mode 100644 index 000000000..0290e3773 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt @@ -0,0 +1,22 @@ +NAME + xSPServiceAppPool + +PARAMETERS + Name (Key, string) + ServiceAccount (Required, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used for provisioning an application pool that can be used for service applications. +The account used for the service account must already be registered as a managed account (which can be provisioned through [xSPManagedAccount](xSPManagedAccount)). + +EXAMPLE + + xSPServiceAppPool MainServiceAppPool + { + Name = "SharePoint Service Applications" + ServiceAccount = "Demo\ServiceAccount" + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt b/Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt new file mode 100644 index 000000000..54e28c49c --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt @@ -0,0 +1,29 @@ +NAME + xSPServiceInstance + +PARAMETERS + Name (Key, string) + InstallAccount (Write, String) + Ensure (Required, string, Allowed values: Present, Absent) + +DESCRIPTION + +This resource is used to specify if a specific service should be running (Ensure = "Present") or not running (Ensure = "Absent") on the current server. +The name is the display name of the service as shown in the Central Admin website. + +**Examples** + + xSPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + InstallAccount = $InstallAccount + } + + xSPServiceInstance StopBCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Absent" + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt b/Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt new file mode 100644 index 000000000..ac4c84fe8 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt @@ -0,0 +1,26 @@ +NAME + xSPSessionStateService + +PARAMETERS + DatabaseName (Key, string) + DatabaseServer (Key, string) + Enabled (Required, boolean) + SessionTimeout (Write, uint32) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will provision a state service app to the local farm. +Specify the name of the database server and database name to provision the app with, and optionally include the session timeout value. +If session timeout is not provided it will default to 60. + +EXAMPLE + + xSPSessionStateService StateServiceApp + { + DatabaseName = "SP_StateService" + DatabaseServer = "SQL.test.domain" + Enabled = $true + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPShellAdmins.help.txt b/Modules/xSharePoint/en-us/about_xSPShellAdmins.help.txt new file mode 100644 index 000000000..99744b488 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPShellAdmins.help.txt @@ -0,0 +1,56 @@ +NAME + xSPShellAdmins + +PARAMETERS + Name (Key, String) + Members (Write, String) + MembersToInclude (Write, String) + MembersToExclude (Write, String) + ContentDatabases (Write, String) + AllContentDatabases (Write, Boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to manage the users with Shell Admin permissions. +There are a number of approaches to how this can be implemented. +The "Members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. +The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource. +The "ContentDatabases" and "AllContentDatabases" properties will allow you to control the permissions on Content Databases. + +Requirements: +At least one of the Members, MemberToInclude or MembersToExclude properties needs to be specified. +Do not combine the Members property with the MemberToInclude and MembersToExclude properties. +Do not combine the ContentDatabase property with the AllContentDatabases property. + +Notes: +1.) If a content database is created using the Central Admin, the farm account is the owner of that content database in SQL Server. +When this is true, you cannot add it to the Shell Admins (common for AllContentDatabases parameter) and the resource will throw an error. +Workaround: Change database owner in SQL Server. + +EXAMPLE + + xSPShellAdmins ShellAdmins + { + Name = "Shell Admins" + Members = "CONTOSO\user1", "CONTOSO\user2" + AllContentDatabases = $true + } + + xSPShellAdmins ShellAdmins + { + Name = "Shell Admins" + Members = "CONTOSO\user1", "CONTOSO\user2" + ContentDatabases = @( + @(MSFT_xSPContentDatabasePermissions { + Name = "SharePoint_Content_1" + Members = "CONTOSO\user2", "CONTOSO\user3" + }) + @(MSFT_xSPContentDatabasePermissions { + Name = "SharePoint_Content_2" + Members = "CONTOSO\user3", "CONTOSO\user4" + }) + ) + } + + diff --git a/Modules/xSharePoint/en-us/about_xSPSite.help.txt b/Modules/xSharePoint/en-us/about_xSPSite.help.txt new file mode 100644 index 000000000..86229eb8a --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSite.help.txt @@ -0,0 +1,38 @@ +NAME + xSPSite + +PARAMETERS + Url (Key, string) + OwnerAlias (Required, string) + CompatibilityLevel (Write, uint32) + ContentDatabase (Write, string) + Description (Write, string) + HostHeaderWebApplication (Write, string) + Language (Write, uint32) + Name (Write, string) + OwnerEmail (Write, string) + QuotaTemplate (Write, string) + SecondaryEmail (Write, string) + SecondaryOwnerAlias (Write, string) + Template (Write, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will provision a site collection to the current farm, based on the settings that are passed through. +These settings map to the New-SPSite cmdlet and accept the same values and types. + +The current version of xSharePoint is only able to check for the existence of a site collection, the additional parameters are not checked for yet, but will be in a later release + +EXAMPLE + + xSPSite TeamSite + { + Url = "http://sharepoint.contoso.com" + OwnerAlias = "CONTOSO\ExampleUser" + HostHeaderWebApplication = "http://spsites.contoso.com" + Name = "Team Sites" + Template = "STS#0" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt new file mode 100644 index 000000000..8549522bb --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt @@ -0,0 +1,24 @@ +NAME + xSPStateServiceApp + +PARAMETERS + Name (Key, string) + DatabaseCredentials (Write, String) + DatabaseName (Required, string) + DatabaseServer (Write, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource provisions an instance of the state service in to the local farm. +The database specific parameters are only used during initial provisioning of the app, and will not change database settings beyond the initial deployment. + +EXAMPLE + + xSPStateServiceApp StateServiceApp + { + Name = "State Service Application" + DatabaseName = "SP_State" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt new file mode 100644 index 000000000..de49e3053 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt @@ -0,0 +1,27 @@ +NAME + xSPSubscriptionSettingsServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, String) + DatabaseName (Write, string) + DatabaseServer (Write, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to provision and manage an instance of the App Management Services Service Application. +It will identify an instance of the subscription settings service app through the application display name. +Currently the resource will provision the app if it does not yet exist, and will change the service account associated to the app if it does not match the configuration. +Database names or server name will not be changed if the configuration does not match, these parameters are only used for the initial provisioning of the service application. + +EXAMPLE + + xSPSubscriptionSettingsServiceApp SubscriptionSettingsServiceApp + { + Name = "Subscription Settings Service Application" + AppPool = "SharePoint web services" + DatabaseServer = "SQL01.contoso.com" + DatabaseName = "SP_ManagedMetadata" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt b/Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt new file mode 100644 index 000000000..4bc7d8751 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt @@ -0,0 +1,38 @@ +NAME + xSPTimerJobState + +PARAMETERS + Name (Key, String) + WebApplication (Write, String) + Enabled (Write, Boolean) + Schedule (Write, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to configure a timer job and make sure it is in a specific state. +The resource can be used to enable or disabled the job and configure the schedule of the job. + +The schedule parameter has to be written in the SPSchedule format (https://technet.microsoft.com/en-us/library/ff607916.aspx). +Examples are: + - Every 5 minutes between 0 and 59 + - Hourly between 0 and 59 + - Daily at 15:00:00 + - Weekly between Fri 22:00:00 and Sun 06:00:00 + - Monthly at 15 15:00:00 + - Yearly at Jan 1 15:00:00 + +NOTE: Make sure you use the internal timer job name, not the display name! +Use "Get-SPTimerJob -WebApplication "http://servername" | select Name, DisplayName" to find the internal name for each Timer Job. + +EXAMPLE + + xSPTimerJobState DisableTimerJob_DeadSiteDelete + { + Name = "job-dead-site-delete" + WebApplication = "http://sites.sharepoint.contoso.com" + Enabled = $true + Schedule ="weekly at sat 5:00" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt b/Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt new file mode 100644 index 000000000..b37395cc5 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt @@ -0,0 +1,32 @@ +NAME + xSPUsageApplication + +PARAMETERS + Name (Key, string) + InstallAccount (Write, String) + DatabaseName (Write, string) + DatabaseServer (Write, string) + DatabaseCredentials (Write, String) + FailoverDatabaseServer (Write, string) + UsageLogCutTime (Write, uint32) + UsageLogLocation (Write, string) + UsageLogMaxFileSizeKB (Write, uint32) + UsageLogMaxSpaceGB (Write, uint32) + +DESCRIPTION + +This resource provisions an instance of the usage and health monitoring service application. +The database settings are only used for initial provisioning, but the usage settings can be changed and will be enforced as the resource is executed. + +EXAMPLE + + xSPUsageApplication UsageApplication + { + Name = "Usage Service Application" + DatabaseName = "SP_Usage" + UsageLogCutTime = 5 + UsageLogLocation = "L:\UsageLogs" + UsageLogMaxFileSizeKB = 1024 + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPUserProfileProperty.help.txt b/Modules/xSharePoint/en-us/about_xSPUserProfileProperty.help.txt new file mode 100644 index 000000000..a6a3c7728 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPUserProfileProperty.help.txt @@ -0,0 +1,69 @@ +NAME + xSPUserProfileProperty + +PARAMETERS + Name (Key, string) + Ensure (write, string, Allowed values: Present, Absent) + UserProfileService (required, string) + DisplayName (write, string) + Type (write, string, Allowed values: BigInteger, Binary, Boolean, Date, DateNoYear, DateTime, Email, Float, Guid, HTML, Integer, Person, String, StringMultiValue, TimeZone, URL) + Description (write, string) + PolicySetting (write, string, Allowed values: Mandatory, Optin, Optout, Disabled) + PrivacySetting (write, string, Allowed values: Public, Contacts, Organization, Manager, Private) + MappingConnectionName (write, string) + MappingPropertyName (write, string) + MappingDirection (write, string) + Length (write, uint32) + DisplayOrder (write, uint32) + IsEventLog (write, boolean) + IsVisibleOnEditor (write, boolean) + IsVisibleOnViewer (write, boolean) + IsUserEditable (write, boolean) + IsAlias (write, boolean) + IsSearchable (write, boolean) + UserOverridePrivacy (write, boolean) + TermStore (write, string) + TermGroup (write, string) + TermSet (write, string) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will create a property in a user profile service application. +It creates, update or delete a property using the parameters that are passed in to it . + +The parameter DisplayOrder is absolute. ie.: If you want it to be placed as the 5th field of section Bla, which has propertyName value of 5000 then your DisplayOrder needs to be 5005 +If no DisplayOrder is added then SharePoint adds it as the last property of section X. + +Length is only relevant if Field type is "String". + +This Resource doesn't currently support removing existing user profile properties + +EXAMPLE +xSPUserProfileProperty WorkEmailProperty +{ + Name = "WorkEmail2" + UserProfileService = "User Profile Service Application" + DisplayName = "Work Email" + Type = "Email" + Description = "" #implementation isn't using it yet + PolicySetting = "Required" + PrivacySetting = "Everyone" + MappingConnectionName = "contoso.com" + MappingPropertyName = "mail" + MappingDirection = "Import" + Length = 10 + DisplayOrder =25 + IsEventLog =$false + IsVisibleOnEditor=$true + IsVisibleOnViewer = $true + IsUserEditable = $true + IsAlias = $false + IsSearchable = $false + TermStore = "" + TermGroup = "" + TermSet = "" + UserOverridePrivacy = $false +} + + diff --git a/Modules/xSharePoint/en-us/about_xSPUserProfileServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPUserProfileServiceApp.help.txt new file mode 100644 index 000000000..a8ed83351 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPUserProfileServiceApp.help.txt @@ -0,0 +1,40 @@ +NAME + xSPUserProfileServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, string) + FarmAccount (Required, String) + InstallAccount (Write, String) + MySiteHostLocation (Write, string) + ProfileDBName (Write, string) + ProfileDBServer (Write, string) + SocialDBName (Write, string) + SocialDBServer (Write, string) + SyncDBName (Write, string) + SyncDBServer (Write, string) + +DESCRIPTION + +This resource will provision an instance of the user profile service to the farm. +It creates the required databases using the parameters that are passed in to it (although these are only used during the initial provisioning). +The farm account is used during the provisioning of the service only (in the set method), and the install account is used in the get and test methods. +This is done to ensure that the databases are created with the correct schema owners and allow the user profile sync service to operate correctly. + +EXAMPLE + + xSPUserProfileServiceApp UserProfileServiceApp + { + Name = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + MySiteHostLocation = "http://my.sharepoint.contoso.local" + ProfileDBName = "SP_UserProfiles" + ProfileDBServer = "SQL.contoso.local\SQLINSTANCE" + SocialDBName = "SP_Social" + SocialDBServer = "SQL.contoso.local\SQLINSTANCE" + SyncDBName = "SP_ProfileSync" + SyncDBServer = "SQL.contoso.local\SQLINSTANCE" + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SetupAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPUserProfileSyncConnection.help.txt b/Modules/xSharePoint/en-us/about_xSPUserProfileSyncConnection.help.txt new file mode 100644 index 000000000..f62a3588b --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPUserProfileSyncConnection.help.txt @@ -0,0 +1,37 @@ +NAME + xSPUserProfileSyncConnection + +PARAMETERS + Name (Key, string) + Forest (Required, string) + UserProfileService (Required, string) + ConnectionCredentials (Required, string) + InstallAccount (Write, string) + IncludedOUs (Required, string) + ExcludedOUs (write, string) + Server (write, string) + UseSSL (Write, boolean) + Force (Write, boolean) + ConnectionType (Write, string, Allowed values: ActiveDirectory, BusinessDataCatalog) + +DESCRIPTION + +This resource will ensure a specifc user profile sync connection is in place and that it is configured accordingly to its definition + +This resource currently supports AD only. +EXAMPLE + + xSPUserProfileSyncConnection MainDomain + { + UserProfileService = "User Profile Service Application" + Forest = "contoso.com" + Name = "Contoso" + ConnectionCredentials = $connectionCredential + Server = "server.contoso.com" + UseSSL = $false + IncludedOUs = @("OU=SharePoint Users,DC=Contoso,DC=com") + ExcludedOUs = @("OU=Notes Usersa,DC=Contoso,DC=com") + Force = $false + ConnectionType = "ActiveDirectory" +} + diff --git a/Modules/xSharePoint/en-us/about_xSPUserProfileSyncService.help.txt b/Modules/xSharePoint/en-us/about_xSPUserProfileSyncService.help.txt new file mode 100644 index 000000000..bed8e8027 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPUserProfileSyncService.help.txt @@ -0,0 +1,26 @@ +NAME + xSPUserProfileSyncService + +PARAMETERS + UserProfileServiceAppName (Key, string) + Ensure (Required, string, Allowed values: Present, Absent) + FarmAccount (Required, String) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is responsible for ensuring that the user profile sync service has been provisioned (Ensure = "Present") or is not running (Ensure = "Absent") on the current server. +This resource uses the InstallAccount to validate the current state only, the set method which will do the provisioning uses the FarmAccount to do the actual work - this means that CredSSP authentication will need to be permitted to allow a connection to the local server. +To allow successful provisioning the farm account must be in the local administrators group, however it is not best practice to leave this account in the Administrators group. +Therefore this resource will add the FarmAccount credential to the local administrators group at the beginning of the set method, and then remove it once it has completed its work. + +EXAMPLE + + xSPUserProfileSyncService UserProfileSyncService + { + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + InstallAccount = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt new file mode 100644 index 000000000..f19b6fcf6 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt @@ -0,0 +1,18 @@ +NAME + xSPVisioServiceApp + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, string) + +DESCRIPTION + +This resource is responsible for creating Visio Graphics Service Application instances within the local SharePoint farm. +The resource will provision and configure the Visio Graphics Service Application. +EXAMPLE + xSPVisioServiceApp VisioServices + { + Name = "Visio Graphics Service Application" + ApplicationPool = "SharePoint Web Services" + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt new file mode 100644 index 000000000..f726bdcb3 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt @@ -0,0 +1,30 @@ +NAME + xSPWebAppBlockedFileTypes + +PARAMETERS + Url (Key, string) + Blocked (write, string) + EnsureBlocked (write, string) + EnsureAllowed (write, string) + InstallAccount (Write, string) + +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 + + xSPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes + { + Url = "Shttp://exmaple.contoso.local" + EnsureBlocked = @("exe", "dll", "msi") + EnsureAllowed = @("pdf", "docx", "xlsx") + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt new file mode 100644 index 000000000..9ac055e73 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt @@ -0,0 +1,39 @@ +NAME + xSPWebAppGeneralSettings + +PARAMETERS + Url (Key, string) + TimeZone (write, uint32) + Alerts (write, boolean) + AlertsLimit (write, uint32) + RSS (write, boolean) + BlogAPI (write, boolean) + BlogAPIAuthenticated (write, boolean) + BrowserFileHandling (write, String, Allowed values: Strict, Permissive) + SecurityValidation (write, boolean) + RecycleBinEnabled (write, boolean) + RecycleBinCleanupEnabled (write, boolean) + RecycleBinRetentionPeriod (write, uint32) + SecondStageRecycleBinQuota (write, uint32) + MaximumUploadSize (write, uint32) + CustomerExperienceProgram (write, boolean) + PresenceEnabled (write, boolean) + InstallAccount (Write, string) + +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 + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt new file mode 100644 index 000000000..890f39792 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt @@ -0,0 +1,24 @@ +NAME + xSPWebAppPolicy + +PARAMETERS + WebAppUrl (Key, string) + UserName (Key, string) + PermissionLevel (Required, string, Allowed values: Deny All, Deny Write, Full Read, Full Control) + ActAsSystemUser (Write, boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource is used to set the "super user" and "super reader" cache accounts for the specified web application object (as described in the TechNet article [Configure object cache user accounts in SharePoint Server 2013](https://technet.microsoft.com/en-us/library/ff758656.aspx)). + +EXAMPLE + + xSPCacheAccounts SetCacheAccounts + { + WebAppUrl = "http://sharepoint.contoso.com" + SuperUserAlias = "DEMO\svcSPSuperUser" + SuperReaderAlias = "DEMO\svcSPReader" + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt new file mode 100644 index 000000000..9119180e2 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt @@ -0,0 +1,28 @@ +NAME + xSPWebAppSiteUseAndDeletion + +PARAMETERS + Url (Key, string) + SendUnusedSiteCollectionNotifications (write, boolean) + UnusedSiteNotificationPeriod (write, uint32) + AutomaticallyDeleteUnusedSiteCollections (write, boolean) + UnusedSiteNotificationsBeforeDeletion (write, uint32) + InstallAccount (Write, string) + +DESCRIPTION + +This resource is responsible for controlling the Site Use and Deletion settings on a specific web application. +You can enable or disable the Site Use and Deletion feature, specify the amount of days after which the alerts are being send, if sites have to be deleted automatically and if so after how many days this has to be done. + +EXAMPLE + + xSPWebAppSiteUseAndDeletion ConfigureSiteUseAndDeletion + { + Url = "http://example.contoso.local" + SendUnusedSiteCollectionNotifications = $true + UnusedSiteNotificationPeriod = 90 + AutomaticallyDeleteUnusedSiteCollections = $true + UnusedSiteNotificationsBeforeDeletion = 24 + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt new file mode 100644 index 000000000..b56203227 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt @@ -0,0 +1,42 @@ +NAME + xSPWebAppThrottlingSettings + +PARAMETERS + Url (Key, string) + ListViewThreshold (write, uint32) + AllowObjectModelOverride (write, boolean) + AdminThreshold (write, uint32) + ListViewLookupThreshold (write, uint32) + HappyHourEnabled (write, boolean) + HappyHour (Write, string) + UniquePermissionThreshold (write, uint32) + RequestThrottling (write, boolean) + ChangeLogEnabled (write, boolean) + ChangeLogExpiryDays (write, uint32) + EventHandlersEnabled (write, boolean) + InstallAccount (Write, string) + +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 + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt new file mode 100644 index 000000000..1b8513563 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt @@ -0,0 +1,26 @@ +NAME + xSPWebAppWorkflowSettings + +PARAMETERS + Url (Key, string) + ExternalWorkflowParticipantsEnabled (write, boolean) + UserDefinedWorkflowsEnabled (write, boolean) + EmailToNoPermissionWorkflowParticipantsEnable (write, boolean) + InstallAccount (Write, string) + +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 + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt b/Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt new file mode 100644 index 000000000..0810cc7c8 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt @@ -0,0 +1,38 @@ +NAME + xSPWebApplication + +PARAMETERS + Name (Key, string) + ApplicationPool (Required, string) + ApplicationPoolAccount (Required, string) + Url (Required, string) + AllowAnonymous (Write, boolean) + AuthenticationMethod (Write, string, Allowed values: NTLM, Kerberos) + DatabaseName (Write, string) + DatabaseServer (Write, string) + HostHeader (Write, string) + Path (Write, string) + Port (Write, string) + InstallAccount (Write, string) + +DESCRIPTION + +This resource is responsible for creating a web application within the local SharePoint farm. +The resource will provision the web application with all of the current settings, and then ensure that it stays part of the correct application pool beyond that (additional checking and setting of properties will be added in future releases). + +EXAMPLE + + xSPWebApplication HostNameSiteCollectionWebApp + { + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Sites" + ApplicationPoolAccount = "CONTOSO\svcSPWebApp" + AllowAnonymous = $false + AuthenticationMethod = "NTLM" + DatabaseName = "SP_Content_01" + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + Url = "http://example.contoso.local" + Port = 80 + PsDscRunAsCredential = $InstallAccount + } + diff --git a/Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt b/Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt new file mode 100644 index 000000000..09814c517 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt @@ -0,0 +1,31 @@ +NAME + xSPWebApplicationAppDomain + +PARAMETERS + WebApplication (Key, string) + Zone (Key, string, Allowed values: Default, Internet, Intranet, Extranet, Custom) + AppDomain (Required, string) + Port (Write, string) + SSL (Write, boolean) + InstallAccount (Write, String) + +DESCRIPTION + +This resource will configure the App Domain at a specific zone for the given Web Application. +The configuration is done per zone on the specified web application, allowing for the setting of unique app domains for each extension of a web application. +The app prefix should still be set using the xSPAppDomain resource before this is applied to customise a specific zone. + + +EXAMPLE + + xSPWebApplicationAppDomain Domain + { + AppDomain = "contosointranetapps.com" + WebApplication ="http://portal.contoso.com"; + Zone = "Default"; + Port = 80; + SSL = $false; + PsDscRunAsCredential = $InstallAccount + } + + diff --git a/Modules/xSharePoint/en-us/about_xSPWordAutomationServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPWordAutomationServiceApp.help.txt new file mode 100644 index 000000000..7aa2c5d23 --- /dev/null +++ b/Modules/xSharePoint/en-us/about_xSPWordAutomationServiceApp.help.txt @@ -0,0 +1,69 @@ +NAME + xSPWordAutomationServiceApp + +PARAMETERS + Name (Key, string) + Ensure (Required, string, Allowed values: Present, Absent) + ApplicationPool (Write, string) + DatabaseName (Write, string) + DatabaseServer (Write, string) + SupportedFileFormats (Write, string, Allowed values: docx, doc, mht, rtf, xml) + DisableEmbeddedFonts (Write, boolean) + MaximumMemoryUsage (Write, uint32) + RecycleThreshold (Write, uint32) + DisableBinaryFileScan (Write, boolean) + ConversionProcesses (Write, uint32) + JobConversionFrequency (Write, uint32) + NumberOfConversionsPerProcess (Write, uint32) + TimeBeforeConversionIsMonitored (Write, uint32) + MaximumConversionAttempts (Write, uint32) + MaximumSyncConversionRequests (Write, uint32) + KeepAliveTimeout (Write, uint32) + MaximumConversionTime (Write, uint32) + InstallAccount (Write, string) + +DESCRIPTION + +The resource is able to provision, unprovision and configure the Word Automation Service Application. +All settings that you can configure on the Service Application administration page are configurable using this resource. + +Important: +When you specify Ensure=Present, the Application Pool and DatabaseName parameters are required. +When you specify Ensure=Absent, no other parameters are allowed (with the exception of Name, InstallAccount or PsDscRunAsCredential). + +EXAMPLE + +Make sure the service application exists and has a specific configuration + + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Present" + ApplicationPool = "SharePoint Web Services" + DatabaseName = "WordAutomation_DB" + DatabaseServer = "SQLServer" + SupportedFileFormats = "docx", "doc", "mht", "rtf", "xml" + DisableEmbeddedFonts = $false + MaximumMemoryUsage = 100 + RecycleThreshold = 100 + DisableBinaryFileScan = $false + ConversionProcesses = 8 + JobConversionFrequency = 15 (in minutes) + NumberOfConversionsPerProcess = 12 + TimeBeforeConversionIsMonitored = 5 (in minutes) + MaximumConversionAttempts = 2 + MaximumSyncConversionRequests = 25 + KeepAliveTimeout = 30 (in seconds) + MaximumConversionTime = 300 (in seconds) + PsDscRunAsCredential = $InstallAccount + } + +Make sure the service application does not exist and remove when it does + + xSPWordAutomationServiceApp Word Automation + { + Name = "Word Automation Service Application" + Ensure = "Absent" + PsDscRunAsCredential = $InstallAccount + } +