diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1
index af9b56d41..35c0ad796 100644
--- a/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.psm1
@@ -11,12 +11,12 @@ 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"
- 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."
}
@@ -66,10 +66,10 @@ 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) {
+ if (($PSBoundParameters.ContainsKey("ServerRole") -eq $true) -and (Get-xSharePointInstalledProductVersion).FileMajorPart -ne 16) {
throw [Exception] "Server role is only supported in SharePoint 2016."
}
@@ -128,10 +128,10 @@ 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) {
+ 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_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1
new file mode 100644
index 000000000..df59ec179
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.psm1
@@ -0,0 +1,151 @@
+function Get-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Collections.Hashtable])]
+ param
+ (
+ [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("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 Health Rule 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. Health Analyzer Rule settings will not be applied"
+ return $null
+ }
+
+ $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"]
+ RuleScope = $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
+}
+
+
+function Set-TargetResource
+{
+ [CmdletBinding()]
+ param
+ (
+ [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("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 Health Analyzer Rule configuration settings"
+
+ 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
+ }
+
+ $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
+ }
+
+ # 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("RuleScope")) { $item["HealthRuleScope"] = $params.RuleScope }
+ 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
+ }
+ }
+}
+
+
+function Test-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Boolean])]
+ param
+ (
+ [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("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 Health Analyzer rule 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..d2d87b8b8
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPHealthAnalyzerRuleState/MSFT_xSPHealthAnalyzerRuleState.schema.mof
@@ -0,0 +1,30 @@
+/*
+**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
+ }
+*/
+
+[ClassVersion("1.0.0.0"), FriendlyName("xSPHealthAnalyzerRuleState")]
+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{"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/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1
index cc99c4c1c..1d6f2dfd8 100644
--- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1
@@ -8,12 +8,12 @@ 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"
- 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."
}
@@ -51,12 +51,12 @@ 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"
- 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."
}
@@ -76,8 +76,12 @@ 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)"
+ $joinFarmArgs.Add("LocalServerRole", $params.ServerRole)
+ } else {
+ Write-Verbose -Message "Detected Version: SharePoint 2016 - no server role provided, configuring server without a specific role"
+ }
}
Default {
throw [Exception] "An unknown version of SharePoint (Major version $_) was detected. Only versions 15 (SharePoint 2013) or 16 (SharePoint 2016) are supported."
@@ -113,10 +117,10 @@ 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) {
+ 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_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_xSPShellAdmins/MSFT_xSPShellAdmins.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1
new file mode 100644
index 000000000..5d3f4d02c
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.psm1
@@ -0,0 +1,584 @@
+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)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases,
+ [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases,
+ [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
+ )
+
+ if ($Members -and (($MembersToInclude) -or ($MembersToExclude))) {
+ Write-Verbose -Verbose "Cannot use the Members parameter together with the MembersToInclude or MembersToExclude parameters"
+ return $null
+ }
+
+ 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) {
+ Write-Verbose -Verbose "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter"
+ return $null
+ }
+
+ Write-Verbose -Message "Getting all Shell Admins"
+
+ $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. Shell admin settings will not be applied"
+ return $null
+ }
+
+ $shellAdmins = Get-SPShellAdmin
+ $allContentDatabases = $true
+
+ $cdbPermissions = @()
+ foreach ($contentDatabase in (Get-SPContentDatabase)) {
+ $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
+ ContentDatabases = $cdbPermissions
+ AllContentDatabases = $params.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)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases,
+ [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 ($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) {
+ throw "Cannot use the ContentDatabases parameter together with the AllContentDatabases parameter"
+ }
+
+ $result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
+ $params = $args[0]
+
+ try {
+ $spFarm = Get-SPFarm
+ } catch {
+ throw "No local SharePoint farm was detected. Shell Admin settings will not be applied"
+ return
+ }
+
+ $shellAdmins = Get-SPShellAdmin
+
+ if ($params.Members) {
+ Write-Verbose -Verbose "Processing Members"
+ if ($shellAdmins) {
+ $differences = Compare-Object -ReferenceObject $shellAdmins.UserName -DifferenceObject $params.Members
+
+ 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
+ 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
+ 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) {
+ 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
+ }
+ }
+ }
+ }
+
+ if ($params.MembersToInclude) {
+ Write-Verbose -Verbose "Processing MembersToInclude"
+ if ($shellAdmins) {
+ foreach ($member in $params.MembersToInclude) {
+ if (-not $shellAdmins.UserName.Contains($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) {
+ 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
+ }
+ }
+ }
+ }
+
+ if ($params.MembersToExclude) {
+ Write-Verbose -Verbose "Processing MembersToExclude"
+ if ($shellAdmins) {
+ foreach ($member in $params.MembersToExclude) {
+ if ($shellAdmins.UserName.Contains($member)) {
+ 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
+ }
+ }
+ }
+ }
+ }
+
+ if ($params.ContentDatabases) {
+ Write-Verbose "Processing ContentDatabases parameter"
+ # 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 -Verbose "Processing Content Database: $($contentDatabase.Name)"
+
+ $currentCDB = Get-SPContentDatabase | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() }
+ if ($currentCDB -ne $null) {
+ $dbShellAdmins = Get-SPShellAdmin -database $currentCDB.Id
+
+ if ($contentDatabase.Members) {
+ 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
+ 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
+ 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) {
+ 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
+ }
+ }
+ }
+ }
+
+ if ($contentDatabase.MembersToInclude) {
+ Write-Verbose -Verbose "Processing MembersToInclude"
+ if ($dbShellAdmins) {
+ ForEach ($member in $contentDatabase.MembersToInclude) {
+ if (-not $dbShellAdmins.UserName.Contains($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) {
+ 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
+ }
+ }
+ }
+ }
+
+ if ($contentDatabase.MembersToExclude) {
+ Write-Verbose -Verbose "Processing MembersToExclude"
+ if ($dbShellAdmins) {
+ ForEach ($member in $contentDatabase.MembersToExclude) {
+ if ($dbShellAdmins.UserName.Contains($member)) {
+ 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
+ }
+ }
+ }
+ }
+ }
+ } else {
+ throw "Specified database does not exist: $($contentDatabase.Name)"
+ }
+ }
+ }
+
+ 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 Content Database: $($contentDatabase.Name)"
+ if ($dbShellAdmins) {
+ $differences = Compare-Object -ReferenceObject $dbShellAdmins.UserName -DifferenceObject $params.Members
+
+ 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
+ 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
+ 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) {
+ 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
+ }
+ }
+ }
+ }
+
+ if ($params.MembersToInclude) {
+ if ($dbShellAdmins) {
+ foreach ($member in $params.MembersToInclude) {
+ if (-not $dbShellAdmins.UserName.Contains($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) {
+ 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
+ }
+ }
+
+ }
+ }
+
+ if ($params.MembersToExclude) {
+ if ($dbShellAdmins) {
+ foreach ($member in $params.MembersToExclude) {
+ if ($dbShellAdmins.UserName.Contains($member)) {
+ 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
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+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)] [Microsoft.Management.Infrastructure.CimInstance[]] $ContentDatabases,
+ [parameter(Mandatory = $false)] [System.Boolean] $AllContentDatabases,
+ [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
+ )
+
+ Write-Verbose -Message "Testing Shell Admin settings"
+
+ # Start checking
+ $CurrentValues = Get-TargetResource @PSBoundParameters
+
+ if ($null -eq $CurrentValues) { return $false }
+
+ if ($Members) {
+ Write-Verbose "Processing Members parameter"
+ if (-not $CurrentValues.Members) { return $false }
+
+ $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"
+ if (-not $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"
+ return $false
+ } else {
+ Write-Verbose "$member is already a Shell Admin. Skipping"
+ }
+ }
+ }
+
+ if ($MembersToExclude) {
+ Write-Verbose "Processing MembersToExclude parameter"
+ 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"
+ }
+ }
+ }
+ }
+
+ 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 (-not $contentDatabase.Members) { return $false }
+
+ $differences = Compare-Object -ReferenceObject $contentDatabase.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) {
+ if (-not $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"
+ return $false
+ } else {
+ Write-Verbose "$member is already a Shell Admin. Skipping"
+ }
+ }
+ }
+
+ if ($MembersToExclude) {
+ 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"
+ }
+ }
+ }
+ }
+ }
+ }
+
+ 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
+ Write-Verbose "Processing Content Database: $($contentDatabase.Name)"
+
+ $currentCDB = $CurrentValues.ContentDatabases | Where-Object { $_.Name.ToLower() -eq $contentDatabase.Name.ToLower() }
+ if ($currentCDB -ne $null) {
+ if ($contentDatabase.Members) {
+ Write-Verbose "Processing Members parameter"
+ if (-not $currentCDB.Members) { return $false }
+
+ $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) {
+ Write-Verbose "Processing MembersToInclude parameter"
+ if (-not $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"
+ return $false
+ } else {
+ Write-Verbose "$member is already a Shell Admin. Skipping"
+ }
+ }
+ }
+
+ if ($contentDatabase.MembersToExclude) {
+ 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"
+ }
+ }
+ }
+ }
+ } else {
+ throw "Specified database does not exist: $($contentDatabase.Name)"
+ }
+ }
+ }
+
+ return $true
+}
+
+
+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..5964bf97d
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPShellAdmins/MSFT_xSPShellAdmins.schema.mof
@@ -0,0 +1,65 @@
+[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**
+
+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"
+ })
+ )
+ }
+
+*/
+[ClassVersion("1.0.0.0"), FriendlyName("xSPShellAdmins")]
+class MSFT_xSPShellAdmins : OMI_BaseResource
+{
+ [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;
+};
+
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_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1
new file mode 100644
index 000000000..2f77a9432
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.psm1
@@ -0,0 +1,386 @@
+function Get-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Collections.Hashtable])]
+ param
+ (
+ [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)] [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
+ )
+
+ 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.UserProfileService -ErrorAction SilentlyContinue
+ if ($null -eq $upsa) {
+ return $null
+ }
+ $caURL = (Get-SpWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true }).Url
+ $context = Get-SPServiceContext -Site $caURL
+ $userProfileConfigManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
+
+ $userProfileSubTypeManager = Get-xSharePointUserProfileSubTypeManager $context
+ $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype("UserProfile")
+
+ $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 = $syncConnection.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.UserProfileService
+ DisplayName = $userProfileProperty.DisplayName
+ Type = $userProfileProperty.CoreProperty.Type.GetTypeCode()
+ Description = $userProfileProperty.Description
+ PolicySetting = $userProfileProperty.PrivacyPolicy
+ PrivacySetting = $userProfileProperty.DefaultPrivacy
+ MappingConnectionName = $mapping.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
+}
+
+function Set-TargetResource
+{
+ [CmdletBinding()]
+ param
+ (
+ [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)] [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
+ )
+
+ #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]
+ #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.ToLower()) -eq $false) ){
+ throw "Only String and String Maultivalue can use Termsets"
+ }
+ #endregion
+ #region setting up objects
+ $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue
+
+ If ($null -eq $ups)
+ {
+ return $null
+ }
+
+ $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 admin permissions on the user profile service application"
+ }
+ $coreProperties = $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties()
+
+ $userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager
+ $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
+
+
+ $userProfileSubTypeManager = Get-xSharePointUserProfileSubTypeManager $context
+ $userProfileSubType = $userProfileSubTypeManager.GetProfileSubtype("UserProfile")
+
+ $userProfileSubTypeProperties = $userProfileSubType.Properties
+
+
+ #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
+ 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
+
+ #Ensure-Property $params
+ if( $params.ContainsKey("Ensure") -and $params.Ensure -eq "Absent"){
+ 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
+
+ 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)
+ $userProfileTypeProperties.Add($upTypeProperty)
+ $upSubProperty = $userProfileSubTypeProperties.Create($UPTypeProperty)
+ $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"
+ Set-xSharePointObjectPropertyIfValueExists -ObjectToSet $coreProperty -PropertyToSet "Description" -ParamsValue $params -ParamKey "Description"
+
+ 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 $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"
+ if($termSet -ne $null){
+ $coreProperty.TermSet = $termSet
+ }
+ #endregion
+ $userProfileProperty.CoreProperty.Commit()
+ $userProfileTypeProperty.Commit()
+ $userProfileProperty.Commit()
+
+
+ #/Ensure-Property
+
+ #region display order
+ # Set-DisplayOrder
+ 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
+ #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)
+ 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{
+ 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
+}
+
+function Test-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Boolean])]
+ param
+ (
+ [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)] [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
+
+ )
+
+ $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","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
new file mode 100644
index 000000000..bfc1c65a1
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileProperty/MSFT_xSPUserProfileProperty.schema.mof
@@ -0,0 +1,75 @@
+
+/*
+**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
+}
+
+*/
+
+
+[ClassVersion("1.0.0.0"), FriendlyName("xSPUserProfileProperty")]
+class MSFT_xSPUserProfileProperty : OMI_BaseResource
+{
+ [Key] string Name ;
+ [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] 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 TermGroup;
+ [write] string TermSet;
+ [Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount;
+};
+
+
+
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..5241db9cd
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPUserProfileSyncConnection/MSFT_xSPUserProfileSyncConnection.psm1
@@ -0,0 +1,234 @@
+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.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
+ )
+
+ 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
+ {
+
+ $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}
+ 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
+ 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)] [ValidateSet("ActiveDirectory","BusinessDataCatalog")] [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"
+ }
+ $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
+
+ 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.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
+ )
+
+ $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/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..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] $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] $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] $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;
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..501488535
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.psm1
@@ -0,0 +1,277 @@
+function Get-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Collections.Hashtable])]
+ param
+ (
+ [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,3600)] [System.UInt32] $MaximumConversionTime,
+ [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
+ )
+
+ Write-Verbose -Message "Getting Word Automation service app '$Name'"
+
+ 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"
+ }
+
+ 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]
+
+ $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.TotalMinutes
+ NumberOfConversionsPerProcess = $serviceApp.ConversionsPerInstance
+ TimeBeforeConversionIsMonitored = $serviceApp.ConversionTimeout.TotalMinutes
+ MaximumConversionAttempts = $serviceApp.MaximumConversionAttempts
+ MaximumSyncConversionRequests = $serviceApp.MaximumSyncConversionRequests
+ KeepAliveTimeout = $serviceApp.KeepAliveTimeout.TotalSeconds
+ MaximumConversionTime = $serviceApp.MaximumConversionTime.TotalSeconds
+ 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
+}
+
+function Set-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Collections.Hashtable])]
+ param
+ (
+ [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,3600)] [System.UInt32] $MaximumConversionTime,
+ [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
+ )
+
+ 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"
+ }
+
+ 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"
+ }
+
+ 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
+
+ $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 }
+
+ $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) {
+ $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool
+ if ($appPool) {
+ Set-SPWordConversionServiceApplication $serviceApp -ApplicationPool $appPool
+ } else {
+ throw "Specified application pool does not exist"
+ }
+ }
+ }
+
+ # 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) {
+ # 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 $wordAutomationTimerjob -Schedule $schedule
+ } else {
+ throw "Timerjob could not be found"
+ }
+ }
+ if ($params.NumberOfConversionsPerProcess) { $serviceApp.ConversionsPerInstance = $params.NumberOfConversionsPerProcess }
+ 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) {
+ $timespan = New-TimeSpan -Seconds $params.KeepAliveTimeout
+ $serviceApp.KeepAliveTimeout = $timespan
+ }
+ if ($params.MaximumConversionTime) {
+ $timespan = New-TimeSpan -Seconds $params.MaximumConversionTime
+ $serviceApp.MaximumConversionTime = $timespan
+ }
+
+ $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 $serviceApp -RemoveData -Confirm:$false
+ }
+ }
+ }
+ }
+}
+
+function Test-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Boolean])]
+ param
+ (
+ [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,3600)] [System.UInt32] $MaximumConversionTime,
+ [parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
+ )
+
+ 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"
+ }
+
+ 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
+
+ if ($null -eq $CurrentValues) { return $false }
+ return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters
+}
+
+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..6736e911b
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWordAutomationServiceApp/MSFT_xSPWordAutomationServiceApp.schema.mof
@@ -0,0 +1,70 @@
+/*
+**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
+ }
+*/
+
+[ClassVersion("1.0.0.0"), FriendlyName("xSPWordAutomationServiceApp")]
+class MSFT_xSPWordAutomationServiceApp : OMI_BaseResource
+{
+ [Key] string Name;
+ [Required, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
+ [Write] string ApplicationPool;
+ [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;
+};
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..7bbc8629a
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.psm1
@@ -0,0 +1,166 @@
+function Get-TargetResource
+{
+ [CmdletBinding()]
+ [OutputType([System.Collections.Hashtable])]
+ param
+ (
+ [parameter(Mandatory = $true)] [System.String] $Name,
+ [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,
+ [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'"
+
+ $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
+ 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
+ }
+ }
+ return $result
+}
+
+
+function Set-TargetResource
+{
+ [CmdletBinding()]
+ param
+ (
+ [parameter(Mandatory = $true)] [System.String] $Name,
+ [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,
+ [parameter(Mandatory = $false)] [System.UInt32] $MinimumTimeBetweenSearchQueries,
+ [parameter(Mandatory = $false)] [System.UInt32] $NumberOfSubscriptionSyncsPerEwsSyncRun,
+ [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)
+
+ $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
+{
+ [CmdletBinding()]
+ [OutputType([System.Boolean])]
+ param
+ (
+ [parameter(Mandatory = $true)] [System.String] $Name,
+ [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,
+ [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
+ }
+ }
+
+ return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool",
+ "MinimumTimeBetweenEwsSyncSubscriptionSearches",
+ "MinimumTimeBetweenProviderRefreshes",
+ "MinimumTimeBetweenSearchQueries",
+ "Name",
+ "NumberOfSubscriptionSyncsPerEwsSyncRun",
+ "NumberOfUsersEwsSyncWillProcessAtOnce",
+ "NumberOfUsersPerEwsSyncBatch"
+ )
+}
+
+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..4ea910359
--- /dev/null
+++ b/Modules/xSharePoint/DSCResources/MSFT_xSPWorkManagementServiceApp/MSFT_xSPWorkManagementServiceApp.schema.mof
@@ -0,0 +1,37 @@
+/*
+**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.
+
+
+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/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
diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1
index 66d422341..70f087de7 100644
--- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1
+++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1
@@ -27,11 +27,34 @@ 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
}
+
+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
@@ -111,16 +134,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() {
diff --git a/Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPAntivirusSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPAntivirusSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt b/Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPAppCatalog.help.txt
rename to Modules/xSharePoint/en-us/about_xSPAppCatalog.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt b/Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPAppDomain.help.txt
rename to Modules/xSharePoint/en-us/about_xSPAppDomain.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPAppManagementServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPAppManagementServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPBCSServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPBCSServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt b/Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPCacheAccounts.help.txt
rename to Modules/xSharePoint/en-us/about_xSPCacheAccounts.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt b/Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPCreateFarm.help.txt
rename to Modules/xSharePoint/en-us/about_xSPCreateFarm.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPDesignerSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPDesignerSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPDiagnosticLoggingSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPDiagnosticLoggingSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt b/Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPDistributedCacheService.help.txt
rename to Modules/xSharePoint/en-us/about_xSPDistributedCacheService.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt b/Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt
similarity index 89%
rename from Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt
rename to Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt
index aa03f07b8..e93f8e886 100644
--- a/Modules/xSharePoint/en-US/about_xSPFarmAdministrators.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPFarmAdministrators.help.txt
@@ -3,9 +3,9 @@
PARAMETERS
Name (Key, String)
- Members[] (Write, String)
- MembersToInclude[] (Write, String)
- MembersToExclude[] (Write, String)
+ Members (Write, String)
+ MembersToInclude (Write, String)
+ MembersToExclude (Write, String)
InstallAccount (Write, String)
DESCRIPTION
diff --git a/Modules/xSharePoint/en-US/about_xSPFeature.help.txt b/Modules/xSharePoint/en-us/about_xSPFeature.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPFeature.help.txt
rename to Modules/xSharePoint/en-us/about_xSPFeature.help.txt
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
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPInstall.help.txt
rename to Modules/xSharePoint/en-us/about_xSPInstall.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt b/Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPInstallPrereqs.help.txt
rename to Modules/xSharePoint/en-us/about_xSPInstallPrereqs.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt b/Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPJoinFarm.help.txt
rename to Modules/xSharePoint/en-us/about_xSPJoinFarm.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPManagedAccount.help.txt
rename to Modules/xSharePoint/en-us/about_xSPManagedAccount.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPManagedMetaDataServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPManagedMetaDataServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt b/Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPManagedPath.help.txt
rename to Modules/xSharePoint/en-us/about_xSPManagedPath.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPOutgoingEmailSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPOutgoingEmailSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPPasswordChangeSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPPasswordChangeSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt b/Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPQuotaTemplate.help.txt
rename to Modules/xSharePoint/en-us/about_xSPQuotaTemplate.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt
similarity index 97%
rename from Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt
index 9dc88f845..1f04f5bb9 100644
--- a/Modules/xSharePoint/en-US/about_xSPSearchIndexPartition.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPSearchIndexPartition.help.txt
@@ -3,7 +3,7 @@
PARAMETERS
Index (Key, Uint32)
- Servers[] (Required, String)
+ Servers (Required, String)
RootDirectory (Write, String)
ServiceAppName (Required, String)
InstallAccount (Write, String)
diff --git a/Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPSearchServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSearchServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt b/Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt
similarity index 86%
rename from Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt
index 3dfdadcc4..74352442f 100644
--- a/Modules/xSharePoint/en-US/about_xSPSearchTopology.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPSearchTopology.help.txt
@@ -3,13 +3,13 @@
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)
+ 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
diff --git a/Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt
similarity index 92%
rename from Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt
index 6baa6372f..0c4281926 100644
--- a/Modules/xSharePoint/en-US/about_xSPSecureStoreServiceApp.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPSecureStoreServiceApp.help.txt
@@ -9,7 +9,7 @@ PARAMETERS
DatabaseCredentials (Write, String)
DatabaseName (Write, string)
DatabaseServer (Write, string)
- DatabaseAuthenticationType (Write, string, Allowed values: te, ValueMap {Windows, SQL)
+ DatabaseAuthenticationType (Write, string, Allowed values: Windows, SQL)
FailoverDatabaseServer (Write, string)
PartitionMode (Write, boolean)
Sharing (Write, boolean)
diff --git a/Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt b/Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPServiceAppPool.help.txt
rename to Modules/xSharePoint/en-us/about_xSPServiceAppPool.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt b/Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPServiceInstance.help.txt
rename to Modules/xSharePoint/en-us/about_xSPServiceInstance.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt b/Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPSessionStateService.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSessionStateService.help.txt
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
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPSite.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSite.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPStateServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPStateServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPSubscriptionSettingsServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPSubscriptionSettingsServiceApp.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt b/Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPTimerJobState.help.txt
rename to Modules/xSharePoint/en-us/about_xSPTimerJobState.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt b/Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPUsageApplication.help.txt
rename to Modules/xSharePoint/en-us/about_xSPUsageApplication.help.txt
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
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPUserProfileServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPUserProfileServiceApp.help.txt
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
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPUserProfileSyncService.help.txt
rename to Modules/xSharePoint/en-us/about_xSPUserProfileSyncService.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt b/Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt
similarity index 91%
rename from Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt
rename to Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt
index 94f927edf..f19b6fcf6 100644
--- a/Modules/xSharePoint/en-US/about_xSPVisioServiceApp.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPVisioServiceApp.help.txt
@@ -3,7 +3,7 @@
PARAMETERS
Name (Key, string)
- ApplicationPool (Write, string)
+ ApplicationPool (Required, string)
DESCRIPTION
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt
similarity index 92%
rename from Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt
index 67267f06d..f726bdcb3 100644
--- a/Modules/xSharePoint/en-US/about_xSPWebAppBlockedFileTypes.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPWebAppBlockedFileTypes.help.txt
@@ -3,9 +3,9 @@
PARAMETERS
Url (Key, string)
- Blocked[] (write, string)
- EnsureBlocked[] (write, string)
- EnsureAllowed[] (write, string)
+ Blocked (write, string)
+ EnsureBlocked (write, string)
+ EnsureAllowed (write, string)
InstallAccount (Write, string)
DESCRIPTION
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPWebAppGeneralSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppGeneralSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt
similarity index 87%
rename from Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt
index 2d468d42c..890f39792 100644
--- a/Modules/xSharePoint/en-US/about_xSPWebAppPolicy.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPWebAppPolicy.help.txt
@@ -4,7 +4,7 @@
PARAMETERS
WebAppUrl (Key, string)
UserName (Key, string)
- PermissionLevel (Write, string, Allowed values: Deny All, Deny Write, Full Read, Full Control)
+ PermissionLevel (Required, string, Allowed values: Deny All, Deny Write, Full Read, Full Control)
ActAsSystemUser (Write, boolean)
InstallAccount (Write, String)
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPWebAppSiteUseAndDeletion.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppSiteUseAndDeletion.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPWebAppThrottlingSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppThrottlingSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt b/Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPWebAppWorkflowSettings.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebAppWorkflowSettings.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt b/Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt
similarity index 100%
rename from Modules/xSharePoint/en-US/about_xSPWebApplication.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebApplication.help.txt
diff --git a/Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt b/Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt
similarity index 90%
rename from Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt
rename to Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt
index fbbcf2846..09814c517 100644
--- a/Modules/xSharePoint/en-US/about_xSPWebApplicationAppDomain.help.txt
+++ b/Modules/xSharePoint/en-us/about_xSPWebApplicationAppDomain.help.txt
@@ -3,7 +3,7 @@
PARAMETERS
WebApplication (Key, string)
- string (Key, , Allowed values: Internet, Intranet, Extranet, Custom)
+ Zone (Key, string, Allowed values: Default, Internet, Intranet, Extranet, Custom)
AppDomain (Required, string)
Port (Write, string)
SSL (Write, boolean)
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
+ }
+
diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1
index 669d2a1f9..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'
@@ -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/Modules/xSharePoint/xSharePoint.pssproj b/Modules/xSharePoint/xSharePoint.pssproj
index 60a700e88..74d749bea 100644
--- a/Modules/xSharePoint/xSharePoint.pssproj
+++ b/Modules/xSharePoint/xSharePoint.pssproj
@@ -51,6 +51,8 @@
+
+
@@ -92,9 +94,13 @@
+
+
+
+
@@ -104,6 +110,9 @@
+
+
+
@@ -125,6 +134,7 @@
+
@@ -178,6 +188,8 @@
+
+
@@ -190,11 +202,15 @@
+
+
+
+
@@ -202,6 +218,8 @@
+
+
diff --git a/README.md b/README.md
index 606b72f4c..3d065fa48 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# xSharePoint
+# xSharePoint
Build status: [![Build status](https://ci.appveyor.com/api/projects/status/aj6ce04iy5j4qcd4/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xsharepoint/branch/master)
@@ -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,7 +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
@@ -125,7 +131,7 @@ Additional detailed documentation is included on the wiki on GitHub.
### 0.4.0
-* Fixed issue with nested modules’ cmdlets not being found
+* Fixed issue with nested modules� cmdlets not being found
### 0.3.0
diff --git a/Tests/Tests.pssproj b/Tests/Tests.pssproj
index 8a52e8497..66639efd2 100644
--- a/Tests/Tests.pssproj
+++ b/Tests/Tests.pssproj
@@ -67,9 +67,13 @@
+
+
+
+
@@ -88,8 +92,10 @@
+
+
diff --git a/Tests/xSharePoint/xSharePoint.TestHelpers.psm1 b/Tests/xSharePoint/xSharePoint.TestHelpers.psm1
index 17b735acc..c31a32698 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
}
}
@@ -103,7 +109,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
@@ -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
@@ -121,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)" }
@@ -162,21 +172,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"
+ }
}
}
}
@@ -186,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" {
diff --git a/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPHealthAnalyzerRuleState.Tests.ps1
new file mode 100644
index 000000000..e80069f42
--- /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
+ RuleScope = "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.RuleScope | 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.RuleScope | 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
+ }
+
+ }
+ }
+}
diff --git a/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPJoinFarm.Tests.ps1
index 81e26a8bf..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 { $LocalServerRole -ne $null }
+ Assert-MockCalled Connect-SPConfigurationDatabase
}
Default {
throw [Exception] "A supported version of SharePoint was not used in testing"
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
+ }
+ }
+ }
+}
diff --git a/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPSubscriptionSettings.Tests.ps1
index f8b3edc53..ed0ac576c 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-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 }
@@ -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,19 +121,24 @@ 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"
}
Mock Get-SPServiceApplication { return $null }
- Mock New-SPSubscriptionSettingsServiceApplication { }
+ Mock New-SPSubscriptionSettingsServiceApplication {return @{} }
+ Mock New-SPSubscriptionSettingsServiceApplicationProxy { return @{}}
it "should not throw an exception in the set method" {
Set-TargetResource @testParams
Assert-MockCalled New-SPSubscriptionSettingsServiceApplication
+ Assert-MockCalled New-SPSubscriptionSettingsServiceApplicationProxy
}
}
}
}
+
+
+
diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1
new file mode 100644
index 000000000..bb92b1017
--- /dev/null
+++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileProperty.Tests.ps1
@@ -0,0 +1,751 @@
+
+[CmdletBinding()]
+param(
+ [string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve)
+)
+Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0
+
+$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 {
+ $testParamsNewProperty = @{
+ Name = "WorkEmailNew"
+ UserProfileService = "User Profile Service Application"
+ DisplayName = "WorkEmailNew"
+ Type = "String"
+ Description = ""
+ PolicySetting = "Mandatory"
+ PrivacySetting = "Public"
+ MappingConnectionName = "contoso"
+ MappingPropertyName = "department"
+ MappingDirection = "Import"
+ Length = 30
+ DisplayOrder = 5496
+ IsEventLog =$false
+ IsVisibleOnEditor=$true
+ IsVisibleOnViewer = $true
+ IsUserEditable = $true
+ IsAlias = $false
+ IsSearchable = $false
+ TermStore = "Managed Metadata service"
+ TermGroup = "People"
+ 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"
+ DisplayName = "WorkEmailUpdate"
+ Type = "String"
+ Description = ""
+ PolicySetting = "Optin"
+ PrivacySetting = "Private"
+ Ensure ="Present"
+ MappingConnectionName = "contoso"
+ MappingPropertyName = "mail"
+ MappingDirection = "Import"
+ Length = 25
+ DisplayOrder = 5401
+ IsEventLog =$true
+ IsVisibleOnEditor=$True
+ IsVisibleOnViewer = $true
+ IsUserEditable = $true
+ IsAlias = $true
+ IsSearchable = $true
+ TermStore = "Managed Metadata service"
+ TermGroup = "People"
+ TermSet = "Location"
+ UserOverridePrivacy = $false
+ }
+
+ try { [Microsoft.Office.Server.UserProfiles] }
+ catch {
+ 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")
+
+ $corePropertyUpdate = @{
+ DisplayName = "WorkEmailUpdate"
+ Name = "WorkEmailUpdate"
+ IsMultiValued=$false
+ Type = "String"
+ TermSet = @{Name= $testParamsUpdateProperty.TermSet
+ Group= @{Name =$testParamsUpdateProperty.TermGroup}
+ TermStore = @{Name =$testParamsUpdateProperty.TermStore} }
+ Length=25
+ IsSearchable =$true
+ } | Add-Member ScriptMethod Commit {
+ $Global:xSPUPSPropertyCommitCalled = $true
+ } -PassThru | Add-Member ScriptMethod Delete {
+ $Global:xSPUPSPropertyDeleteCalled = $true
+ } -PassThru
+ $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 = @{WorkEmailUpdate = $corePropertyUpdate}
+
+ $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
+ }| Add-Member ScriptMethod Commit {
+ $Global:xSPUPPropertyCommitCalled = $true
+ } -PassThru
+
+ $typeProperties = @{"WorkEmailUpdate" = $typePropertyUpdate} | Add-Member ScriptMethod Create {
+ $Global:xSPUPTypeCreateCalled = $true
+ } -PassThru| Add-Member ScriptMethod Add {
+ $Global:xSPUPTypeAddCalled = $true
+ } -PassThru -Force
+
+ #$typeProperties.Add($typeProperty)
+ $subTypePropertyUpdate = @{
+ Name= "WorkEmailUpdate"
+ DisplayName="WorkEmailUpdate"
+ Description = ""
+ 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 = @{} | 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 $result
+ } -PassThru| Add-Member ScriptMethod Add {
+ $Global:xSPUPSubTypeAddCalled = $true
+ } -PassThru -Force
+
+ $userProfileSubTypePropertiesUpdateProperty = @{"WorkEmailUpdate" = $subTypePropertyUpdate } | Add-Member ScriptMethod Create {
+ $Global:xSPUPSubTypeCreateCalled = $true
+ } -PassThru | Add-Member ScriptMethod Add {
+ $Global:xSPUPSubTypeAddCalled = $true
+ } -PassThru -Force | Add-Member ScriptMethod GetPropertyByName {
+ $Global:xSPUPGetPropertyByNameCalled = $true
+ return $subTypePropertyUpdate
+ } -PassThru
+ #$userProfileSubTypePropertiesValidProperty.Add($subTypeProperty);
+ mock Get-xSharePointUserProfileSubTypeManager -MockWith {
+ $result = @{}| Add-Member ScriptMethod GetProfileSubtype {
+ $Global:xSPUPGetProfileSubtypeCalled = $true
+ return @{
+ Properties = $userProfileSubTypePropertiesNoProperty
+ }
+ } -PassThru
+
+ return $result
+ }
+
+
+ Mock Get-SPWebApplication -MockWith {
+ return @(
+ @{
+ IsAdministrationWebApplication=$true
+ Url ="caURL"
+ })
+ }
+ #IncludeCentralAdministration
+ $TermSets =@{Department = @{Name="Department"
+ }
+ Location = @{Name="Location"
+ }
+ }
+
+ $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
+ }
+
+
+ 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 $propertyMappingItem}
+ } -PassThru -force | Add-Member ScriptMethod AddNewExportMapping {
+ $Global:UpsMappingAddNewExportCalled=$true;
+ return $true;
+ } -PassThru | Add-Member ScriptMethod AddNewMapping {
+ $Global:UpsMappingAddNewMappingCalled=$true;
+ return $true;
+ } -PassThru
+ $connection = @{
+ DisplayName = "Contoso"
+ Server = "contoso.com"
+ AccountDomain = "Contoso"
+ AccountUsername = "TestAccount"
+ Type= "ActiveDirectory"
+ PropertyMapping = $propertyMapping
+ }
+
+ $connection = $connection | Add-Member ScriptMethod Update {
+ $Global:xSPUPSSyncConnectionUpdateCalled = $true
+ } -PassThru | Add-Member ScriptMethod AddPropertyMapping {
+ $Global:xSPUPSSyncConnectionAddPropertyMappingCalled = $true
+ } -PassThru
+
+
+ $ConnnectionManager = @($connection) | 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 {
+ $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 = $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 = $farmAccount
+ ServiceApplicationProxyGroup = "Proxy Group"
+ ConnectionManager= @($connection) #New-Object System.Collections.ArrayList
+ }
+
+ Mock Get-SPServiceApplication { return $userProfileServiceValidConnection }
+
+
+ Context "When property doesn't exist" {
+
+ 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
+
+ }
+
+ }
+
+ 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: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 "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} | should throw "connection not found"
+
+ $Global:xSPUPGetProfileSubtypeCalled | Should be $true
+ $Global:xSPUPGetPropertyByNameCalled | Should be $true
+ $Global:xSPUPSMappingItemCalled | Should be $false
+
+ }
+
+
+
+
+ }
+
+ 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 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 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 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 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" {
+
+ $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
+ }
+
+ 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
+ }
+ }
+ }
+}
diff --git a/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1
new file mode 100644
index 000000000..f51a75498
--- /dev/null
+++ b/Tests/xSharePoint/xSharePoint.xSPUserProfileSyncConnection.Tests.ps1
@@ -0,0 +1,330 @@
+[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 };
+ public enum ProfileType { User};
+ }
+"@ -ErrorAction SilentlyContinue
+ }
+ 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"
+ Mock Get-SPWebApplication {
+ return @{
+ Url="http://ca"
+ IsAdministrationWebApplication=$true
+ }
+ }
+ $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 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
+ }
+ }
+ }
+}
+
diff --git a/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1
new file mode 100644
index 000000000..d6f214559
--- /dev/null
+++ b/Tests/xSharePoint/xSharePoint.xSPWordAutomationServiceApp.Tests.ps1
@@ -0,0 +1,356 @@
+[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 = "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")
+
+ 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 and Ensure is set to Present" {
+
+ Mock Get-SPServiceApplication { return $null }
+ 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
+ Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name }
+ }
+
+ It "returns false when the Test method is called" {
+ 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 @(@{
+ 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 }
+ 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
+ }
+
+ It "returns true when the Test method is called" {
+ Test-TargetResource @testParams | Should Be $true
+ }
+ }
+
+ Context "When a service application exists and incorrect application pool is configured" {
+ Mock Get-SPServiceApplication {
+ $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 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"
+ }
+ }
+
+ }
+}
diff --git a/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1 b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1
new file mode 100644
index 000000000..41c39aa48
--- /dev/null
+++ b/Tests/xSharePoint/xSharePoint.xSPWorkManagementServiceApp.Tests.ps1
@@ -0,0 +1,178 @@
+[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"
+ }
+ $testParamsComplete = @{
+ Name = "Test Work Management App"
+ ApplicationPool = "Test App Pool"
+ MinimumTimeBetweenEwsSyncSubscriptionSearches =10
+ MinimumTimeBetweenProviderRefreshes=10
+ MinimumTimeBetweenSearchQueries=10
+ NumberOfSubscriptionSyncsPerEwsSyncRun=10
+ NumberOfUsersEwsSyncWillProcessAtOnce=10
+ NumberOfUsersPerEwsSyncBatch=10
+ }
+
+ 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 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" {
+
+ 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
+ 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 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"
+ })
+ }
+
+
+ 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 }
+ }
+
+ }
+
+ Context "When a service application exists and is configured correctly" {
+ Mock Get-SPServiceApplication {
+ return @(@{
+ TypeName = "Work Management Service Application"
+ 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 @testParamsComplete | Should Not BeNullOrEmpty
+ Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsComplete.Name }
+ }
+
+ It "returns true when the Test method is called" {
+ Test-TargetResource @testParamsComplete | 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" }
+ 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 { }
+
+ It "returns false when the Test method is called" {
+ Test-TargetResource @testParamsComplete | Should Be $false
+ }
+
+ It "calls the update service app cmdlet from the set method" {
+ Set-TargetResource @testParamsComplete
+ Assert-MockCalled Set-SPWorkManagementServiceApplication
+ Assert-MockCalled Get-SPServiceApplication
+ }
+ }
+
+ }
+}
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 }