diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da394b06..8fa55d651 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + - SPTrustedIdentityTokenIssuer - Do not set property ProviderSignOutUri in SharePoint 2013 as it does not exist +- SPUserProfileServiceApp + - Changed MySiteHostLocation to not be mandatory + - Added validation to Set function for testing if SiteNamingConflictResolution parameter + is defined then also MySiteHostLocation parameters has to be because it is a mandatory + parameter in the parameter set of New-SPProfileServiceApplication when + SiteNamingConflictResolution is used. + - Added "MySiteHostLocation" to Test-SPDscParameterState function in Test-TargetResource ### Fixed diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 index 1fc40d4b9..0a0fc85cf 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 @@ -16,7 +16,7 @@ function Get-TargetResource [System.String] $ApplicationPool, - [Parameter(Mandatory = $true)] + [Parameter()] [System.String] $MySiteHostLocation, @@ -85,6 +85,15 @@ function Get-TargetResource Write-Verbose -Message "Getting user profile service application $Name" + # If SiteNamingConflictResolution parameters is defined then also MySiteHostLocation need to be defined. + # This is because MySiteHostLocation is a mandatory parameter in the ParameterSet of New-SPProfileServiceApplication when SiteNamingConflictResolution is defined + if (($PSBoundParameters.ContainsKey("SiteNamingConflictResolution") -eq $true -and $PSBoundParameters.ContainsKey("MySiteHostLocation") -eq $false)) + { + $message = "MySiteHostLocation missing. Please specify MySiteHostLocation when specifying SiteNamingConflictResolution" + + Write-Verbose -Message $message + } + $farmAccount = Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { @@ -271,7 +280,7 @@ function Set-TargetResource [System.String] $ApplicationPool, - [Parameter(Mandatory = $true)] + [Parameter()] [System.String] $MySiteHostLocation, @@ -340,8 +349,23 @@ function Set-TargetResource Write-Verbose -Message "Setting user profile service application $Name" + if ($Ensure -eq "Present") { + # If SiteNamingConflictResolution parameters is defined then also MySiteHostLocation need to be defined. + # This is because MySiteHostLocation is a mandatory parameter in the ParameterSet of New-SPProfileServiceApplication when SiteNamingConflictResolution is defined + if (($PSBoundParameters.ContainsKey("SiteNamingConflictResolution") -eq $true -and $PSBoundParameters.ContainsKey("MySiteHostLocation") -eq $false)) + { + $message = "MySiteHostLocation missing. Please specify MySiteHostLocation when specifying SiteNamingConflictResolution" + + Add-SPDscEvent -Message $message ` + -EntryType 'Error' ` + -EventID 100 ` + -Source $MyInvocation.MyCommand.Source + + throw $message + } + $PSBoundParameters.UpdateProxyGroup = $UpdateProxyGroup $farmAccount = Invoke-SPDscCommand -Credential $InstallAccount ` @@ -651,7 +675,7 @@ function Test-TargetResource [System.String] $ApplicationPool, - [Parameter(Mandatory = $true)] + [Parameter()] [System.String] $MySiteHostLocation, @@ -747,6 +771,7 @@ function Test-TargetResource -ValuesToCheck @("Name", "EnableNetBIOS", "NoILMUsed", + "MySiteHostLocation", "SiteNamingConflictResolution", "Ensure") } diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.schema.mof b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.schema.mof index 08950ae71..53249f9cf 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.schema.mof +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.schema.mof @@ -4,7 +4,7 @@ class MSFT_SPUserProfileServiceApp : OMI_BaseResource [Key, Description("The name of the user profile service")] string Name; [Write, Description("The proxy name, if not specified will be /Name of service app/ Proxy")] string ProxyName; [Required, Description("The name of the application pool to run the service app in")] string ApplicationPool; - [Required, Description("The URL of the my site host collection")] string MySiteHostLocation; + [Write, Description("The URL of the my site host collection")] string MySiteHostLocation; [Write, Description("The Managed Path of the my site sites")] string MySiteManagedPath; [Write, Description("The name of the profile database")] string ProfileDBName; [Write, Description("The name of the server to host the profile database")] string ProfileDBServer; diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 index 3f81db2d7..67c554265 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 @@ -33,7 +33,7 @@ function Invoke-TestSetup $script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceFullName ` + -DscResourceName $script:DSCResourceFullName ` -ResourceType 'Mof' ` -TestType 'Unit' } @@ -50,7 +50,7 @@ try InModuleScope -ModuleName $script:DSCResourceFullName -ScriptBlock { Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { BeforeAll { - Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + Invoke-Command -Scriptblock $Global:SPDscHelper.InitializeScript -NoNewScope # Initialize tests $getTypeFullName = "Microsoft.Office.Server.Administration.UserProfileApplication" @@ -75,6 +75,17 @@ try { } + public string MySiteHostUrl + { + get + { + return "https://my.contoso.com"; + } + set + { + } + } + public string PersonalSiteFormat { get