Skip to content

Commit

Permalink
Merge pull request #1275 from petepuu/master
Browse files Browse the repository at this point in the history
SPUserProfileServiceApp: Changed MySiteHostLocation parameter to not be mandatory
  • Loading branch information
ykuijs authored Dec 18, 2020
2 parents 9f8135b + 88c89f6 commit 333e119
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Get-TargetResource
[System.String]
$ApplicationPool,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$MySiteHostLocation,

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -271,7 +280,7 @@ function Set-TargetResource
[System.String]
$ApplicationPool,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$MySiteHostLocation,

Expand Down Expand Up @@ -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 `
Expand Down Expand Up @@ -651,7 +675,7 @@ function Test-TargetResource
[System.String]
$ApplicationPool,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$MySiteHostLocation,

Expand Down Expand Up @@ -747,6 +771,7 @@ function Test-TargetResource
-ValuesToCheck @("Name",
"EnableNetBIOS",
"NoILMUsed",
"MySiteHostLocation",
"SiteNamingConflictResolution",
"Ensure")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Invoke-TestSetup

$script:testEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:DSCModuleName `
-DSCResourceName $script:DSCResourceFullName `
-DscResourceName $script:DSCResourceFullName `
-ResourceType 'Mof' `
-TestType 'Unit'
}
Expand All @@ -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"
Expand All @@ -75,6 +75,17 @@ try
{
}
public string MySiteHostUrl
{
get
{
return "https://my.contoso.com";
}
set
{
}
}
public string PersonalSiteFormat
{
get
Expand Down

0 comments on commit 333e119

Please sign in to comment.