diff --git a/.vscode/RunPesterTests.ps1 b/.vscode/RunPesterTests.ps1 index ed9a18d40..99f45ffc1 100644 --- a/.vscode/RunPesterTests.ps1 +++ b/.vscode/RunPesterTests.ps1 @@ -5,24 +5,24 @@ $harnessPath = Join-Path -Path $PSScriptRoot ` Import-Module -Name $harnessPath -Force $DscTestsPath = Join-Path -Path $PSScriptRoot ` - -ChildPath "..\Modules\SharePointDsc\DscResource.Tests" ` - -Resolve -if ((Test-Path $DscTestsPath) -eq $false) + -ChildPath "..\Modules\SharePointDsc\DscResource.Tests" + +if ((Test-Path -Path $DscTestsPath) -eq $false) { Write-Warning -Message ("Unable to locate DscResource.Tests repo at '$DscTestsPath', " + ` "common DSC resource tests will not be executed") $result = Invoke-TestHarness -IgnoreCodeCoverage -} -else +} +else { $result = Invoke-TestHarness -DscTestsPath $DscTestsPath -IgnoreCodeCoverage } -if ($result.FailedCount -gt 0) +if ($result.FailedCount -gt 0) { Write-Output -InputObject "Failed test result summary:" $result.TestResult | Where-Object -FilterScript { - $_.Passed -eq $false + $_.Passed -eq $false } | ForEach-Object -Process { Write-Output -InputObject "-----------------------------------------------------------" $outputObject = @{ diff --git a/CHANGELOG.md b/CHANGELOG.md index c8913ff95..3935d43f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,71 @@ # Change log for SharePointDsc +## v3.2 + +* Changes to SharePointDsc unit testing + * Implemented Strict Mode version 1 for all code run during unit tests. + * Changed InstallAccount into PSDscRunAsCredential parameter in examples +* SPAuthenticationRealm + * New resource for setting farm authentication realm +* SPConfigWizard + * Updated PSConfig parameters according recommendations in blog post of + Stefan Gossner +* SPDistributedCacheService + * Fixed exception on Stop-SPServiceInstance with SharePoint 2019 +* SPFarm + * Improved logging + * Added ability to manage the Developer Dashboard settings +* SPFarmSolution + * Fixed issue where uninstalling a solution would not work as expected if it + contained web application resources. +* SPIncomingEmailSettings + * New resource for configuring incoming email settings +* SPInstallPrereqs + * Improved logging + * Corrected detection for Windows Server 2019 + * Corrected support for Windows Server 2019 for SharePoint 2016 +* SPProductUpgrade + * Fixed issue where upgrading SP2013 would not properly detect the installed + version + * Fixed issue where the localized SharePoint 2019 CU was detected as a + Service Pack for a Language Pack +* SPSearchAuthorativePage + * Fixed issue where modifying search query would not target the correct + search application +* SPSearchResultSource + * Updated resource to allow localized ProviderTypes +* SPServiceAppSecurity + * Updated resource to allow localized permission levels +* SPServiceInstance + * Added -All switch to resolve "Unable to locate service application" in SP2013 +* SPSite + * Improved logging +* SPUserProfileProperty + * Fix user profile property mappings does not work +* SPUserProfileServiceApp + * Added warning message when MySiteHostLocation is not specified. This is + currently not required, which results in an error. Will be corrected in + SPDsc v4.0 (is a breaking change). +* SPUserProfileSyncConnection + * Fixed issue where test resource never would return true for any configurations + on SharePoint 2016/2019 + * Fixed issue where updating existing connection never would work for any + configurations on SharePoint 2016/2019 + * Updated documentation to reflect that Fore will not impact configurations for + SharePoint 2016/2019. Updated the test method accordingly. +* SPUserProfileSyncService + * Fixed issue where failure to configure the sync service would not throw error +* SPWebAppPeoplePickerSettings + * Converted password for access account to secure string. Previsouly + the resource would fail setting the password and an exeption was thrown that + printed the password in clear text. +* SPWebAppPolicy + * Fixed issue where parameter MembersToExclude did not work as expected +* SPWorkflowService + * Added support for specifying scope name. + * Added support for detecting incorrect configuration for scope name and + WorkflowHostUri + ## v3.1 * Changes to SharePointDsc diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 new file mode 100644 index 000000000..efee10938 --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 @@ -0,0 +1,95 @@ +function Get-TargetResource() +{ + [CmdletBinding()] + [OutputType([System.Collections.HashTable])] + param ( + [Parameter(Mandatory = $true)] + [ValidateSet('Yes')] + [String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [String] + $AuthenticationRealm, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Getting farm authentication realm" + + $result = Invoke-SPDSCCommand -Credential $InstallAccount ` + -ScriptBlock { + $currentRealm = Get-SPAuthenticationRealm + + Write-Verbose -Message "Current farm authentication realm is '$currentRealm'" + + return @{ + IsSingleInstance = "Yes" + AuthenticationRealm = $currentRealm + } + } + + return $result +} + +function Set-TargetResource() +{ + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [ValidateSet('Yes')] + [String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [String] + $AuthenticationRealm, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Setting farm authentication realm to $AuthenticationRealm" + + Invoke-SPDSCCommand -Credential $InstallAccount ` + -Arguments $PSBoundParameters ` + -ScriptBlock { + + $params = $args[0] + Set-SPAuthenticationRealm -Realm $params.AuthenticationRealm + } +} + +function Test-TargetResource() +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [ValidateSet('Yes')] + [String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [String] + $AuthenticationRealm, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Testing farm authentication realm" + + $CurrentValues = Get-TargetResource @PSBoundParameters + + return Test-SPDscParameterState -CurrentValues $CurrentValues ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("AuthenticationRealm") +} + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.schema.mof new file mode 100644 index 000000000..e073cb187 --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.schema.mof @@ -0,0 +1,7 @@ +[ClassVersion("1.0.0.0"), FriendlyName("SPAuthenticationRealm")] +class MSFT_SPAuthenticationRealm : OMI_BaseResource +{ + [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; + [Required, Description("The authentication realm to be set")] String AuthenticationRealm; + [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/readme.md new file mode 100644 index 000000000..3be9c8021 --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/readme.md @@ -0,0 +1,14 @@ +# Description + +**Type:** Distributed +**Requires CredSSP:** No + +This resource is used to set the authentication realm for a farm. +By default the authentication realm for a new farm installation +is the same as the farm id. + +Note: + +SharePoint automatically converts the realm to lower case ASCII printable characters. +The specified authentication realm must therefore conform to this for the test +method to be able to detect a correct configuration. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 index 4fe2c9feb..7667dbfec 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 @@ -56,14 +56,14 @@ function Get-TargetResource { Write-Verbose -Message "Server isn't running the Web Application role" return @{ - WebAppUrl = $null - Zone = $null - EnableCache = $false - Location = $null - MaxSizeInGB = $null + WebAppUrl = $null + Zone = $null + EnableCache = $false + Location = $null + MaxSizeInGB = $null MaxAgeInSeconds = $null - FileTypes = $null - InstallAccount = $params.InstallAccount + FileTypes = $null + InstallAccount = $params.InstallAccount } } @@ -74,21 +74,21 @@ function Get-TargetResource { Write-Verbose -Message "Specified web application was not found." return @{ - WebAppUrl = $null - Zone = $null - EnableCache = $false - Location = $null - MaxSizeInGB = $null + WebAppUrl = $null + Zone = $null + EnableCache = $false + Location = $null + MaxSizeInGB = $null MaxAgeInSeconds = $null - FileTypes = $null - InstallAccount = $params.InstallAccount + FileTypes = $null + InstallAccount = $params.InstallAccount } } $zone = [Microsoft.SharePoint.Administration.SPUrlZone]::$($params.Zone) $sitePath = $wa.IisSettings[$zone].Path - $webconfiglocation = Join-Path $sitePath "web.config" + $webconfiglocation = Join-Path -Path $sitePath -ChildPath "web.config" [xml]$webConfig = Get-Content -Path $webConfigLocation @@ -128,14 +128,14 @@ function Get-TargetResource } $returnval = @{ - WebAppUrl = $params.WebAppUrl - Zone = $params.Zone - EnableCache = $cacheEnabled - Location = $webconfig.configuration.SharePoint.BlobCache.location - MaxSizeInGB = $maxsize + WebAppUrl = $params.WebAppUrl + Zone = $params.Zone + EnableCache = $cacheEnabled + Location = $webconfig.configuration.SharePoint.BlobCache.location + MaxSizeInGB = $maxsize MaxAgeInSeconds = $maxage - FileTypes = $webconfig.configuration.SharePoint.BlobCache.path - InstallAccount = $params.InstallAccount + FileTypes = $webconfig.configuration.SharePoint.BlobCache.path + InstallAccount = $params.InstallAccount } return $returnval @@ -260,7 +260,7 @@ function Set-TargetResource $zone = [Microsoft.SharePoint.Administration.SPUrlZone]::$($params.Zone) - $sitePath = $wa.IisSettings[$zone].Path + $sitePath = $wa.IisSettings[$zone].Path $timestamp = Get-Date -Format "yyyyMMdd_HHmmss" $webconfiglocation = Join-Path -Path $sitePath -ChildPath "web.config" $webconfigbackuplocation = Join-Path -Path $sitePath -ChildPath "web_config-$timestamp.backup" @@ -299,7 +299,7 @@ function Set-TargetResource ## Check Blob Cache folder if ($Location) { - if ( -not (Test-Path -Path $Location)) + if (-not (Test-Path -Path $Location)) { Write-Verbose "Create Blob Cache Folder $Location" try @@ -362,7 +362,7 @@ function Test-TargetResource if ($Location) { - if ( -not (Test-Path -Path $Location)) + if (-not (Test-Path -Path $Location)) { Write-Verbose "Blob Cache Folder $Location does not exist" return $false diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 index 03d6809b6..ccabecc6e 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 @@ -27,7 +27,9 @@ function Get-TargetResource Write-Verbose -Message "Getting cache accounts for $WebAppUrl" - $result = Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { + $result = Invoke-SPDSCCommand -Credential $InstallAccount ` + -Arguments $PSBoundParameters ` + -ScriptBlock { $params = $args[0] $wa = Get-SPWebApplication -Identity $params.WebAppUrl -ErrorAction SilentlyContinue @@ -35,17 +37,17 @@ function Get-TargetResource if ($null -eq $wa) { return @{ - WebAppUrl = $params.WebAppUrl - SuperUserAlias = $null + WebAppUrl = $params.WebAppUrl + SuperUserAlias = $null SuperReaderAlias = $null - SetWebAppPolicy = $false - InstallAccount = $params.InstallAccount + SetWebAppPolicy = $false + InstallAccount = $params.InstallAccount } } $returnVal = @{ InstallAccount = $params.InstallAccount - WebAppUrl = $params.WebAppUrl + WebAppUrl = $params.WebAppUrl } $policiesSet = $true @@ -198,7 +200,7 @@ function Set-TargetResource { $wa.Policies.Remove($claimsReader) } - $policy = $wa.Policies.Add($claimsReader, "Super Reader (Claims)") + $policy = $wa.Policies.Add($claimsReader, "Super Reader (Claims)") $policyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) $policy.PolicyRoleBindings.Add($policyRole) @@ -208,7 +210,7 @@ function Set-TargetResource { $wa.Policies.Remove($claimsSuper) } - $policy = $wa.Policies.Add($claimsSuper, "Super User (Claims)") + $policy = $wa.Policies.Add($claimsSuper, "Super User (Claims)") $policyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) $policy.PolicyRoleBindings.Add($policyRole) } @@ -219,7 +221,7 @@ function Set-TargetResource $wa.Policies.Remove($params.SuperReaderAlias) } - $readPolicy = $wa.Policies.Add($params.SuperReaderAlias, "Super Reader") + $readPolicy = $wa.Policies.Add($params.SuperReaderAlias, "Super Reader") $readPolicyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) $readPolicy.PolicyRoleBindings.Add($readPolicyRole) @@ -227,7 +229,7 @@ function Set-TargetResource { $wa.Policies.Remove($params.SuperUserAlias) } - $policy = $wa.Policies.Add($params.SuperUserAlias, "Super User") + $policy = $wa.Policies.Add($params.SuperUserAlias, "Super User") $policyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) $policy.PolicyRoleBindings.Add($policyRole) } @@ -275,15 +277,15 @@ function Test-TargetResource return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuperUserAlias", ` - "SuperReaderAlias", ` - "SetWebAppPolicy") + "SuperReaderAlias", ` + "SetWebAppPolicy") } else { return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuperUserAlias", ` - "SuperReaderAlias") + "SuperReaderAlias") } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 index b03bad602..1e47664e7 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 @@ -194,7 +194,7 @@ function Set-TargetResource -ScriptBlock { $psconfigExe = $args[0] $psconfig = Start-Process -FilePath $psconfigExe ` - -ArgumentList "-cmd upgrade -inplace b2b -wait -force -cmd installcheck -noinstallcheck" ` + -ArgumentList "-cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install" ` -Wait ` -PassThru diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 index 6883d6d6d..d47783111 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 @@ -246,9 +246,17 @@ function Set-TargetResource Add-SPDistributedCacheServiceInstance - Get-SPServiceInstance | Where-Object -FilterScript { - $_.GetType().Name -eq "SPDistributedCacheServiceInstance" - } | Stop-SPServiceInstance -Confirm:$false + try + { + Get-SPServiceInstance | Where-Object -FilterScript { + $_.GetType().Name -eq "SPDistributedCacheServiceInstance" + } | Stop-SPServiceInstance -Confirm:$false + } + catch + { + # In SharePoint 2019, Stop-SPServiceInstance throws an exception if service + # is not running on the server, try/catch handles this scenario + } $count = 0 $maxCount = 30 @@ -309,7 +317,14 @@ function Set-TargetResource $account = Get-SPManagedAccount -Identity $params.ServiceAccount $cacheService.ProcessIdentity.ManagedAccount = $account $cacheService.ProcessIdentity.Update() - $cacheService.ProcessIdentity.Deploy() + try + { + $cacheService.ProcessIdentity.Deploy() + } + catch + { + # In SharePoint 2019, ProcessIdentity.Deploy() may throw an exception + } } } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 index 9bc4c30a5..bc963caf0 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 @@ -26,10 +26,6 @@ function Get-TargetResource [System.Management.Automation.PSCredential] $FarmAccount, - [Parameter()] - [System.Management.Automation.PSCredential] - $InstallAccount, - [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Passphrase, @@ -62,7 +58,17 @@ function Get-TargetResource "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] - $ServerRole + $ServerRole, + + [Parameter()] + [ValidateSet("Off","On","OnDemand")] + [System.String] + $DeveloperDashboard, + + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount ) Write-Verbose -Message "Getting the settings of the current local SharePoint Farm (if any)" @@ -89,7 +95,20 @@ function Get-TargetResource Write-Verbose -Message "Detected installation of SharePoint 2013" } 16 { - if($installedVersion.ProductBuildPart.ToString().Length -eq 4) + if ($DeveloperDashboard -eq "OnDemand") + { + throw ("The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint " + ` + "2016 and 2019") + } + + if ($DeveloperDashboard -eq "On") + { + Write-Verbose -Message ("Please make sure you also provision the Usage and Health " + ` + "service application to make sure the Developer Dashboard " + ` + "works properly") + } + + if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) { Write-Verbose -Message "Detected installation of SharePoint 2016" } @@ -119,21 +138,21 @@ function Get-TargetResource throw [Exception] ("ServerRole values of 'ApplicationWithSearch' or " + ` "'WebFrontEndWithDistributedCache' require the SharePoint 2016 " + ` "Feature Pack 1 to be installed. See " + ` - "https://support.microsoft.com/en-au/kb/3127940") + "https://support.microsoft.com/en-us/kb/3127940") } # Determine if a connection to a farm already exists $majorVersion = $installedVersion.FileMajorPart - $regPath = "hklm:SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\$majorVersion.0\Secure\ConfigDB" - $dsnValue = Get-SPDSCRegistryKey -Key $regPath -Value "dsn" -ErrorAction SilentlyContinue + $regPath = "hklm:SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\$majorVersion.0\Secure\ConfigDB" + $dsnValue = Get-SPDSCRegistryKey -Key $regPath -Value "dsn" -ErrorAction SilentlyContinue if ($null -ne $dsnValue) { # This node has already been connected to a farm $result = Invoke-SPDSCCommand -Credential $InstallAccount ` - -Arguments $PSBoundParameters ` - -ScriptBlock { + -Arguments $PSBoundParameters ` + -ScriptBlock { $params = $args[0] try @@ -198,23 +217,27 @@ function Get-TargetResource $centralAdminAuth = "NTLM" } + $admService = Get-SPDSCContentService + $developerDashboardSettings = $admService.DeveloperDashboardSettings + $developerDashboardStatus = $developerDashboardSettings.DisplayLevel + $returnValue = @{ - IsSingleInstance = "Yes" - FarmConfigDatabaseName = $spFarm.Name - DatabaseServer = $configDb.NormalizedDataSource - FarmAccount = $farmAccount # Need to return this as a credential to match the type expected - InstallAccount = $null - Passphrase = $null - AdminContentDatabaseName = $centralAdminSite.ContentDatabases[0].Name - RunCentralAdmin = $centralAdminProvisioned + IsSingleInstance = "Yes" + FarmConfigDatabaseName = $spFarm.Name + DatabaseServer = $configDb.NormalizedDataSource + FarmAccount = $farmAccount # Need to return this as a credential to match the type expected + Passphrase = $null + AdminContentDatabaseName = $centralAdminSite.ContentDatabases[0].Name + RunCentralAdmin = $centralAdminProvisioned CentralAdministrationPort = (New-Object -TypeName System.Uri $centralAdminSite.Url).Port CentralAdministrationAuth = $centralAdminAuth + DeveloperDashboard = $developerDashboardStatus } $installedVersion = Get-SPDSCInstalledProductVersion - if($installedVersion.FileMajorPart -eq 16) + if ($installedVersion.FileMajorPart -eq 16) { $server = Get-SPServer -Identity $env:COMPUTERNAME -ErrorAction SilentlyContinue - if($null -ne $server -and $null -ne $server.Role) + if ($null -ne $server -and $null -ne $server.Role) { $returnValue.Add("ServerRole", $server.Role) } @@ -224,7 +247,7 @@ function Get-TargetResource $currentServer = "$($env:COMPUTERNAME).$domain" $server = Get-SPServer -Identity $currentServer -ErrorAction SilentlyContinue - if($null -ne $server -and $null -ne $server.Role) + if ($null -ne $server -and $null -ne $server.Role) { $returnValue.Add("ServerRole", $server.Role) } @@ -243,17 +266,16 @@ function Get-TargetResource "incomplete, however the 'Ensure' property should be " + ` "considered correct") return @{ - IsSingleInstance = "Yes" - FarmConfigDatabaseName = $null - DatabaseServer = $null - FarmAccount = $null - InstallAccount = $null - Passphrase = $null - AdminContentDatabaseName = $null - RunCentralAdmin = $null + IsSingleInstance = "Yes" + FarmConfigDatabaseName = $null + DatabaseServer = $null + FarmAccount = $null + Passphrase = $null + AdminContentDatabaseName = $null + RunCentralAdmin = $null CentralAdministrationPort = $null CentralAdministrationAuth = $null - Ensure = "Present" + Ensure = "Present" } } else @@ -266,17 +288,16 @@ function Get-TargetResource { # This node has never been connected to a farm, return the null return object return @{ - IsSingleInstance = "Yes" - FarmConfigDatabaseName = $null - DatabaseServer = $null - FarmAccount = $null - InstallAccount = $null - Passphrase = $null - AdminContentDatabaseName = $null - RunCentralAdmin = $null + IsSingleInstance = "Yes" + FarmConfigDatabaseName = $null + DatabaseServer = $null + FarmAccount = $null + Passphrase = $null + AdminContentDatabaseName = $null + RunCentralAdmin = $null CentralAdministrationPort = $null CentralAdministrationAuth = $null - Ensure = "Absent" + Ensure = "Absent" } } } @@ -310,10 +331,6 @@ function Set-TargetResource [System.Management.Automation.PSCredential] $FarmAccount, - [Parameter()] - [System.Management.Automation.PSCredential] - $InstallAccount, - [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Passphrase, @@ -346,7 +363,17 @@ function Set-TargetResource "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] - $ServerRole + $ServerRole, + + [Parameter()] + [ValidateSet("Off","On","OnDemand")] + [System.String] + $DeveloperDashboard, + + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount ) Write-Verbose -Message "Setting local SP Farm settings" @@ -372,6 +399,8 @@ function Set-TargetResource if ($CurrentValues.Ensure -eq "Present") { + Write-Verbose -Message "Server already part of farm, updating settings" + if ($CurrentValues.RunCentralAdmin -ne $RunCentralAdmin) { Invoke-SPDSCCommand -Credential $InstallAccount ` @@ -382,11 +411,12 @@ function Set-TargetResource # Provision central administration if ($params.RunCentralAdmin -eq $true) { + Write-Verbose -Message "RunCentralAdmin set to true, provisioning Central Admin" $serviceInstance = Get-SPServiceInstance -Server $env:COMPUTERNAME if ($null -eq $serviceInstance) { $domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain - $fqdn = "$($env:COMPUTERNAME).$domain" + $fqdn = "$($env:COMPUTERNAME).$domain" $serviceInstance = Get-SPServiceInstance -Server $fqdn ` } @@ -406,12 +436,12 @@ function Set-TargetResource } else { - # Unprovision central administration + Write-Verbose -Message "RunCentralAdmin set to false, unprovisioning Central Admin" $serviceInstance = Get-SPServiceInstance -Server $env:COMPUTERNAME if ($null -eq $serviceInstance) { $domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain - $fqdn = "$($env:COMPUTERNAME).$domain" + $fqdn = "$($env:COMPUTERNAME).$domain" $serviceInstance = Get-SPServiceInstance -Server $fqdn } @@ -438,17 +468,36 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] + Write-Verbose -Message "Updating Central Admin port" Set-SPCentralAdministration -Port $params.CentralAdministrationPort } } + + if ($CurrentValues.DeveloperDashboard -ne $DeveloperDashboard) + { + Invoke-SPDSCCommand -Credential $InstallAccount ` + -Arguments $PSBoundParameters ` + -ScriptBlock { + $params = $args[0] + + Write-Verbose -Message "Updating Developer Dashboard setting" + $admService = Get-SPDSCContentService + $developerDashboardSettings = $admService.DeveloperDashboardSettings + $developerDashboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::$params.DeveloperDashboard + $developerDashboardSettings.Update() + } + } + return } else { + Write-Verbose -Message "Server not part of farm, creating or joining farm" + $actionResult = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments @($PSBoundParameters, $PSScriptRoot) ` -ScriptBlock { - $params = $args[0] + $params = $args[0] $scriptRoot = $args[1] $modulePath = "..\..\Modules\SharePointDsc.Farm\SPFarm.psm1" @@ -477,18 +526,17 @@ function Set-TargetResource if ($dbStatus.ValidPermissions -eq $false) { throw "The current user does not have sufficient permissions to SQL Server" - return } $executeArgs = @{ - DatabaseServer = $params.DatabaseServer - DatabaseName = $params.FarmConfigDatabaseName - Passphrase = $params.Passphrase.Password + DatabaseServer = $params.DatabaseServer + DatabaseName = $params.FarmConfigDatabaseName + Passphrase = $params.Passphrase.Password SkipRegisterAsDistributedCacheHost = $true } $installedVersion = Get-SPDSCInstalledProductVersion - switch($installedVersion.FileMajorPart) + switch ($installedVersion.FileMajorPart) { 15 { Write-Verbose -Message "Detected Version: SharePoint 2013" @@ -496,7 +544,7 @@ function Set-TargetResource 16 { if ($params.ContainsKey("ServerRole") -eq $true) { - if($installedVersion.ProductBuildPart.ToString().Length -eq 4) + if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) { Write-Verbose -Message ("Detected Version: SharePoint 2016 - " + ` "configuring server as $($params.ServerRole)") @@ -510,7 +558,7 @@ function Set-TargetResource } else { - if($installedVersion.ProductBuildPart.ToString().Length -eq 4) + if ($installedVersion.ProductBuildPart.ToString().Length -eq 4) { Write-Verbose -Message ("Detected Version: SharePoint 2016 - no server " + ` "role provided, configuring server without a " + ` @@ -561,8 +609,7 @@ function Set-TargetResource $farmAction = "" if ($createFarm -eq $false) { - # The database exists, so attempt to join the farm to the server - + Write-Verbose -Message "The database exists, so attempt to join the server to the farm" # Remove the server role optional attribute as it is only used when creating # a new farm @@ -573,9 +620,9 @@ function Set-TargetResource Write-Verbose -Message ("The server will attempt to join the farm now once every " + ` "60 seconds for the next 15 minutes.") - $loopCount = 0 + $loopCount = 0 $connectedToFarm = $false - $lastException = $null + $lastException = $null while ($connectedToFarm -eq $false -and $loopCount -lt 15) { try @@ -601,14 +648,17 @@ function Set-TargetResource { Write-Verbose -Message ("Unable to join config database. Throwing exception.") throw $lastException - return } $farmAction = "JoinedFarm" } else { + Write-Verbose -Message "The database does not exist, so create a new farm" + + Write-Verbose -Message ("Creating Lock database to prevent two servers creating " + ` + "the same farm") Add-SPDscConfigDBLock -SQLServer $params.DatabaseServer ` - -Database $params.FarmConfigDatabaseName + -Database $params.FarmConfigDatabaseName try { @@ -617,26 +667,36 @@ function Set-TargetResource AdministrationContentDatabaseName = $params.AdminContentDatabaseName } + Write-Verbose -Message "Creating new Config database" New-SPConfigurationDatabase @executeArgs $farmAction = "CreatedFarm" } finally { + Write-Verbose -Message "Removing Lock database" Remove-SPDscConfigDBLock -SQLServer $params.DatabaseServer ` - -Database $params.FarmConfigDatabaseName + -Database $params.FarmConfigDatabaseName } } # Run common tasks for a new server + Write-Verbose -Message "Starting Install-SPHelpCollection" Install-SPHelpCollection -All | Out-Null + + Write-Verbose -Message "Starting Initialize-SPResourceSecurity" Initialize-SPResourceSecurity | Out-Null + + Write-Verbose -Message "Starting Install-SPService" Install-SPService | Out-Null + + Write-Verbose -Message "Starting Install-SPFeature" Install-SPFeature -AllExistingFeatures -Force | Out-Null # Provision central administration if ($params.RunCentralAdmin -eq $true) { + Write-Verbose -Message "RunCentralAdmin is True, provisioning Central Admin" $centralAdminSite = Get-SPWebApplication -IncludeCentralAdministration ` | Where-Object -FilterScript { $_.IsAdministrationWebApplication -eq $true @@ -680,8 +740,18 @@ function Set-TargetResource } } + Write-Verbose -Message "Starting Install-SPApplicationContent" Install-SPApplicationContent | Out-Null + if ($params.DeveloperDashboard -ne "Off") + { + Write-Verbose -Message "Updating Developer Dashboard setting" + $admService = Get-SPDSCContentService + $developerDashboardSettings = $admService.DeveloperDashboardSettings + $developerDashboardSettings.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::$params.DeveloperDashboard + $developerDashboardSettings.Update() + } + return $farmAction } @@ -729,10 +799,6 @@ function Test-TargetResource [System.Management.Automation.PSCredential] $FarmAccount, - [Parameter()] - [System.Management.Automation.PSCredential] - $InstallAccount, - [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Passphrase, @@ -765,7 +831,17 @@ function Test-TargetResource "SingleServerFarm", "WebFrontEnd", "WebFrontEndWithDistributedCache")] - $ServerRole + $ServerRole, + + [Parameter()] + [ValidateSet("Off","On","OnDemand")] + [System.String] + $DeveloperDashboard, + + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount ) Write-Verbose -Message "Testing local SP Farm settings" @@ -778,7 +854,8 @@ function Test-TargetResource -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "RunCentralAdmin", - "CentralAdministrationPort") + "CentralAdministrationPort", + "DeveloperDashboard") } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof index 576fac73a..8e013ce58 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.schema.mof @@ -2,15 +2,16 @@ class MSFT_SPFarm : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; - [Write, Description("Present to create/join the farm. Absent is currently not supported"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [Write, Description("Present to create/join the farm. Absent is currently not supported"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Required, Description("Name of the configuration database")] String FarmConfigDatabaseName; [Required, Description("Server that will host the configuration and admin content databases")] String DatabaseServer; [Required, Description("The account to use as the main farm account"), EmbeddedInstance("MSFT_Credential")] String FarmAccount; [Required, Description("The passphrase to use to allow servers to join this farm"), EmbeddedInstance("MSFT_Credential")] String Passphrase; [Required, Description("The name of the admin content database")] String AdminContentDatabaseName; [Required, Description("Should the central admin site run on this specific server?")] Boolean RunCentralAdmin; - [Write, Description("What port will Central Admin be provisioned to - default is 9999")] uint32 CentralAdministrationPort; + [Write, Description("What port will Central Admin be provisioned to - default is 9999")] Uint32 CentralAdministrationPort; [Write, Description("The authentication provider of the CentralAdministration web application"), ValueMap{"NTLM","Kerberos"}, Values{"NTLM","Kerberos"}] String CentralAdministrationAuth; - [Write, Description("SharePoint 2016 & 2019 only - the MinRole role to enroll this server as"), ValueMap{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}, Values{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}] string ServerRole; + [Write, Description("SharePoint 2016 & 2019 only - the MinRole role to enroll this server as"), ValueMap{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}, Values{"Application","ApplicationWithSearch","Custom","DistributedCache","Search","SingleServer","SingleServerFarm","WebFrontEnd","WebFrontEndWithDistributedCache"}] String ServerRole; + [Write, Description("Specifies the state of the Developer Dashboard ('OnDemand' is SP2013 only)"), ValueMap{"Off","On","OnDemand"}, Values{"Off","On","OnDemand"}] String DeveloperDashboard; [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md index 608d14c85..62148d5cb 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarm/Readme.md @@ -33,3 +33,11 @@ designate it as a cache server. CentralAdministrationAuth can be specified as "NTLM" or "KERBEROS". If not specified, it defaults to NTLM. If using Kerberos, make sure to have appropriate SPNs setup for Farm account and Central Administration URI. + +DeveloperDashboard can be specified as "On", "Off" and (only when using +SharePoint 2013) to "OnDemand". + +NOTE: +When using SharePoint 2016 and later and enabling the Developer Dashboard, +please make sure you also provision the Usage and Health service application +to make sure the Developer Dashboard works properly. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 index 1a6adf7d1..d78f3075b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 @@ -60,10 +60,10 @@ function Get-TargetResource $farmAdministratorsGroup = $caWeb.SiteGroups.GetByName($farmAdminGroup) return @{ IsSingleInstance = "Yes" - Members = $farmAdministratorsGroup.users.UserLogin + Members = $farmAdministratorsGroup.users.UserLogin MembersToInclude = $params.MembersToInclude MembersToExclude = $params.MembersToExclude - InstallAccount = $params.InstallAccount + InstallAccount = $params.InstallAccount } } return $result @@ -134,7 +134,7 @@ function Set-TargetResource else { Write-Verbose "Farm Administrators group does not match. Perform corrective action" - $addUsers = @() + $addUsers = @() $removeUsers = @() foreach ($difference in $differences) { @@ -154,14 +154,14 @@ function Set-TargetResource } } - if($addUsers.count -gt 0) + if ($addUsers.count -gt 0) { Write-Verbose "Adding $($addUsers.Count) users to the Farm Administrators group" $changeUsers.Add = $addUsers $runChange = $true } - if($removeUsers.count -gt 0) + if ($removeUsers.count -gt 0) { Write-Verbose "Removing $($removeUsers.Count) users from the Farm Administrators group" $changeUsers.Remove = $removeUsers @@ -188,7 +188,7 @@ function Set-TargetResource } } - if($addUsers.count -gt 0) + if ($addUsers.count -gt 0) { Write-Verbose "Adding $($addUsers.Count) users to the Farm Administrators group" $changeUsers.Add = $addUsers @@ -214,7 +214,7 @@ function Set-TargetResource } } - if($removeUsers.count -gt 0) + if ($removeUsers.count -gt 0) { Write-Verbose "Removing $($removeUsers.Count) users from the Farm Administrators group" $changeUsers.Remove = $removeUsers @@ -343,7 +343,9 @@ function Merge-SPDscFarmAdminList $changeUsers ) - $result = Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $changeUsers -ScriptBlock { + $result = Invoke-SPDSCCommand -Credential $InstallAccount ` + -Arguments $changeUsers ` + -ScriptBlock { $changeUsers = $args[0] $webApps = Get-SPwebapplication -IncludeCentralAdministration diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 index 692671edf..8a3322114 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 @@ -12,13 +12,13 @@ function Get-TargetResource() [System.String] $Value, - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = 'Present', [Parameter()] - [System.Management.Automation.PSCredential] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -29,16 +29,16 @@ function Get-TargetResource() -ScriptBlock { $params = $args[0] - try + try { $spFarm = Get-SPFarm -ErrorAction SilentlyContinue - } - catch + } + catch { Write-Verbose -Message ("No local SharePoint farm was detected.") return @{ - Key = $params.Key - Value = $null + Key = $params.Key + Value = $null Ensure = 'Absent' } } @@ -49,29 +49,29 @@ function Get-TargetResource() { if ($spFarm.Properties.Contains($params.Key) -eq $true) { - $localEnsure = "Present" + $localEnsure = "Present" $currentValue = $spFarm.Properties[$params.Key] } else { - $localEnsure = "Absent" + $localEnsure = "Absent" $currentValue = $null } } } else { - $null = $currentValue - $localEnsure = 'Absent' + $currentValue = $null + $localEnsure = 'Absent' } return @{ - Key = $params.Key - Value = $currentValue + Key = $params.Key + Value = $currentValue Ensure = $localEnsure } } - return $result + return $result } function Set-TargetResource() @@ -87,13 +87,13 @@ function Set-TargetResource() [System.String] $Value, - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = 'Present', [Parameter()] - [System.Management.Automation.PSCredential] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -104,14 +104,13 @@ function Set-TargetResource() -ScriptBlock { $params = $args[0] - try + try { $spFarm = Get-SPFarm -ErrorAction SilentlyContinue - } - catch + } + catch { throw "No local SharePoint farm was detected." - return } if ($params.Ensure -eq 'Present') @@ -125,7 +124,7 @@ function Set-TargetResource() else { Write-Warning -Message 'Ensure = Present, value parameter cannot be null' - } + } } else { @@ -151,13 +150,13 @@ function Test-TargetResource() [System.String] $Value, - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = 'Present', [Parameter()] - [System.Management.Automation.PSCredential] + [System.Management.Automation.PSCredential] $InstallAccount ) diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 index ced418660..a2935a95f 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 @@ -53,16 +53,16 @@ function Get-TargetResource if ($null -ne $solution) { $currentState = "Present" - $deployed = $solution.Deployed - $version = $Solution.Properties["Version"] + $deployed = $solution.Deployed + $version = $Solution.Properties["Version"] $deployedWebApplications = @($solution.DeployedWebApplications ` | Select-Object -ExpandProperty Url) } else { $currentState = "Absent" - $deployed = $false - $version = "0.0.0.0" + $deployed = $false + $version = "0.0.0.0" $deployedWebApplications = @() } @@ -123,8 +123,8 @@ function Set-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters - $PSBoundParameters.Ensure = $Ensure - $PSBoundParameters.Version = $Version + $PSBoundParameters.Ensure = $Ensure + $PSBoundParameters.Version = $Version $PSBoundParameters.Deployed = $Deployed if ($Ensure -eq "Present") @@ -222,7 +222,7 @@ function Set-TargetResource } else { - #If ensure is absent we should also retract the solution first + # If ensure is absent we should also retract the solution first $Deployed = $false } @@ -243,6 +243,8 @@ function Set-TargetResource $runParams.Add("Confirm", $false) $runParams.Add("Verbose", $false) + $solution = Get-SPSolution -Identity $params.Name -Verbose:$false + if ($solution.ContainsWebApplicationResource) { if ($null -eq $webApps -or $webApps.Length -eq 0) @@ -325,8 +327,8 @@ function Set-TargetResource $runParams = @{ Identity = $params.Name - Confirm = $false - Verbose = $false + Confirm = $false + Verbose = $false } Remove-SPSolution @runParams @@ -435,7 +437,6 @@ function Wait-SPDSCSolutionJob Write-Verbose -Message "Result: $($solution.LastOperationResult)" Write-Verbose -Message "Details: $($solution.LastOperationDetails)" - } else { @@ -449,7 +450,7 @@ function Wait-SPDSCSolutionJob Stop-SPAssignment $gc -Verbose:$false return @{ - LastOperationResult = $solution.LastOperationResult + LastOperationResult = $solution.LastOperationResult LastOperationDetails = $solution.LastOperationDetails } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 index 7562250a1..3e857e4ce 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 @@ -4,30 +4,30 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Url, - [Parameter(Mandatory = $true)] - [ValidateSet("Farm","WebApplication","Site","Web")] - [System.String] + [Parameter(Mandatory = $true)] + [ValidateSet("Farm","WebApplication","Site","Web")] + [System.String] $FeatureScope, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Version ) @@ -39,34 +39,34 @@ function Get-TargetResource $params = $args[0] $checkParams = @{ - Identity = $params.Name + Identity = $params.Name } - if ($params.FeatureScope -eq "Farm") + if ($params.FeatureScope -eq "Farm") { $checkParams.Add($params.FeatureScope, $true) - } - else + } + else { $checkParams.Add($params.FeatureScope, $params.Url) } $featureAtScope = Get-SPFeature @checkParams -ErrorAction SilentlyContinue $enabled = ($null -ne $featureAtScope) - if ($enabled -eq $true) + if ($enabled -eq $true) { - $currentState = "Present" - } - else + $currentState = "Present" + } + else { - $currentState = "Absent" + $currentState = "Absent" } return @{ - Name = $params.Name - FeatureScope = $params.FeatureScope - Url = $params.Url + Name = $params.Name + FeatureScope = $params.FeatureScope + Url = $params.Url + Version = $featureAtScope.Version + Ensure = $currentState InstallAccount = $params.InstallAccount - Ensure = $currentState - Version = $featureAtScope.Version } } return $result @@ -78,30 +78,30 @@ function Set-TargetResource [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Url, - [Parameter(Mandatory = $true)] - [ValidateSet("Farm","WebApplication","Site","Web")] - [System.String] + [Parameter(Mandatory = $true)] + [ValidateSet("Farm","WebApplication","Site","Web")] + [System.String] $FeatureScope, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Version ) @@ -110,9 +110,9 @@ function Set-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters $PSBoundParameters.Add("CurrentValues", $CurrentValues) - $PSBoundParameters.Ensure = $Ensure + $PSBoundParameters.Ensure = $Ensure - if ($Ensure -eq "Present") + if ($Ensure -eq "Present") { Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` @@ -121,18 +121,18 @@ function Set-TargetResource $currentValues = $params["CurrentValues"] $runParams = @{ - Identity = $params.Name + Identity = $params.Name } - if ($params.FeatureScope -ne "Farm") + if ($params.FeatureScope -ne "Farm") { $runParams.Add("Url", $params.Url) } - + if ($currentValues.Ensure -eq "Present") { # Disable the feature first if it already exists. - $runParams.Add("Confirm", $false) + $runParams.Add("Confirm", $false) Write-Verbose -Message ("Disable Feature '$($params.Name)' because it is " + ` "already active at scope '$($params.FeatureScope)'...") Disable-SPFeature @runParams @@ -143,29 +143,29 @@ function Set-TargetResource Enable-SPFeature @runParams } } - if ($Ensure -eq "Absent") + if ($Ensure -eq "Absent") { Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { - + $params = $args[0] $currentValues = $params["CurrentValues"] $runParams = @{ - Identity = $params.Name + Identity = $params.Name } - if ($params.FeatureScope -ne "Farm") + if ($params.FeatureScope -ne "Farm") { $runParams.Add("Url", $params.Url) } - - $runParams.Add("Confirm", $false) + + $runParams.Add("Confirm", $false) Write-Verbose -Message ("Disable Feature '$($params.Name)' because 'Ensure' is " + ` - "'$($params.Ensure)'...") + "'$($params.Ensure)'...") Disable-SPFeature @runParams - } + } } } @@ -176,36 +176,36 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Url, - [Parameter(Mandatory = $true)] - [ValidateSet("Farm","WebApplication","Site","Web")] - [System.String] + [Parameter(Mandatory = $true)] + [ValidateSet("Farm","WebApplication","Site","Web")] + [System.String] $FeatureScope, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Version ) Write-Verbose -Message "Testing feature $Name at $FeatureScope scope" - $PSBoundParameters.Ensure = $Ensure + $PSBoundParameters.Ensure = $Ensure $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 new file mode 100644 index 000000000..4005d7c80 --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 @@ -0,0 +1,379 @@ +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateSet("Yes")] + [System.String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [ValidateSet("Present", "Absent")] + [System.String] + $Ensure, + + [Parameter()] + [System.Boolean] + $UseAutomaticSettings, + + [Parameter()] + [ValidateSet("Yes", "No", "Remote")] + [System.String] + $UseDirectoryManagementService, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $RemoteDirectoryManagementURL, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerAddress, + + [Parameter()] + [System.Boolean] + $DLsRequireAuthenticatedSenders, + + [Parameter()] + [System.Boolean] + $DistributionGroupsEnabled, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerDisplayAddress, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $DropFolder, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Getting SharePoint Incoming Email Settings" + + $result = Invoke-SPDSCCommand -Credential $InstallAccount ` + -ScriptBlock { + $spEmailServiceInstance = (Get-SPServiceInstance | Where-Object {$_.GetType().FullName -eq "Microsoft.SharePoint.Administration.SPIncomingEmailServiceInstance" }) | Select-Object -First 1 + $spEmailService = $spEmailServiceInstance.service + + # some simple error checking, just incase we didn't capture the service for some reason + if ($null -eq $spEmailService) + { + Write-Verbose "Error getting the SharePoint Incoming Email Service" + return @{ + IsSingleInstance = "Yes" + Ensure = $null + UseAutomaticSettings = $null + UseDirectoryManagementService = $null + RemoteDirectoryManagementURL = $null + ServerAddress = $null + DLsRequireAuthenticatedSenders = $null + DistributionGroupsEnabled = $null + ServerDisplayAddress = $null + DropFolder = $null + } + } + + # determine if incoming email is enabled + if ($spEmailService.Enabled -eq $true) + { + $ensure = "Present" + } + else + { + return @{ + IsSingleInstance = "Yes" + Ensure = "Absent" + UseAutomaticSettings = $null + UseDirectoryManagementService = $null + RemoteDirectoryManagementURL = $null + ServerAddress = $null + DLsRequireAuthenticatedSenders = $null + DistributionGroupsEnabled = $null + ServerDisplayAddress = $null + DropFolder = $null + } + } + + #determine directory service integration mode + if ($spEmailService.UseDirectoryManagementService -eq $false) + { + $useDirectoryManagementService = "No" + } + elseif ($spEmailService.UseDirectoryManagementService -eq $true -and $spEmailService.RemoteDirectoryManagementService -eq $false) + { + $useDirectoryManagementService = "Yes" + $remoteDirectoryManagementURL = $null + } + elseif ($spEmailService.UseDirectoryManagementService -eq $true -and $spEmailService.RemoteDirectoryManagementService -eq $true) + { + $useDirectoryManagementService = "Remote" + $remoteDirectoryManagementURL = $spEmailService.DirectoryManagementServiceUrl + } + + return @{ + IsSingleInstance = "Yes" + Ensure = $ensure + UseAutomaticSettings = $spEmailService.UseAutomaticSettings + UseDirectoryManagementService = $useDirectoryManagementService + RemoteDirectoryManagementURL = $remoteDirectoryManagementURL + ServerAddress = $spEmailService.ServerAddress + DLsRequireAuthenticatedSenders = $spEmailService.DLsRequireAuthenticatedSenders + DistributionGroupsEnabled = $spEmailService.DistributionGroupsEnabled + ServerDisplayAddress = $spEmailService.ServerDisplayAddress + DropFolder = $spEmailService.DropFolder + } + + } + + return $result +} + + +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateSet("Yes")] + [System.String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [ValidateSet("Present", "Absent")] + [System.String] + $Ensure, + + [Parameter()] + [System.Boolean] + $UseAutomaticSettings, + + [Parameter()] + [ValidateSet("Yes", "No", "Remote")] + [System.String] + $UseDirectoryManagementService, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $RemoteDirectoryManagementURL, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerAddress, + + [Parameter()] + [System.Boolean] + $DLsRequireAuthenticatedSenders, + + [Parameter()] + [System.Boolean] + $DistributionGroupsEnabled, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerDisplayAddress, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $DropFolder, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Setting SharePoint Incoming Email Settings" + + if ($Ensure -eq 'Present') + { + if (-not $PSBoundParameters.containskey("UseAutomaticSettings")) + { + throw "UseAutomaticSettings parameter must be specified when enabling incoming email." + } + + if (-not $PSBoundParameters.containskey("ServerDisplayAddress")) + { + throw "ServerDisplayAddress parameter must be specified when enabling incoming email" + } + + if (($PSBoundParameters.UseDirectoryManagementService -eq 'Remote' -and $null -eq $PSBoundParameters.RemoteDirectoryManagementURL) ` + -or ($PSBoundParameters.containskey('RemoteDirectoryManagementURL') -and $PSBoundParameters.UseDirectoryManagementService -ne 'Remote')) + { + throw "RemoteDirectoryManagementURL must be specified only when UseDirectoryManagementService is set to 'Remote'" + } + + if ($PSBoundParameters.UseAutomaticSettings -eq $true -and $PSBoundParameters.containskey("DropFolder")) + { + throw "DropFolder parameter is not valid when using Automatic Mode" + } + + if ($PSBoundParameters.UseAutomaticSettings -eq $false -and (-not $PSBoundParameters.containskey("DropFolder"))) + { + throw "DropFolder parameter must be specified when not using Automatic Mode" + } + } + + Invoke-SPDSCCommand -Credential $InstallAccount ` + -Arguments $PSBoundParameters ` + -ScriptBlock { + $params = $args[0] + + $spEmailServiceInstance = (Get-SPServiceInstance | Where-Object {$_.GetType().FullName -eq "Microsoft.SharePoint.Administration.SPIncomingEmailServiceInstance" }) | Select-Object -First 1 + $spEmailService = $spEmailServiceInstance.service + + #some simple error checking, just incase we didn't capture the service for some reason + if ($null -eq $spEmailService) + { + throw "Error getting the SharePoint Incoming Email Service" + } + + if ($params.Ensure -eq "Absent") + { + Write-Verbose -Message "Disabling SharePoint Incoming Email" + $spEmailService.Enabled = $false + + } + else #Present + { + Write-Verbose -Message "Enabling SharePoint Incoming Email" + + + + $spEmailService.Enabled = $true + $spEmailService.ServerDisplayAddress = $params.ServerDisplayAddress + + if ($params.UseAutomaticSettings -eq $true) + { + Write-Verbose -Message "Setting Incoming Email Service to use Automatic Settings" + $spEmailService.UseAutomaticSettings = $true + } + else + { + Write-Verbose -Message "Setting Incoming Email Service to use Advanced Settings" + $spEmailService.UseAutomaticSettings = $false + $spEmailService.DropFolder = $params.DropFolder + } + + #Configure Directory Management modes + if ($params.UseDirectoryManagementService -eq "Yes") + { + $spEmailService.UseDirectoryManagementService = $true + $spEmailService.RemoteDirectoryManagementService = $false + } + elseif ($params.UseDirectoryManagementService -eq "Remote") + { + $spEmailService.UseDirectoryManagementService = $true + $spEmailService.RemoteDirectoryManagementService = $true + $spEmailService.DirectoryManagementServiceURL = $params.RemoteDirectoryManagementURL + } + else + { + $spEmailService.UseDirectoryManagementService = $false + $spEmailService.RemoteDirectoryManagementService = $false + $spEmailService.DirectoryManagementServiceURL = $null + } + + #Optional settings for Directory Management + if ($params.UseDirectoryManagementService -eq "Yes" -or $params.UseDirectoryManagementService -eq "Remote") + { + if ($params.containskey('DLsRequireAuthenticatedSenders')) + { + $spEmailService.DLsRequireAuthenticatedSenders = $params.DLsRequireAuthenticatedSenders + } + + if ($params.containskey('DistributionGroupsEnabled')) + { + $spEmailService.DistributionGroupsEnabled = $params.DistributionGroupsEnabled + } + + if ($params.containskey('ServerAddress')) + { + $spEmailService.ServerAddress = $params.ServerAddress + } + } + } + + $spEmailService.Update() + + } + +} + +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateSet("Yes")] + [System.String] + $IsSingleInstance, + + [Parameter(Mandatory = $true)] + [ValidateSet("Present", "Absent")] + [System.String] + $Ensure, + + [Parameter()] + [System.Boolean] + $UseAutomaticSettings, + + [Parameter()] + [ValidateSet("Yes", "No", "Remote")] + [System.String] + $UseDirectoryManagementService, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $RemoteDirectoryManagementURL, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerAddress, + + [Parameter()] + [System.Boolean] + $DLsRequireAuthenticatedSenders, + + [Parameter()] + [System.Boolean] + $DistributionGroupsEnabled, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ServerDisplayAddress, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $DropFolder, + + [Parameter()] + [System.Management.Automation.PSCredential] + $InstallAccount + ) + + Write-Verbose -Message "Testing SharePoint Incoming Email Settings" + + return Test-SPDscParameterState -CurrentValues (Get-TargetResource @PSBoundParameters) ` + -DesiredValues $PSBoundParameters +} + + +Export-ModuleMember -Function *-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.schema.mof new file mode 100644 index 000000000..34684edc1 --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.schema.mof @@ -0,0 +1,16 @@ + +[ClassVersion("1.0.0.0"), FriendlyName("SPIncomingEmailSettings")] +class MSFT_SPIncomingEmailSettings : OMI_BaseResource +{ + [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; + [Required, Description("Present ensures Incoming Email is enabled. Absent disables incoming email"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; + [Write, Description("Automatic Settings enables a local SMTP service on the SharePoint server. Set to False to use an external drop folder")] Boolean UseAutomaticSettings; + [Write, Description("Set to Yes, the service supports the creation and management of e-mail distribution groups from SharePoint Sites, and creates mail contacts mail enabled SharePoint lists. Set to Remote to use a remote SharePoint Directory Management Web Service"), ValueMap{"Yes","No","Remote"}, Values{"Yes","No","Remote"}] string UseDirectoryManagementService; + [Write, Description("URL to the remote SharePoint Directory Management Web Service")] String RemoteDirectoryManagementURL; + [Write, Description("SMTP Server Address when Directory Managment Service mode is used")] String ServerAddress; + [Write, Description("SharePoint Distribution lists accept from authenticated senders only")] Boolean DLsRequireAuthenticatedSenders; + [Write, Description("Allow creation of distribution groups from within SharePoint")] Boolean DistributionGroupsEnabled; + [Write, Description("Email server display address 'mylist@example.com'")] String ServerDisplayAddress; + [Write, Description("Path to email drop folder if not using Automatic Settings")] String DropFolder; + [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; +}; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/Readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/Readme.md new file mode 100644 index 000000000..dc06549be --- /dev/null +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/Readme.md @@ -0,0 +1,13 @@ +# Description + +**Type:** Common +**Requires CredSSP:** No + +This resource is used to enable and configure SharePoint incoming email. +Setting the Ensure parameter to 'Present' or 'Absent' will enable or disable +incoming email accordingly. When enabled, this resource allows for configuring +of required parameters for both Automatic and Advanced methods of supporting +SharePoint incoming email. + +This resource does not currently support setting the Active Directory OU +where SharePoint can create mail contacts and distribution groups. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 index 9330721d1..f23b7969d 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 @@ -49,22 +49,22 @@ function Get-TargetResource { return @{ IsSingleInstance = "Yes" - BinaryDir = $BinaryDir - ProductKey = $ProductKey - InstallPath = $InstallPath - DataPath = $DataPath - Ensure = "Present" + BinaryDir = $BinaryDir + ProductKey = $ProductKey + InstallPath = $InstallPath + DataPath = $DataPath + Ensure = "Present" } } else { return @{ IsSingleInstance = "Yes" - BinaryDir = $BinaryDir - ProductKey = $ProductKey - InstallPath = $InstallPath - DataPath = $DataPath - Ensure = "Absent" + BinaryDir = $BinaryDir + ProductKey = $ProductKey + InstallPath = $InstallPath + DataPath = $DataPath + Ensure = "Absent" } } } @@ -110,7 +110,6 @@ function Set-TargetResource { throw [Exception] ("SharePointDsc does not support uninstalling SharePoint or " + ` "its prerequisites. Please remove this manually.") - return } $InstallerPath = Join-Path $BinaryDir "setup.exe" @@ -158,7 +157,7 @@ function Set-TargetResource Write-Verbose -Message "Writing install config file" - $configPath = "$env:temp\SPInstallConfig.xml" + $configPath = Join-Path -Path $env:temp -ChildPath "SPInstallConfig.xml" $configData = " @@ -278,7 +277,6 @@ function Test-TargetResource { throw [Exception] ("SharePointDsc does not support uninstalling SharePoint or " + ` "its prerequisites. Please remove this manually.") - return } $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 index c6df94910..8568a4d69 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 @@ -1,21 +1,36 @@ $Script:SP2013Features = @("Application-Server", "AS-NET-Framework", - "AS-TCP-Port-Sharing", "AS-Web-Support", "AS-WAS-Support", - "AS-HTTP-Activation", "AS-Named-Pipes", "AS-TCP-Activation","Web-Server", - "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", - "Web-Http-Errors", "Web-Static-Content", "Web-Http-Redirect", "Web-Health", - "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", - "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", - "Web-Dyn-Compression", "Web-Security", "Web-Filtering", "Web-Basic-Auth", - "Web-Client-Auth", "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", - "Web-Url-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", - "Web-Net-Ext45", "Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", - "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", "Web-Mgmt-Compat", - "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", "Web-Scripting-Tools", - "NET-Framework-Features", "NET-Framework-Core", "NET-Framework-45-ASPNET", - "NET-WCF-HTTP-Activation45", "NET-WCF-Pipe-Activation45", - "NET-WCF-TCP-Activation45", "Server-Media-Foundation", - "Windows-Identity-Foundation", "PowerShell-V2", "WAS", "WAS-Process-Model", - "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer") + "AS-TCP-Port-Sharing", "AS-Web-Support", "AS-WAS-Support", + "AS-HTTP-Activation", "AS-Named-Pipes", "AS-TCP-Activation","Web-Server", + "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", + "Web-Http-Errors", "Web-Static-Content", "Web-Http-Redirect", "Web-Health", + "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", + "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", + "Web-Dyn-Compression", "Web-Security", "Web-Filtering", "Web-Basic-Auth", + "Web-Client-Auth", "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", + "Web-Url-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", + "Web-Net-Ext45", "Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", + "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", "Web-Mgmt-Compat", + "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", "Web-Scripting-Tools", + "NET-Framework-Features", "NET-Framework-Core", "NET-Framework-45-ASPNET", + "NET-WCF-HTTP-Activation45", "NET-WCF-Pipe-Activation45", + "NET-WCF-TCP-Activation45", "Server-Media-Foundation", + "Windows-Identity-Foundation", "PowerShell-V2", "WAS", "WAS-Process-Model", + "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer") + +$Script:SP2016Win19Features = @("Web-Server", "Web-WebServer", + "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", + "Web-Http-Errors", "Web-Static-Content", "Web-Health", + "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", + "Web-Http-Tracing", "Web-Performance", "Web-Stat-Compression", + "Web-Dyn-Compression", "Web-Security", "Web-Filtering", "Web-Basic-Auth", + "Web-Digest-Auth", "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", + "Web-Net-Ext45", "Web-Asp-Net", "Web-Asp-Net45", "Web-ISAPI-Ext", + "Web-ISAPI-Filter", "Web-Mgmt-Tools", "Web-Mgmt-Console", + "Web-Mgmt-Compat", "Web-Metabase", "Web-Lgcy-Scripting", "Web-WMI", + "NET-Framework-Features", "NET-HTTP-Activation", "NET-Non-HTTP-Activ", + "NET-Framework-45-ASPNET", "NET-WCF-Pipe-Activation45", + "Windows-Identity-Foundation", "WAS", "WAS-Process-Model", + "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer") $Script:SP2016Win16Features = @("Web-Server", "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", @@ -33,22 +48,22 @@ $Script:SP2016Win16Features = @("Web-Server", "Web-WebServer", "WAS-NET-Environment", "WAS-Config-APIs", "XPS-Viewer") $Script:SP2016Win12r2Features = @("Application-Server", "AS-NET-Framework", - "AS-Web-Support", "Web-Server", "Web-WebServer", "Web-Common-Http", - "Web-Default-Doc", "Web-Dir-Browsing", "Web-Http-Errors", - "Web-Static-Content", "Web-Http-Redirect", "Web-Health", - "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", - "Web-Performance", "Web-Stat-Compression", "Web-Dyn-Compression", - "Web-Security", "Web-Filtering", "Web-Basic-Auth", "Web-Client-Auth", - "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", "Web-Url-Auth", - "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", "Web-Net-Ext45", - "Web-Asp-Net45", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Mgmt-Tools", - "Web-Mgmt-Console", "Web-Mgmt-Compat", "Web-Metabase", - "Web-Lgcy-Mgmt-Console", "Web-Lgcy-Scripting", "Web-WMI", - "Web-Scripting-Tools", "NET-Framework-Features", "NET-Framework-Core", - "NET-HTTP-Activation", "NET-Non-HTTP-Activ", "NET-Framework-45-ASPNET", - "NET-WCF-HTTP-Activation45", "Windows-Identity-Foundation", - "PowerShell-V2", "WAS", "WAS-Process-Model", "WAS-NET-Environment", - "WAS-Config-APIs") + "AS-Web-Support", "Web-Server", "Web-WebServer", "Web-Common-Http", + "Web-Default-Doc", "Web-Dir-Browsing", "Web-Http-Errors", + "Web-Static-Content", "Web-Http-Redirect", "Web-Health", + "Web-Http-Logging", "Web-Log-Libraries", "Web-Request-Monitor", + "Web-Performance", "Web-Stat-Compression", "Web-Dyn-Compression", + "Web-Security", "Web-Filtering", "Web-Basic-Auth", "Web-Client-Auth", + "Web-Digest-Auth", "Web-Cert-Auth", "Web-IP-Security", "Web-Url-Auth", + "Web-Windows-Auth", "Web-App-Dev", "Web-Net-Ext", "Web-Net-Ext45", + "Web-Asp-Net45", "Web-ISAPI-Ext", "Web-ISAPI-Filter", "Web-Mgmt-Tools", + "Web-Mgmt-Console", "Web-Mgmt-Compat", "Web-Metabase", + "Web-Lgcy-Mgmt-Console", "Web-Lgcy-Scripting", "Web-WMI", + "Web-Scripting-Tools", "NET-Framework-Features", "NET-Framework-Core", + "NET-HTTP-Activation", "NET-Non-HTTP-Activ", "NET-Framework-45-ASPNET", + "NET-WCF-HTTP-Activation45", "Windows-Identity-Foundation", + "PowerShell-V2", "WAS", "WAS-Process-Model", "WAS-NET-Environment", + "WAS-Config-APIs") $Script:SP2019Win16Features = @("Web-Server", "Web-WebServer", "Web-Common-Http", "Web-Default-Doc", "Web-Dir-Browsing", @@ -189,11 +204,11 @@ function Get-TargetResource } if ($majorVersion -eq 16) { - if($buildVersion -lt 5000) + if ($buildVersion -lt 5000) { Write-Verbose -Message "Version: SharePoint 2016" } - elseif($buildVersion -ge 5000) + elseif ($buildVersion -ge 5000) { Write-Verbose -Message "Version: SharePoint 2019" } @@ -204,39 +219,55 @@ function Get-TargetResource $osVersion = Get-SPDscOSVersion if ($majorVersion -eq 15) { + if ($osVersion.Major -ne 6) + { + throw "SharePoint 2013 only supports Windows Server 2012 R2 and below" + } + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2013Features } elseif ($majorVersion -eq 16) { - if($buildVersion -lt 5000) + if ($buildVersion -lt 5000) { if ($osVersion.Major -eq 10) { - # Server 2016 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features + if ($osVersion.Build -lt 17763) + { + Write-Verbose -Message "OS Version: Windows Server 2016" + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features + } + else + { + Write-Verbose -Message "OS Version: Windows Server 2019" + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win19Features + } } elseif ($osVersion.Major -eq 6 -and $osVersion.Minor -eq 3) { - # Server 2012 R2 + Write-Verbose -Message "OS Version: Windows Server 2012 R2" $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win12r2Features } else { - throw "SharePoint 2016 only supports Windows Server 2016 or 2012 R2" + throw "SharePoint 2016 only supports Windows Server 2019, 2016 or 2012 R2" } } # SharePoint 2019 - elseif($buildVersion -ge 5000) + elseif ($buildVersion -ge 5000) { - if ($osVersion.Major -eq 11) - { - # Server 2019 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win19Features - } - elseif ($osVersion.Major -eq 10) + if ($osVersion.Major -eq 10) { - # Server 2016 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win16Features + if ($osVersion.Build -lt 17763) + { + Write-Verbose -Message "OS Version: Windows Server 2016" + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win16Features + } + else + { + Write-Verbose -Message "OS Version: Windows Server 2019" + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win19Features + } } else { @@ -268,28 +299,28 @@ function Get-TargetResource # Common prereqs $prereqsToTest = @( [PSObject]@{ - Name = "AppFabric 1.1 for Windows Server" - SearchType = "Equals" + Name = "AppFabric 1.1 for Windows Server" + SearchType = "Equals" SearchValue = "AppFabric 1.1 for Windows Server" }, [PSObject]@{ - Name = "Microsoft CCR and DSS Runtime 2008 R3" - SearchType = "Equals" + Name = "Microsoft CCR and DSS Runtime 2008 R3" + SearchType = "Equals" SearchValue = "Microsoft CCR and DSS Runtime 2008 R3" }, [PSObject]@{ - Name = "Microsoft Identity Extensions" - SearchType = "Equals" + Name = "Microsoft Identity Extensions" + SearchType = "Equals" SearchValue = "Microsoft Identity Extensions" }, [PSObject]@{ - Name = "Microsoft Sync Framework Runtime v1.0 SP1 (x64)" - SearchType = "Equals" + Name = "Microsoft Sync Framework Runtime v1.0 SP1 (x64)" + SearchType = "Equals" SearchValue = "Microsoft Sync Framework Runtime v1.0 SP1 (x64)" }, [PSObject]@{ - Name = "WCF Data Services 5.6.0 Runtime" - SearchType = "Equals" + Name = "WCF Data Services 5.6.0 Runtime" + SearchType = "Equals" SearchValue = "WCF Data Services 5.6.0 Runtime" } ) @@ -299,18 +330,18 @@ function Get-TargetResource { $prereqsToTest += @( [PSObject]@{ - Name = "Active Directory Rights Management Services Client 2.*" - SearchType = "Like" + Name = "Active Directory Rights Management Services Client 2.*" + SearchType = "Like" SearchValue = "Active Directory Rights Management Services Client 2.*" }, [PSObject]@{ - Name = "Microsoft SQL Server Native Client (2008 R2 or 2012)" - SearchType = "Match" + Name = "Microsoft SQL Server Native Client (2008 R2 or 2012)" + SearchType = "Match" SearchValue = "SQL Server (2008 R2|2012) Native Client" }, [PSObject]@{ - Name = "WCF Data Services 5.0 (for OData v3) Primary Components" - SearchType = "Equals" + Name = "WCF Data Services 5.0 (for OData v3) Primary Components" + SearchType = "Equals" SearchValue = "WCF Data Services 5.0 (for OData v3) Primary Components" } ) @@ -324,55 +355,55 @@ function Get-TargetResource #SP2016 prereqs $prereqsToTest += @( [PSObject]@{ - Name = "Active Directory Rights Management Services Client 2.1" - SearchType = "Equals" + Name = "Active Directory Rights Management Services Client 2.1" + SearchType = "Equals" SearchValue = "Active Directory Rights Management Services Client 2.1" }, [PSObject]@{ - Name = "Microsoft SQL Server 2012 Native Client" - SearchType = "Equals" + Name = "Microsoft SQL Server 2012 Native Client" + SearchType = "Equals" SearchValue = "Microsoft SQL Server 2012 Native Client" }, [PSObject]@{ - Name = "Microsoft ODBC Driver 11 for SQL Server" - SearchType = "Equals" + Name = "Microsoft ODBC Driver 11 for SQL Server" + SearchType = "Equals" SearchValue = "Microsoft ODBC Driver 11 for SQL Server" }, [PSObject]@{ - Name = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0" - SearchType = "Like" + Name = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0" + SearchType = "Like" SearchValue = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.*" }, [PSObject]@{ - Name = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0" - SearchType = "Like" + Name = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0" + SearchType = "Like" SearchValue = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.*" }, [PSObject]@{ - Name = "Microsoft Visual C++ 2015 Redistributable (x64)" - SearchType = "BundleUpgradeCode" + Name = "Microsoft Visual C++ 2015 Redistributable (x64)" + SearchType = "BundleUpgradeCode" SearchValue = "{C146EF48-4D31-3C3D-A2C5-1E91AF8A0A9B}" MinimumRequiredVersion = "14.0.23026.0" } ) } - elseif($buildVersion -ge 5000) + elseif ($buildVersion -ge 5000) { #SP2019 prereqs $prereqsToTest += @( [PSObject]@{ - Name = "Active Directory Rights Management Services Client 2.1" - SearchType = "Equals" + Name = "Active Directory Rights Management Services Client 2.1" + SearchType = "Equals" SearchValue = "Active Directory Rights Management Services Client 2.1" }, [PSObject]@{ - Name = "Microsoft SQL Server 2012 Native Client" - SearchType = "Equals" + Name = "Microsoft SQL Server 2012 Native Client" + SearchType = "Equals" SearchValue = "Microsoft SQL Server 2012 Native Client" }, [PSObject]@{ - Name = "Microsoft Visual C++ 2017 Redistributable (x64)" - SearchType = "BundleUpgradeCode" + Name = "Microsoft Visual C++ 2017 Redistributable (x64)" + SearchType = "BundleUpgradeCode" SearchValue = "{C146EF48-4D31-3C3D-A2C5-1E91AF8A0A9B}" MinimumRequiredVersion = "14.13.26020.0" } @@ -383,28 +414,28 @@ function Get-TargetResource -PrereqsToCheck $prereqsToTest $results = @{ - IsSingleInstance = "Yes" - InstallerPath = $InstallerPath - OnlineMode = $OnlineMode - SXSpath = $SXSpath - SQLNCli = $SQLNCli - PowerShell = $PowerShell - NETFX = $NETFX - IDFX = $IDFX - Sync = $Sync - AppFabric = $AppFabric - IDFX11 = $IDFX11 - MSIPCClient = $MSIPCClient - WCFDataServices = $WCFDataServices - KB2671763 = $KB2671763 + IsSingleInstance = "Yes" + InstallerPath = $InstallerPath + OnlineMode = $OnlineMode + SXSpath = $SXSpath + SQLNCli = $SQLNCli + PowerShell = $PowerShell + NETFX = $NETFX + IDFX = $IDFX + Sync = $Sync + AppFabric = $AppFabric + IDFX11 = $IDFX11 + MSIPCClient = $MSIPCClient + WCFDataServices = $WCFDataServices + KB2671763 = $KB2671763 WCFDataServices56 = $WCFDataServices56 - MSVCRT11 = $MSVCRT11 - MSVCRT14 = $MSVCRT14 - MSVCRT141 = $MSVCRT141 - KB3092423 = $KB3092423 - ODBC = $ODBC - DotNetFx = $DotNetFx - DotNet472 = $DotNet472 + MSVCRT11 = $MSVCRT11 + MSVCRT14 = $MSVCRT14 + MSVCRT141 = $MSVCRT141 + KB3092423 = $KB3092423 + ODBC = $ODBC + DotNetFx = $DotNetFx + DotNet472 = $DotNet472 } if ($prereqsInstalled -eq $true -and $windowsFeaturesInstalled -eq $true) @@ -527,17 +558,51 @@ function Set-TargetResource { throw [Exception] ("SharePointDsc does not support uninstalling SharePoint or its " + ` "prerequisites. Please remove this manually.") - return } Write-Verbose -Message "Detecting SharePoint version from binaries" $majorVersion = Get-SPDSCAssemblyVersion -PathToAssembly $InstallerPath - $buildVersion = (Get-SPDSCBuildVersion -PathToAssembly $InstallerPath) + $buildVersion = Get-SPDSCBuildVersion -PathToAssembly $InstallerPath $osVersion = Get-SPDscOSVersion + switch ($osVersion.Major) + { + 6 { + switch ($osVersion.Minor) + { + 0 { + Write-Verbose -Message "Operating System: Windows Server 2008" + } + 1 { + Write-Verbose -Message "Operating System: Windows Server 2008 R2" + } + 2 { + Write-Verbose -Message "Operating System: Windows Server 2012" + } + 3 { + Write-Verbose -Message "Operating System: Windows Server 2012 R2" + } + } + } + 10 { + if ($osVersion.Build -lt 17763) + { + Write-Verbose -Message "Operating System: Windows Server 2016" + } + else + { + Write-Verbose -Message "Operating System: Windows Server 2019" + } + } + } if ($majorVersion -eq 15) { - $BinaryDir = Split-Path -Path $InstallerPath + if ($osVersion.Major -ne 6) + { + throw "SharePoint 2013 only supports Windows Server 2012 R2 and below" + } + + $BinaryDir = Split-Path -Path $InstallerPath $svrsetupDll = Join-Path -Path $BinaryDir -ChildPath "updates\svrsetup.dll" $checkDotNet = $true if (Test-Path -Path $svrsetupDll) @@ -572,7 +637,6 @@ function Set-TargetResource throw [Exception] ("A known issue prevents installation of SharePoint 2013 on " + ` "servers that have .NET 4.6 already installed. See details " + ` "at https://support.microsoft.com/en-us/kb/3087184") - return } } @@ -583,15 +647,23 @@ function Set-TargetResource } elseif ($majorVersion -eq 16) { - if($buildVersion -lt 5000) + if ($buildVersion -lt 5000) { Write-Verbose -Message "Version: SharePoint 2016" $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","KB3092423", "WCFDataServices56","DotNetFx","MSVCRT11","MSVCRT14","ODBC") if ($osVersion.Major -eq 10) { - # Server 2016 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features + if ($osVersion.Build -lt 17763) + { + # Server 2016 + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win16Features + } + else + { + # Server 2019 + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2016Win19Features + } } elseif ($osVersion.Major -eq 6 -and $osVersion.Minor -eq 3) { @@ -604,21 +676,24 @@ function Set-TargetResource } } # SharePoint 2019 - elseif($buildVersion -ge 5000) + elseif ($buildVersion -ge 5000) { Write-Verbose -Message "Version: SharePoint 2019" $requiredParams = @("SQLNCli","Sync","AppFabric","IDFX11","MSIPCClient","KB3092423", "WCFDataServices56","DotNet472","MSVCRT11","MSVCRT141") - if ($osVersion.Major -eq 11) - { - # Server 2019 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win19Features - } - elseif ($osVersion.Major -eq 10) + if ($osVersion.Major -eq 10) { - # Server 2016 - $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win16Features + if ($osVersion.Build -lt 17763) + { + # Server 2016 + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win16Features + } + else + { + # Server 2019 + $WindowsFeatures = Get-WindowsFeature -Name $Script:SP2019Win19Features + } } else { @@ -666,7 +741,7 @@ function Set-TargetResource { throw "In offline mode for version $majorVersion parameter $_ is required" } - if ((Test-Path $PSBoundParameters.$_) -eq $false) + if ((Test-Path -Path $PSBoundParameters.$_) -eq $false) { throw ("The $_ parameter has been passed but the file cannot be found at the " + ` "path supplied: `"$($PSBoundParameters.$_)`"") @@ -722,8 +797,8 @@ function Set-TargetResource "Auto Update\RebootRequired" $rebootTest2 = Get-Item -Path $rebootKey2 -ErrorAction SilentlyContinue - $sessionManagerKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" - $sessionManager = Get-Item -Path $sessionManagerKey | Get-ItemProperty + $sessionManagerKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" + $sessionManager = Get-Item -Path $sessionManagerKey | Get-ItemProperty $pendingFileRenames = $sessionManager.PendingFileRenameOperations.Count if (($null -ne $rebootTest1) -or ($null -ne $rebootTest2) -or ($pendingFileRenames -gt 0)) @@ -845,13 +920,13 @@ function Test-TargetResource { throw [Exception] ("SharePointDsc does not support uninstalling SharePoint or its " + ` "prerequisites. Please remove this manually.") - return } $CurrentValues = Get-TargetResource @PSBoundParameters return Test-SPDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure") + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("Ensure") } function Test-SPDscPrereqInstallStatus @@ -929,7 +1004,7 @@ function Test-SPDscPrereqInstallStatus [int[]]$installedVersion = $installedItem.DisplayVersion.Split('.') for ([int]$index = 0; $index -lt $minimumRequiredVersion.Length -and $index -lt $installedVersion.Length; $index++) { - if($minimumRequiredVersion[$index] -gt $installedVersion[$index]) + if ($minimumRequiredVersion[$index] -gt $installedVersion[$index]) { $isRequiredVersionInstalled = $false; } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 index 498449585..2eb7cbef0 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 @@ -33,6 +33,7 @@ function Get-TargetResource $nonCompliantServices = Get-SPService | Where-Object -FilterScript { $_.CompliantWithMinRole -eq $false } + $params = $args[0]; if ($null -eq $nonCompliantServices) { diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 index 9b7da8150..4f467c69b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 @@ -66,7 +66,7 @@ function Get-TargetResource return Get-SPDscFarmProductsInfo } - if ($setupFileInfo.VersionInfo.FileDescription -match "Language Pack") + if ($setupFileInfo.VersionInfo.FileDescription -match "Service Pack.*Language Pack") { Write-Verbose -Message "Update is a Language Pack Service Pack." # Retrieve language from file and check version for that language pack. @@ -154,9 +154,7 @@ function Get-TargetResource # Check SharePoint version information. $servicepack = $true $versionInfo = Invoke-SPDSCCommand -Credential $InstallAccount ` - -Arguments $productName ` -ScriptBlock { - $productToCheck = $args[0] return Get-SPDscFarmVersionInfo -ProductToCheck "Microsoft SharePoint Server 2013" } } @@ -165,9 +163,7 @@ function Get-TargetResource Write-Verbose -Message "Update is a Cumulative Update." # Cumulative Update is multi-lingual. Check version information of all products. $versionInfo = Invoke-SPDSCCommand -Credential $InstallAccount ` - -Arguments $productName ` -ScriptBlock { - $productToCheck = $args[0] return Get-SPDscFarmVersionInfo } } @@ -327,7 +323,7 @@ function Set-TargetResource # To prevent an endless loop: Check if an upgrade is required. $installedVersion = Get-SPDSCInstalledProductVersion - if ($spVersion.FileMajorPart -eq 15) + if ($installedVersion.FileMajorPart -eq 15) { $wssRegKey ="hklm:SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\WSS" } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 index 5c5f13c20..52ef31624 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 @@ -122,10 +122,11 @@ function Get-TargetResource $adGroup = Convert-SPDscADGroupIDToName -GroupId $script:groupDataSet.SecurityGroups.WSEC_GRP_AD_GUID } + $groupMembers = @() + if ($adGroup -eq "") { # No AD group is set, check for individual members - $groupMembers = @() $script:groupDataSet.GroupMembers.Rows | ForEach-Object -Process { $groupMembers += Get-SPDscProjectServerResourceName -ResourceId $_["RES_UID"] -PwaUrl $params.Url } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 index 121440ca4..542ac3812 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 @@ -46,7 +46,7 @@ function Get-TargetResource Action = $params.Action Ensure = "Absent" InstallAccount = $params.InstallAccount - } + } $serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName if($null -eq $serviceApp) @@ -67,9 +67,9 @@ function Get-TargetResource { return $nullReturn } - else + else { - + return @{ ServiceAppName = $params.ServiceAppName Path = $params.Path @@ -80,7 +80,7 @@ function Get-TargetResource } } } - else + else { $queryDemoted = $serviceApp | Get-SPEnterpriseSearchQueryDemoted -Identity $params.Path ` -Owner $searchOwner ` @@ -90,7 +90,7 @@ function Get-TargetResource { return $nullReturn } - else + else { return @{ ServiceAppName = $params.ServiceAppName @@ -104,7 +104,7 @@ function Get-TargetResource } return $result - + } @@ -140,7 +140,7 @@ function Set-TargetResource [System.Management.Automation.PSCredential] $InstallAccount ) - + Write-Verbose -Message "Setting Authoratative Page Settings for '$Path'" $CurrentResults = Get-TargetResource @PSBoundParameters @@ -155,7 +155,7 @@ function Set-TargetResource $serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName $searchObjectLevel = [Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::Ssa $searchOwner = New-Object -TypeName "Microsoft.Office.Server.Search.Administration.SearchObjectOwner" -ArgumentList $searchObjectLevel - + if($null -eq $serviceApp) { throw "Search Service App was not available." @@ -167,13 +167,13 @@ function Set-TargetResource -Owner $searchOwner ` -Level $params.Level } - else + else { New-SPEnterpriseSearchQueryDemoted -Url $params.Path -SearchApplication $serviceApp -Owner $searchOwner } } } - if($CurrentResults.Ensure -eq "Present" -and $Ensure -eq "Present") + if($CurrentResults.Ensure -eq "Present" -and $Ensure -eq "Present") { $result = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` @@ -192,7 +192,7 @@ function Set-TargetResource if($params.Action -eq "Authoratative") { Set-SPEnterpriseSearchQueryAuthority -Identity $params.ServiceAppName ` - -SearchApplication $ssa ` + -SearchApplication $serviceApp ` -Owner $searchOwner ` -Level $params.Level } @@ -216,14 +216,14 @@ function Set-TargetResource if($params.Action -eq "Authoratative") { Remove-SPEnterpriseSearchQueryAuthority -Identity $params.ServiceAppName ` - -SearchApplication $ssa ` + -SearchApplication $serviceApp ` -Owner $searchOwner ` -ErrorAction SilentlyContinue } - else + else { Remove-SPEnterpriseSearchQueryDemoted -Identity $params.ServiceAppName ` - -SearchApplication $ssa ` + -SearchApplication $serviceApp ` -Owner $searchOwner ` -ErrorAction SilentlyContinue } @@ -245,7 +245,7 @@ function Test-TargetResource [Parameter(Mandatory = $true)] [System.String] $Path, - + [Parameter()] [ValidateRange(0.0, 2.0)] [System.Single] @@ -280,7 +280,7 @@ function Test-TargetResource -ValuesToCheck @("ServiceAppName", "Path", "Level", - "Action", + "Action", "Ensure") } else @@ -289,7 +289,7 @@ function Test-TargetResource -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", "Path", - "Action", + "Action", "Ensure") } } @@ -298,7 +298,7 @@ function Test-TargetResource return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", - "Action", + "Action", "Ensure") } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 index 4063bdafd..dd600e971 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 @@ -4,33 +4,33 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $FileType, - - [Parameter(Mandatory = $true)] - [System.String] + + [Parameter(Mandatory = $true)] + [System.String] $ServiceAppName, - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Description, - [Parameter()] - [System.String] + [Parameter()] + [System.String] $MimeType, - - [Parameter()] - [System.Boolean] + + [Parameter()] + [System.Boolean] $Enabled, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.Management.Automation.PSCredential] + + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -42,10 +42,9 @@ function Get-TargetResource { Write-Verbose -Message "Ensure is configured as Present, but MimeType and/or Description is missing" $nullReturn = @{ - FileType = $params.FileType - ServiceAppName = $params.ServiceAppName + FileType = $FileType + ServiceAppName = $ServiceAppName Ensure = "Absent" - InstallAccount = $params.InstallAccount } return $nullReturn } @@ -57,42 +56,42 @@ function Get-TargetResource $serviceApps = Get-SPServiceApplication -Name $params.ServiceAppName ` -ErrorAction SilentlyContinue - + $nullReturn = @{ FileType = $params.FileType ServiceAppName = $params.ServiceAppName Ensure = "Absent" InstallAccount = $params.InstallAccount } - - if ($null -eq $serviceApps) + + if ($null -eq $serviceApps) { Write-Verbose -Message "Service Application $($params.ServiceAppName) is not found" - return $nullReturn + return $nullReturn } - + $serviceApp = $serviceApps | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" + $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" } - if ($null -eq $serviceApp) + if ($null -eq $serviceApp) { Write-Verbose -Message "Service Application $($params.ServiceAppName) is not a search service application" return $nullReturn - } - else + } + else { $fileType = Get-SPEnterpriseSearchFileFormat ` -SearchApplication $params.ServiceAppName | Where-Object -FilterScript { $_.Identity -eq $params.FileType } - if ($null -eq $fileType) + if ($null -eq $fileType) { Write-Verbose -Message "File Type $($params.FileType) not found" return $nullReturn - } - else + } + else { $returnVal = @{ FileType = $params.FileType @@ -102,7 +101,7 @@ function Get-TargetResource Enabled = $fileType.Enabled Ensure = "Present" InstallAccount = $params.InstallAccount - } + } return $returnVal } @@ -116,38 +115,38 @@ function Set-TargetResource [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $FileType, - - [Parameter(Mandatory = $true)] - [System.String] + + [Parameter(Mandatory = $true)] + [System.String] $ServiceAppName, - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Description, - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $MimeType, - - [Parameter()] - [System.Boolean] + + [Parameter()] + [System.Boolean] $Enabled, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.Management.Automation.PSCredential] + + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Setting Search File Type '$FileType'" - + if ($Ensure -eq "Present" -and ` (-not($PSBoundParameters.ContainsKey("MimeType")) -or ` -not($PSBoundParameters.ContainsKey("Description")))) @@ -156,7 +155,7 @@ function Set-TargetResource } $PSBoundParameters.Ensure = $Ensure - + $result = Get-TargetResource @PSBoundParameters Write-Verbose -Message "Checking if Service Application '$ServiceAppName' exists" @@ -167,40 +166,40 @@ function Set-TargetResource $serviceApps = Get-SPServiceApplication -Name $params.ServiceAppName ` -ErrorAction SilentlyContinue - - if ($null -eq $serviceApps) + + if ($null -eq $serviceApps) { throw "Service Application $($params.ServiceAppName) is not found" } - + $serviceApp = $serviceApps | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" + $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" } - if ($null -eq $serviceApp) + if ($null -eq $serviceApp) { throw "Service Application $($params.ServiceAppName) is not a search service application" - } + } } - if ($result.Ensure -eq "Absent" -and $Ensure -eq "Present") + if ($result.Ensure -eq "Absent" -and $Ensure -eq "Present") { Write-Verbose -Message "Creating File Type $FileType" Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - + $newParams = @{ FormatId = $params.FileType SearchApplication = $params.ServiceAppName - FormatName = $params.Description - MimeType = $params.MimeType + FormatName = $params.Description + MimeType = $params.MimeType } - + New-SPEnterpriseSearchFileFormat @newParams - if ($params.ContainsKey("Enabled") -eq $true) + if ($params.ContainsKey("Enabled") -eq $true) { $stateParams = @{ Identity = $params.FileType @@ -212,18 +211,18 @@ function Set-TargetResource } } - if ($result.Ensure -eq "Present" -and $Ensure -eq "Present") + if ($result.Ensure -eq "Present" -and $Ensure -eq "Present") { Write-Verbose -Message "Updating File Type $FileType" Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - + $fileType = Get-SPEnterpriseSearchFileFormat ` -SearchApplication $params.ServiceAppName | Where-Object -FilterScript { $_.Identity -eq $params.FileType } - if ($null -ne $fileType) + if ($null -ne $fileType) { if (($fileType.MimeType -ne $params.MimeType) -or ($fileType.Name -ne $params.Description)) @@ -238,7 +237,7 @@ function Set-TargetResource FormatName = $params.Description MimeType = $params.MimeType } - + New-SPEnterpriseSearchFileFormat @newParams } @@ -258,15 +257,15 @@ function Set-TargetResource } } } - - if ($Ensure -eq "Absent") + + if ($Ensure -eq "Absent") { Write-Verbose -Message "Removing Crawl Rule $Path" Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - + Remove-SPEnterpriseSearchFileFormat -Identity $params.FileType ` -SearchApplication $params.ServiceAppName ` -Confirm:$false @@ -280,33 +279,33 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $FileType, - - [Parameter(Mandatory = $true)] - [System.String] + + [Parameter(Mandatory = $true)] + [System.String] $ServiceAppName, - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $Description, - - [Parameter()] - [System.String] + + [Parameter()] + [System.String] $MimeType, - - [Parameter()] - [System.Boolean] + + [Parameter()] + [System.Boolean] $Enabled, - - [Parameter()] - [ValidateSet("Present","Absent")] - [System.String] + + [Parameter()] + [ValidateSet("Present","Absent")] + [System.String] $Ensure = "Present", - - [Parameter()] - [System.Management.Automation.PSCredential] + + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -315,10 +314,10 @@ function Test-TargetResource $PSBoundParameters.Ensure = $Ensure $CurrentValues = Get-TargetResource @PSBoundParameters - - if ($Ensure -eq "Present") + + if ($Ensure -eq "Present") { - if ($PSBoundParameters.ContainsKey("Enabled") -eq $true) + if ($PSBoundParameters.ContainsKey("Enabled") -eq $true) { if ($Enabled -ne $CurrentValues.Enabled) { @@ -328,9 +327,9 @@ function Test-TargetResource return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("Ensure", - "Description", - "MimeType") + -ValuesToCheck @("Ensure", + "Description", + "MimeType") } else { diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 index a0b61ad70..8aa58b5c5 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 @@ -4,22 +4,22 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [Parameter(Mandatory = $true)] - [System.UInt32] + [Parameter(Mandatory = $true)] + [System.UInt32] $Index, - - [Parameter(Mandatory = $true)] - [System.String[]] + + [Parameter(Mandatory = $true)] + [System.String[]] $Servers, - - [Parameter()] + + [Parameter()] [System.String] $RootDirectory, - + [Parameter(Mandatory = $true)] [System.String] $ServiceAppName, - + [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount @@ -33,15 +33,15 @@ function Get-TargetResource $params = $args[0] $ConfirmPreference = 'None' - $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName + $ssa = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName $currentTopology = $ssa.ActiveTopology - + $searchComponent = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology | ` Where-Object -FilterScript { ($_.GetType().Name -eq "IndexComponent") ` - -and ($_.IndexPartitionOrdinal -eq $params.Index) + -and ($_.IndexPartitionOrdinal -eq $params.Index) } - + $IndexComponents = $searchComponent.ServerName $rootDirectory = $searchComponent.RootDirectory @@ -68,22 +68,22 @@ function Set-TargetResource [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [System.UInt32] + [Parameter(Mandatory = $true)] + [System.UInt32] $Index, - - [Parameter(Mandatory = $true)] - [System.String[]] + + [Parameter(Mandatory = $true)] + [System.String[]] $Servers, - - [Parameter()] + + [Parameter()] [System.String] $RootDirectory, - + [Parameter(Mandatory = $true)] [System.String] $ServiceAppName, - + [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount @@ -103,10 +103,10 @@ function Set-TargetResource $AllSearchServers = $params.Servers # Ensure the search service instance is running on all servers - foreach($searchServer in $AllSearchServers) + foreach($searchServer in $AllSearchServers) { $searchService = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer - if($searchService.Status -eq "Offline") + if($searchService.Status -eq "Offline") { Write-Verbose -Message "Start Search Service Instance" Start-SPEnterpriseSearchServiceInstance -Identity $searchService @@ -114,36 +114,36 @@ function Set-TargetResource #Wait for Search Service Instance to come online $loopCount = 0 - $online = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer - do + $online = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer + do { - $online = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer + $online = Get-SPEnterpriseSearchServiceInstance -Identity $searchServer Write-Verbose -Message "Waiting for service: $($online.TypeName)" $loopCount++ Start-Sleep -Seconds 30 - } + } until ($online.Status -eq "Online" -or $loopCount -eq 20) } - if ($params.ContainsKey("RootDirectory") -eq $true) + if ($params.ContainsKey("RootDirectory") -eq $true) { # Create the index partition directory on each remote server - foreach($IndexPartitionServer in $params.Servers) + foreach($IndexPartitionServer in $params.Servers) { $networkPath = "\\$IndexPartitionServer\" + $params.RootDirectory.Replace(":\", "$\") New-Item -Path $networkPath -ItemType Directory -Force } # Create the directory on the local server as it will not apply the topology without it - if ((Test-Path -Path $params.RootDirectory) -eq $false) + if ((Test-Path -Path $params.RootDirectory) -eq $false) { New-Item $params.RootDirectory -ItemType Directory -Force } } - + # Get all service service instances to assign topology components to $AllSearchServiceInstances = @{} - foreach ($server in $AllSearchServers) + foreach ($server in $AllSearchServers) { $si = Get-SPEnterpriseSearchServiceInstance -Identity $server $AllSearchServiceInstances.Add($server, $si) @@ -164,44 +164,44 @@ function Set-TargetResource @("Servers") | ForEach-Object -Process { $CurrentSearchProperty = $_ Write-Verbose -Message "Setting components for '$CurrentSearchProperty' property" + $ComponentsToRemove = @() - if ($null -eq $CurrentValues.$CurrentSearchProperty) + if ($null -eq $CurrentValues.$CurrentSearchProperty) { $ComponentsToAdd = $params.$CurrentSearchProperty - } - else + } + else { $ComponentsToAdd = @() - $ComponentsToRemove = @() $components = $params.$CurrentSearchProperty | Where-Object -FilterScript { - $CurrentValues.$CurrentSearchProperty.Contains($_) -eq $false + $CurrentValues.$CurrentSearchProperty.Contains($_) -eq $false } - foreach($component in $components) + foreach($component in $components) { $ComponentsToAdd += $component } $components = $CurrentValues.$CurrentSearchProperty | Where-Object -FilterScript { - $params.$CurrentSearchProperty.Contains($_) -eq $false + $params.$CurrentSearchProperty.Contains($_) -eq $false } - foreach($component in $components) + foreach($component in $components) { $ComponentsToRemove += $component } } - foreach($componentToAdd in $ComponentsToAdd) + foreach($componentToAdd in $ComponentsToAdd) { $NewComponentParams = @{ SearchTopology = $newTopology SearchServiceInstance = $AllSearchServiceInstances.$componentToAdd } - switch($componentTypes.$CurrentSearchProperty) + switch($componentTypes.$CurrentSearchProperty) { "IndexComponent" { $NewComponentParams.Add("IndexPartition", $params.Index) - if ($params.ContainsKey("RootDirectory") -eq $true) + if ($params.ContainsKey("RootDirectory") -eq $true) { - if ([string]::IsNullOrEmpty($params.RootDirectory) -eq $false) + if ([string]::IsNullOrEmpty($params.RootDirectory) -eq $false) { $NewComponentParams.Add("RootDirectory", $params.RootDirectory) } @@ -210,7 +210,7 @@ function Set-TargetResource } } } - foreach($componentToRemove in $ComponentsToRemove) + foreach($componentToRemove in $ComponentsToRemove) { $component = Get-SPEnterpriseSearchComponent -SearchTopology $newTopology | ` Where-Object -FilterScript { @@ -218,12 +218,12 @@ function Set-TargetResource -and ($_.ServerName -eq $componentToRemove) ` -and ($_.IndexPartitionOrdinal -eq $params.Index) } - if ($null -ne $component) + if ($null -ne $component) { $component | Remove-SPEnterpriseSearchComponent -SearchTopology $newTopology ` -Confirm:$false } - + } } @@ -238,22 +238,22 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [Parameter(Mandatory = $true)] - [System.UInt32] + [Parameter(Mandatory = $true)] + [System.UInt32] $Index, - - [Parameter(Mandatory = $true)] - [System.String[]] + + [Parameter(Mandatory = $true)] + [System.String[]] $Servers, - - [Parameter()] + + [Parameter()] [System.String] $RootDirectory, - + [Parameter(Mandatory = $true)] [System.String] $ServiceAppName, - + [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 index dd05b3f56..6cc1bd9ce 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 @@ -28,12 +28,6 @@ function Get-TargetResource $Query, [Parameter(Mandatory = $true)] - [ValidateSet("Exchange Search Provider", - "Local People Provider", - "Local SharePoint Provider", - "OpenSearch Provider", - "Remote People Provider", - "Remote SharePoint Provider")] [System.String] $ProviderType, @@ -71,8 +65,22 @@ function Get-TargetResource InstallAccount = $params.InstallAccount } $serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity $params.SearchServiceAppName + if ($null -eq $serviceApp) + { + Write-Verbose -Message ("Specified Search service application $($params.SearchServiceAppName)" + ` + "does not exist.") + return $nullReturn + } $fedManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($serviceApp) + $providers = $fedManager.ListProviders() + if ($providers.Keys -notcontains $params.ProviderType) + { + Write-Verbose -Message ("Unknown ProviderType ($($params.ProviderType)) is used. Allowed " + ` + "values are: '" + ($providers.Keys -join "', '") + "'") + return $nullReturn + } + $searchOwner = $null if ("ssa" -eq $params.ScopeName.ToLower()) { @@ -144,12 +152,6 @@ function Set-TargetResource $Query, [Parameter(Mandatory = $true)] - [ValidateSet("Exchange Search Provider", - "Local People Provider", - "Local SharePoint Provider", - "OpenSearch Provider", - "Remote People Provider", - "Remote SharePoint Provider")] [System.String] $ProviderType, @@ -182,15 +184,27 @@ function Set-TargetResource $serviceApp = Get-SPEnterpriseSearchServiceApplication ` -Identity $params.SearchServiceAppName - + if ($null -eq $serviceApp) + { + throw ("Specified Search service application $($params.SearchServiceAppName)" + ` + "does not exist.") + } $fedManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($serviceApp) + $providers = $fedManager.ListProviders() + if ($providers.Keys -notcontains $params.ProviderType) + { + throw ("Unknown ProviderType ($($params.ProviderType)) is used. Allowed " + ` + "values are: '" + ($providers.Keys -join "', '") + "'") + } + $searchOwner = $null if ("ssa" -eq $params.ScopeName.ToLower()) { $searchOwner = Get-SPEnterpriseSearchOwner -Level SSA } - else { + else + { $searchOwner = Get-SPEnterpriseSearchOwner -Level $params.ScopeName -SPWeb $params.ScopeUrl } @@ -229,7 +243,8 @@ function Set-TargetResource { $searchOwner = Get-SPEnterpriseSearchOwner -Level SSA } - else { + else + { $searchOwner = Get-SPEnterpriseSearchOwner -Level $params.ScopeName -SPWeb $params.ScopeUrl } @@ -272,12 +287,6 @@ function Test-TargetResource $Query, [Parameter(Mandatory = $true)] - [ValidateSet("Exchange Search Provider", - "Local People Provider", - "Local SharePoint Provider", - "OpenSearch Provider", - "Remote People Provider", - "Remote SharePoint Provider")] [System.String] $ProviderType, diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.schema.mof index 8407cba5b..ad46ff438 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.schema.mof @@ -6,7 +6,7 @@ class MSFT_SPSearchResultSource : OMI_BaseResource [Key, Description("The URI of the site where to create the result source. Leave empty to have it created globally")] String ScopeUrl; [Required, Description("The name of the search service application to associate this result source with")] String SearchServiceAppName; [Required, Description("The query to pass to the provider source")] String Query; - [Required, Description("The provider type to use for the result source"), ValueMap{"Exchange Search Provider","Local People Provider","Local SharePoint Provider","OpenSearch Provider","Remote People Provider","Remote SharePoint Provider"}, Values{"Exchange Search Provider","Local People Provider","Local SharePoint Provider","OpenSearch Provider","Remote People Provider","Remote SharePoint Provider"}] String ProviderType; + [Required, Description("The provider type to use for the result source")] String ProviderType; [Write, Description("The URI to connect to the remote location")] String ConnectionUrl; [Write, Description("Present if the result source should exist, absent if it should not"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/readme.md index 3c82606dc..28fa3579c 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/readme.md @@ -14,8 +14,23 @@ following provider types: * Remote People Provider * Remote SharePoint Provider +> **Important:** +> The above provider types are specific to the used localized version of SharePoint. +> Please make sure you use the correct localized values. Use the below script to +> check of all possible values. + The default value for the Ensure parameter is Present. When not specifying this parameter, the result source is created. To define a result source as global, use the value 'SSA' as the ScopeName value. + +## Script + +``` PowerShell +$serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity "SearchServiceAppName" + +$fedManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($serviceApp) +$providers = $fedManager.ListProviders() +$providers.Keys +``` diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 index 29a989135..fc886b115 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 @@ -123,6 +123,7 @@ function Get-TargetResource $cloudIndex = $serviceApp.CloudIndex } + $pName = $null; $serviceAppProxies = Get-SPServiceApplicationProxy -ErrorAction SilentlyContinue if ($null -ne $serviceAppProxies) { diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 index 7663a96dd..1ac8d603b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 @@ -243,15 +243,14 @@ function Set-TargetResource $params.Remove("DatabaseAuthenticationType") } - if ($params.ContainsKey("ProxyName")) + $pName = "$($params.Name) Proxy" + + if ($params.ContainsKey("ProxyName") -and $null -ne $params.ProxyName) { $pName = $params.ProxyName $params.Remove("ProxyName") | Out-Null } - if ($null -eq $pName) - { - $pName = "$($params.Name) Proxy" - } + New-SPSecureStoreServiceApplication @params | New-SPSecureStoreServiceApplicationProxy -Name $pName } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 index 4b586e396..42d55d67b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 @@ -4,58 +4,58 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, [Parameter()] [System.String] - [ValidateSet("Present","Absent")] + [ValidateSet("Present","Absent")] $Ensure = "Present", - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxies, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToInclude, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToExclude, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) - + Write-Verbose -Message "Getting Service Application Proxy Group $Name" if (($Ensure -eq "Present") ` -and $ServiceAppProxies ` - -and (($ServiceAppProxiesToInclude) -or ($ServiceAppProxiesToExclude))) + -and (($ServiceAppProxiesToInclude) -or ($ServiceAppProxiesToExclude))) { Write-Verbose -Message ("Cannot use the ServiceAppProxies parameter together " + ` "with the ServiceAppProxiesToInclude or " + ` "ServiceAppProxiesToExclude parameters") return $null } - + if (($Ensure -eq "Present") ` -and !$ServiceAppProxies ` -and !$ServiceAppProxiesToInclude ` - -and !$ServiceAppProxiesToExclude) + -and !$ServiceAppProxiesToExclude) { Write-Verbose -Message ("At least one of the following parameters must be specified: " + ` "ServiceAppProxies, ServiceAppProxiesToInclude, " + ` "ServiceAppProxiesToExclude") - return $null + return $null } - + $result = Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - + #Try to get the proxy group if ($params.Name -eq "Default") { @@ -63,29 +63,29 @@ function Get-TargetResource } else { - $ProxyGroup = Get-SPServiceApplicationProxyGroup $params.name -ErrorAction SilentlyContinue + $ProxyGroup = Get-SPServiceApplicationProxyGroup $params.Name -ErrorAction SilentlyContinue } - + if ($ProxyGroup) { $Ensure = "Present" } else { - $Ensure = "Absent" + $Ensure = "Absent" } - + $ServiceAppProxies = $ProxyGroup.Proxies.DisplayName - + return @{ Name = $params.name Ensure = $Ensure - ServiceAppProxies = $ServiceAppProxies - ServiceAppProxiesToInclude = $param.ServiceAppProxiesToInclude - ServiceAppProxiesToExclude = $param.ServiceAppProxiesToExclude + ServiceAppProxies = $ServiceAppProxies + ServiceAppProxiesToInclude = $params.ServiceAppProxiesToInclude + ServiceAppProxiesToExclude = $params.ServiceAppProxiesToExclude InstallAccount = $params.InstallAccount } - + } return $result } @@ -95,239 +95,239 @@ function Set-TargetResource [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, [Parameter()] [System.String] - [ValidateSet("Present","Absent")] + [ValidateSet("Present","Absent")] $Ensure = "Present", - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxies, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToInclude, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToExclude, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) - + Write-Verbose -Message "Setting Service Application Proxy Group $Name" - + if (($Ensure -eq "Present") ` -and $ServiceAppProxies ` - -and (($ServiceAppProxiesToInclude) -or ($ServiceAppProxiesToExclude))) + -and (($ServiceAppProxiesToInclude) -or ($ServiceAppProxiesToExclude))) { throw ("Cannot use the ServiceAppProxies parameter together " + ` "with the ServiceAppProxiesToInclude or " + ` "ServiceAppProxiesToExclude parameters") } - + if (($Ensure -eq "Present") ` -and !$ServiceAppProxies ` -and !$ServiceAppProxiesToInclude ` - -and !$ServiceAppProxiesToExclude) + -and !$ServiceAppProxiesToExclude) { throw ("At least one of the following parameters must be specified: " + ` "ServiceAppProxies, ServiceAppProxiesToInclude, " + ` - "ServiceAppProxiesToExclude") + "ServiceAppProxiesToExclude") } Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - + if ($params.Ensure -eq "Present") { - if ($params.Name -eq "Default") + if ($params.Name -eq "Default") { $ProxyGroup = Get-SPServiceApplicationProxyGroup -Default - } - else + } + else { $ProxyGroup = Get-SPServiceApplicationProxyGroup -Identity $params.Name ` - -ErrorAction SilentlyContinue - } - - if (!($ProxyGroup)) + -ErrorAction SilentlyContinue + } + + if (!($ProxyGroup)) { Write-Verbose -Message "Creating new Service Application Proxy Group $($params.Name)" $ProxyGroup = New-SPServiceApplicationProxyGroup -Name $params.Name } #Explicit Service Applications - if ($params.ServiceAppProxies) + if ($params.ServiceAppProxies) { - if ($ProxyGroup.Proxies.DisplayName) + if ($ProxyGroup.Proxies.DisplayName) { $differences = Compare-Object -ReferenceObject $ProxyGroup.Proxies.DisplayName ` -DifferenceObject $params.ServiceAppProxies - - if ($null -eq $Differences) + + if ($null -eq $Differences) { Write-Verbose -Message ("Service Proxy Group $($params.name) " + ` "membership matches desired state") } - else + else { - foreach ($difference in $differences) + foreach ($difference in $differences) { - if ($difference.SideIndicator -eq "=>") + if ($difference.SideIndicator -eq "=>") { $ServiceProxyName = $difference.InputObject $ServiceProxy = Get-SPServiceApplicationProxy | ` Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose -Message "Adding $ServiceProxyName to $($params.name) Proxy Group" $ProxyGroup | Add-SPServiceApplicationProxyGroupMember -Member $ServiceProxy - - } - elseif ($difference.SideIndicator -eq "<=") + + } + elseif ($difference.SideIndicator -eq "<=") { $ServiceProxyName = $difference.InputObject $ServiceProxy = Get-SPServiceApplicationProxy | ` Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose -Message "Removing $ServiceProxyName from $($params.name) Proxy Group" - $ProxyGroup | Remove-SPServiceApplicationProxyGroupMember -member $ServiceProxy + $ProxyGroup | Remove-SPServiceApplicationProxyGroupMember -member $ServiceProxy } } } } - else + else { - foreach ($ServiceProxyName in $params.ServiceAppProxies) + foreach ($ServiceProxyName in $params.ServiceAppProxies) { $ServiceProxy = Get-SPServiceApplicationProxy | Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose -Message "Adding $ServiceProxyName to $($params.name) Proxy Group" $ProxyGroup | Add-SPServiceApplicationProxyGroupMember -member $ServiceProxy } } } - - if ($params.ServiceAppProxiesToInclude) + + if ($params.ServiceAppProxiesToInclude) { - if ($ProxyGroup.Proxies.DisplayName) + if ($ProxyGroup.Proxies.DisplayName) { $differences = Compare-Object -ReferenceObject $ProxyGroup.Proxies.DisplayName ` - -DifferenceObject $params.ServiceAppProxiesToInclude - - if ($null -eq $Differences) + -DifferenceObject $params.ServiceAppProxiesToInclude + + if ($null -eq $Differences) { Write-Verbose -Message "Service Proxy Group $($params.name) Membership matches desired state" } - else + else { - foreach ($difference in $differences) + foreach ($difference in $differences) { - if ($difference.SideIndicator -eq "=>") + if ($difference.SideIndicator -eq "=>") { $ServiceProxyName = $difference.InputObject $ServiceProxy = Get-SPServiceApplicationProxy | ` Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose -Message "Adding $ServiceProxyName to $($params.name) Proxy Group" $ProxyGroup | Add-SPServiceApplicationProxyGroupMember -member $ServiceProxy - + } } } } - else + else { - foreach ($ServiceProxyName in $params.ServiceAppProxies) + foreach ($ServiceProxyName in $params.ServiceAppProxies) { $ServiceProxy = Get-SPServiceApplicationProxy | ` Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose "Adding $ServiceProxyName to $($params.name) Proxy Group" $ProxyGroup | Add-SPServiceApplicationProxyGroupMember -member $ServiceProxy } } } - - if ($params.ServiceAppProxiesToExclude) + + if ($params.ServiceAppProxiesToExclude) { - if ($ProxyGroup.Proxies.Displayname) + if ($ProxyGroup.Proxies.Displayname) { $differences = Compare-Object -ReferenceObject $ProxyGroup.Proxies.DisplayName ` -DifferenceObject $params.ServiceAppProxiesToExclude ` -IncludeEqual - - if ($null -eq $Differences) + + if ($null -eq $Differences) { throw "Error comparing ServiceAppProxiesToExclude for Service Proxy Group $($params.name)" } - else + else { - foreach ($difference in $differences) + foreach ($difference in $differences) { - if ($difference.SideIndicator -eq "==") + if ($difference.SideIndicator -eq "==") { $ServiceProxyName = $difference.InputObject $ServiceProxy = Get-SPServiceApplicationProxy | Where-Object -FilterScript { $_.DisplayName -eq $ServiceProxyName } - - if (!$ServiceProxy) + + if (!$ServiceProxy) { throw "Invalid Service Application Proxy $ServiceProxyName" } - + Write-Verbose -Message "Removing $ServiceProxyName to $($params.name) Proxy Group" - $ProxyGroup | Remove-SPServiceApplicationProxyGroupMember -member $ServiceProxy + $ProxyGroup | Remove-SPServiceApplicationProxyGroupMember -member $ServiceProxy } } } - } + } } } - else + else { Write-Verbose "Removing $($params.name) Proxy Group" $ProxyGroup | Remove-SPServiceApplicationProxyGroup -confirm:$false @@ -341,115 +341,115 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $Name, [Parameter()] [System.String] - [ValidateSet("Present","Absent")] + [ValidateSet("Present","Absent")] $Ensure = "Present", - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxies, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToInclude, - [Parameter()] - [System.String[]] + [Parameter()] + [System.String[]] $ServiceAppProxiesToExclude, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) - + Write-Verbose -Message "Testing Service Application Proxy Group $Name" - + $CurrentValues = Get-TargetResource @PSBoundParameters - if ($null -eq $CurrentValues) + if ($null -eq $CurrentValues) { - return $false + return $false } - - if ($CurrentValues.Ensure -ne $Ensure) + + if ($CurrentValues.Ensure -ne $Ensure) { return $false } - + if ($ServiceAppProxies) { Write-Verbose -Message "Testing ServiceAppProxies property for $Name Proxy Group" - - if (-not $CurrentValues.ServiceAppProxies) + + if (-not $CurrentValues.ServiceAppProxies) { - return $false + return $false } - + $differences = Compare-Object -ReferenceObject $CurrentValues.ServiceAppProxies ` -DifferenceObject $ServiceAppProxies - if ($null -eq $differences) + if ($null -eq $differences) { Write-Verbose -Message "ServiceAppProxies match" - } - else + } + else { Write-Verbose -Message "ServiceAppProxies do not match" return $false - } + } } - + if ($ServiceAppProxiesToInclude) { Write-Verbose -Message "Testing ServiceAppProxiesToInclude property for $Name Proxy Group" - - if (-not $CurrentValues.ServiceAppProxies) + + if (-not $CurrentValues.ServiceAppProxies) { - return $false + return $false } - + $differences = Compare-Object -ReferenceObject $CurrentValues.ServiceAppProxies ` -DifferenceObject $ServiceAppProxiesToInclude - if ($null -eq $differences) + if ($null -eq $differences) { Write-Verbose -Message "ServiceAppProxiesToInclude matches" - } - elseif ($differences.sideindicator -contains "=>") + } + elseif ($differences.sideindicator -contains "=>") { Write-Verbose -Message "ServiceAppProxiesToInclude does not match" return $false } } - + if ($ServiceAppProxiesToExclude) { Write-Verbose -Message "Testing ServiceAppProxiesToExclude property for $Name Proxy Group" - - if (-not $CurrentValues.ServiceAppProxies) + + if (-not $CurrentValues.ServiceAppProxies) { - return $true + return $true } - + $differences = Compare-Object -ReferenceObject $CurrentValues.ServiceAppProxies ` -DifferenceObject $ServiceAppProxiesToExclude ` -IncludeEqual - if ($null -eq $differences) + if ($null -eq $differences) { return $false - } - elseif ($differences.sideindicator -contains "==") + } + elseif ($differences.sideindicator -contains "==") { Write-Verbose -Message "ServiceAppProxiesToExclude does not match" return $false - } + } } - - return $true + + return $true } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 index 8839061a1..bd9914bab 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 @@ -49,14 +49,92 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] + Write-Verbose -Message "Getting Service Application $($params.ServiceAppName)" $serviceApp = Get-SPServiceApplication -Name $params.ServiceAppName + $nullReturn = @{ + ServiceAppName = "" + SecurityType = $params.SecurityType + InstallAccount = $params.InstallAccount + } + if ($null -eq $serviceApp) { - return @{ - ServiceAppName = "" - SecurityType = $params.SecurityType - InstallAccount = $params.InstallAccount + return $nullReturn + } + + Write-Verbose -Message "Checking if valid AccessLevels are used" + Write-Verbose -Message "Retrieving all available localized AccessLevels" + $availablePerms = New-Object System.Collections.ArrayList + $appSecurity = Get-SPServiceApplicationSecurity -Identity $serviceApp + foreach ($right in $appSecurity.NamedAccessRights) + { + if (-not $availablePerms.Contains($right.Name)) + { + $availablePerms.Add($right.Name) | Out-Null + } + } + + $appSecurity = Get-SPServiceApplicationSecurity -Identity $serviceApp -Admin + foreach ($right in $appSecurity.NamedAccessRights) + { + if (-not $availablePerms.Contains($right.Name)) + { + $availablePerms.Add($right.Name) | Out-Null + } + } + + if ($params.ContainsKey("Members") -eq $true) + { + Write-Verbose -Message "Checking AccessLevels in Members parameter" + foreach($member in $params.Members) + { + foreach ($accessLevel in $member.AccessLevels) + { + if ($availablePerms -notcontains $accessLevel) + { + Write-Verbose -Message ("Unknown AccessLevel is used ($accessLevel). " + ` + "Allowed values are '" + ` + ($availablePerms -join "', '") + "'") + return $nullReturn + } + } + } + } + + if ($params.ContainsKey("MembersToInclude") -eq $true) + { + Write-Verbose -Message "Checking AccessLevels in MembersToInclude parameter" + foreach($member in $params.MembersToInclude) + { + foreach ($accessLevel in $member.AccessLevels) + { + if ($availablePerms -notcontains $accessLevel) + { + Write-Verbose -Message ("Unknown AccessLevel is used ($accessLevel). " + ` + "Allowed values are '" + ` + ($availablePerms -join "', '") + "'") + return $nullReturn + } + } + } + } + + if ($params.ContainsKey("MembersToExclude") -eq $true) + { + Write-Verbose -Message "Checking AccessLevels in MembersToExclude parameter" + foreach($member in $params.MembersToExclude) + { + foreach ($accessLevel in $member.AccessLevels) + { + if ($availablePerms -notcontains $accessLevel) + { + Write-Verbose -Message ("Unknown AccessLevel is used ($accessLevel). " + ` + "Allowed values are '" + ` + ($availablePerms -join "', '") + "'") + return $nullReturn + } + } } } @@ -165,11 +243,6 @@ function Set-TargetResource $CurrentValues = Get-TargetResource @PSBoundParameters - if ([System.String]::IsNullOrEmpty($CurrentValues.ServiceAppName) -eq $true) - { - throw "Unable to locate service application $ServiceAppName" - } - Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments @($PSBoundParameters, $CurrentValues) ` -ScriptBlock { @@ -177,6 +250,64 @@ function Set-TargetResource $CurrentValues = $args[1] $serviceApp = Get-SPServiceApplication -Name $params.ServiceAppName + if ($null -eq $serviceApp) + { + throw "Unable to locate service application $($params.ServiceAppName)" + } + + Write-Verbose -Message "Checking if valid AccessLevels are used" + Write-Verbose -Message "Retrieving all available localized AccessLevels" + $availablePerms = New-Object System.Collections.ArrayList + $appSecurity = Get-SPServiceApplicationSecurity -Identity $serviceApp + foreach ($right in $appSecurity.NamedAccessRights) + { + if (-not $availablePerms.Contains($right.Name)) + { + $availablePerms.Add($right.Name) | Out-Null + } + } + + $appSecurity = Get-SPServiceApplicationSecurity -Identity $serviceApp -Admin + foreach ($right in $appSecurity.NamedAccessRights) + { + if (-not $availablePerms.Contains($right.Name)) + { + $availablePerms.Add($right.Name) | Out-Null + } + } + + if ($params.ContainsKey("Members") -eq $true) + { + Write-Verbose -Message "Checking AccessLevels in Members parameter" + foreach($member in $params.Members) + { + foreach ($accessLevel in $member.AccessLevels) + { + if ($availablePerms -notcontains $accessLevel) + { + throw ("Unknown AccessLevel is used ($accessLevel). Allowed values are " + ` + "'" + ($availablePerms -join "', '") + "'") + } + } + } + } + + if ($params.ContainsKey("MembersToInclude") -eq $true) + { + Write-Verbose -Message "Checking AccessLevels in MembersToInclude parameter" + foreach($member in $params.MembersToInclude) + { + foreach ($accessLevel in $member.AccessLevels) + { + if ($availablePerms -notcontains $accessLevel) + { + throw ("Unknown AccessLevel is used ($accessLevel). Allowed values are " + ` + "'" + ($availablePerms -join "', '") + "'") + } + } + } + } + switch ($params.SecurityType) { "Administrators" { @@ -391,9 +522,9 @@ function Test-TargetResource $result = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments @($PSBoundParameters, $CurrentValues, $PSScriptRoot) ` -ScriptBlock { - $params = $args[0] + $params = $args[0] $CurrentValues = $args[1] - $ScriptRoot = $args[2] + $ScriptRoot = $args[2] $relPath = "..\..\Modules\SharePointDsc.ServiceAppSecurity\SPServiceAppSecurity.psm1" Import-Module (Join-Path -Path $ScriptRoot -ChildPath $relPath -Resolve) diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.schema.mof index 5b60fe5f2..03e6bc77b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.schema.mof @@ -2,7 +2,7 @@ class MSFT_SPServiceAppSecurityEntry { [Required, Description("The username for the entry")] String Username; - [Required, Description("The access levels for the entry"), ValueMap{"Create Target Application", "Delete Target Application", "Manage Target Application", "All Target Applications", "Manage Profiles", "Manage Audiences", "Manage Permissions", "Retrieve People Data for Search Crawlers", "Manage Social Data", "Full Control", "Read (Diagnostics Pages Only)", "Read Access to Term Store", "Read and Restricted Write Access to Term Store","Full Access to Term Store"}, Values{"Create Target Application", "Delete Target Application", "Manage Target Application", "All Target Applications", "Manage Profiles", "Manage Audiences", "Manage Permissions", "Retrieve People Data for Search Crawlers", "Manage Social Data", "Full Control", "Read (Diagnostics Pages Only)", "Read Access to Term Store", "Read and Restricted Write Access to Term Store","Full Access to Term Store"}] String AccessLevels[]; + [Required, Description("The access levels for the entry")] String AccessLevels[]; }; [ClassVersion("1.0.0.0"), FriendlyName("SPServiceAppSecurity")] class MSFT_SPServiceAppSecurity : OMI_BaseResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/readme.md index 95d3c5e11..3201555aa 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/readme.md @@ -22,6 +22,13 @@ as the username. The token is case sensitive. ## Permission overview +> **Important** +> When using localized versions of Windows and/or SharePoint, it is possible +> that permissions levels are also in the local language. In that case, use +> the localized permissions levels. All possible values can be retrieved using +> the script at the bottom of this page. The below permissions are the English +> versions. + Available permissions for Administrators are Full Control except for these service applications: @@ -60,3 +67,15 @@ NOTE: Multiple permissions can be specified for each principal. Full Control will include all other permissions. It is not required to specify all available permissions if Full Control is specified. + +## Script + +``` PowerShell +$serviceApp = Get-SPServiceApplication -Name "ServiceAppName" + +$perms = Get-SPServiceApplicationSecurity -Identity $serviceApp +$perms.NamedAccessRights.Name + +$perms = Get-SPServiceApplicationSecurity -Identity $serviceApp -Admin +$perms.NamedAccessRights.Name +``` diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 index 80a6ca1a2..e8e972525 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 @@ -30,7 +30,7 @@ function Get-TargetResource $params = $args[0] $newName = $args[1] - $si = Get-SPServiceInstance -Server $env:COMPUTERNAME | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $env:COMPUTERNAME -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -40,7 +40,7 @@ function Get-TargetResource { $domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain $fqdn = "$($env:COMPUTERNAME).$domain" - $si = Get-SPServiceInstance -Server $fqdn | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $fqdn -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -108,7 +108,7 @@ function Set-TargetResource $params = $args[0] $newName = $args[1] - $si = Get-SPServiceInstance -Server $env:COMPUTERNAME | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $env:COMPUTERNAME -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -118,7 +118,7 @@ function Set-TargetResource { $domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain $fqdn = "$($env:COMPUTERNAME).$domain" - $si = Get-SPServiceInstance -Server $fqdn | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $fqdn -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -126,7 +126,7 @@ function Set-TargetResource } if ($null -eq $si) { - throw [Exception] "Unable to locate service application '$($params.Name)'" + throw [Exception] "Unable to locate service instance '$($params.Name)'" } Start-SPServiceInstance -Identity $si } @@ -139,7 +139,7 @@ function Set-TargetResource $params = $args[0] $newName = $args[1] - $si = Get-SPServiceInstance -Server $env:COMPUTERNAME | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $env:COMPUTERNAME -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -149,7 +149,7 @@ function Set-TargetResource { $domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain $fqdn = "$($env:COMPUTERNAME).$domain" - $si = Get-SPServiceInstance -Server $fqdn | Where-Object -FilterScript { + $si = Get-SPServiceInstance -Server $fqdn -All | Where-Object -FilterScript { $_.TypeName -eq $params.Name -or ` $_.TypeName -eq $newName -or ` $_.GetType().Name -eq $newName @@ -157,7 +157,7 @@ function Set-TargetResource } if ($null -eq $si) { - throw [Exception] "Unable to locate service application '$($params.Name)'" + throw [Exception] "Unable to locate service instance '$($params.Name)'" } Stop-SPServiceInstance -Identity $si } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 index 6fe4f238c..be63a6579 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 @@ -282,10 +282,12 @@ function Set-TargetResource if ($null -eq $site) { + Write-Verbose -Message ("Starting New-SPSite with the following parameters: " + ` + "$(Convert-SPDscHashtableToString $params)") $site = New-SPSite @params if ($CreateDefaultGroups -eq $true) { - $doCreateDefaultGroups = $true; + $doCreateDefaultGroups = $true } else @@ -335,6 +337,8 @@ function Set-TargetResource if ($newParams.Count -gt 1) { Write-Verbose -Message "Updating existing site collection" + Write-Verbose -Message ("Starting Set-SPSite with the following parameters: " + ` + "$(Convert-SPDscHashtableToString $newParams)") Set-SPSite @newParams } @@ -342,7 +346,7 @@ function Set-TargetResource { if ($CreateDefaultGroups -eq $true) { - $doCreateDefaultGroups = $true; + $doCreateDefaultGroups = $true } else { @@ -362,7 +366,7 @@ function Set-TargetResource if($null -eq $systemAccountSite.SecondaryContact) { - $secondaryOwnerLogin = $null; + $secondaryOwnerLogin = $null } else { @@ -463,10 +467,10 @@ function Test-TargetResource return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Url", - "QuotaTemplate", - "OwnerAlias", - "SecondaryOwnerAlias", - "AdministrationSiteType") + "QuotaTemplate", + "OwnerAlias", + "SecondaryOwnerAlias", + "AdministrationSiteType") } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 index b25b9bd33..0b7721031 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 @@ -304,14 +304,15 @@ function Get-ProviderRealmsStatus() } else { + $update = @{ } + $inclusion = @{ } + if ($includeRealms.Count -gt 0) { - $inclusion = @{ } $includeRealms.Keys | Where-Object { !$currentRealms.ContainsKey($_) -and $currentRealms[$_] -ne $includeRealms[$_] } | ForEach-Object { $inclusion.Add("$($_)", "$($includeRealms[$_])") } - $update = @{ } $includeRealms.Keys | Where-Object { $currentRealms.ContainsKey($_) -and $currentRealms[$_] -ne $includeRealms[$_] } | ForEach-Object { $update.Add("$($_)", "$($includeRealms[$_])") } @@ -327,9 +328,10 @@ function Get-ProviderRealmsStatus() $inclusion.Keys | ForEach-Object { $currentRealms.Add($_, $inclusion[$_]) } } + $exclusion = @{ } + if ($excludeRealms.Count -gt 0) { - $exclusion = @{ } $excludeRealms.Keys | Where-Object { $currentRealms.ContainsKey($_) -and $currentRealms[$_] -eq $excludeRealms[$_] diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 index d27b79024..d15d0b6e9 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 @@ -460,7 +460,7 @@ function Set-TargetResource $userProfileProperty = $userProfileSubType.Properties.GetPropertyByName($params.Name) - if ($null -ne $userProfileProperty ` + if ($null -ne $userProfileProperty -and $params.ContainsKey("Type") ` -and $userProfileProperty.CoreProperty.Type -ne $params.Type) { throw ("Can't change property type. Current Type is " + ` @@ -615,7 +615,7 @@ function Set-TargetResource if ($params.ContainsKey("PropertyMappings")) { - foreach ($propertyMapping in $PropertyMappings) + foreach ($propertyMapping in $params.PropertyMappings) { $syncConnection = $userProfileConfigManager.ConnectionManager[$propertyMapping.ConnectionName] @@ -630,7 +630,7 @@ function Set-TargetResource } if ($null -eq $currentMapping ` - -or ($currentMapping.DataSourcePropertyName -ne $params.MappingPropertyName) ` + -or ($currentMapping.DataSourcePropertyName -ne $propertyMapping.PropertyName) ` -or ($currentMapping.IsImport ` -and $propertyMapping.Direction -eq "Export") ) diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 index 6bb3d745a..fbcffe8c5 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 @@ -73,6 +73,12 @@ function Get-TargetResource Write-Verbose -Message "Getting user profile service application $Name" + if ($PSBoundParameters.ContainsKey("MySiteHostLocation") -eq $false) + { + Write-Verbose -Message ("You should also specify the MySiteHostLocation parameter. " + ` + "This will be required as of SharePointDsc v4.0") + } + $farmAccount = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { @@ -283,6 +289,12 @@ function Set-TargetResource Write-Verbose -Message "Setting user profile service application $Name" + if ($PSBoundParameters.ContainsKey("MySiteHostLocation") -eq $false) + { + Write-Verbose -Message ("You should also specify the MySiteHostLocation parameter. " + ` + "This will be required as of SharePointDsc v4.0") + } + if ($Ensure -eq "Present") { $farmAccount = Invoke-SPDSCCommand -Credential $InstallAccount ` @@ -390,15 +402,13 @@ function Set-TargetResource -oldName "SyncDBServer" ` -newName "ProfileSyncDBServer" - if ($params.ContainsKey("ProxyName")) + $pName = "$($params.Name) Proxy" + + if ($params.ContainsKey("ProxyName") -and $null -ne $params.ProxyName) { $pName = $params.ProxyName $params.Remove("ProxyName") | Out-Null } - if ($null -eq $pName) - { - $pName = "$($params.Name) Proxy" - } $serviceApps = Get-SPServiceApplication -Name $params.Name ` -ErrorAction SilentlyContinue @@ -573,6 +583,12 @@ function Test-TargetResource Write-Verbose -Message "Testing for user profile service application $Name" + if ($PSBoundParameters.ContainsKey("MySiteHostLocation") -eq $false) + { + Write-Verbose -Message ("You should also specify the MySiteHostLocation parameter. " + ` + "This will be required as of SharePointDsc v4.0") + } + $PSBoundParameters.Ensure = $Ensure $CurrentValues = Get-TargetResource @PSBoundParameters diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/readme.md index a9b6d86ad..d3c04d12b 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/readme.md @@ -31,3 +31,7 @@ retrieve the Farm account from the Managed Accounts. This does however mean that CredSSP is required, which has some security implications. More information about these risks can be found at: http://www.powershellmagazine.com/2014/03/06/accidental-sabotage-beware-of-credssp/ + +NOTE2: +You should always specify the MySiteHostLocation parameter. Currently this is not +a required parameter, but will be as of SharePointDsc v4.0. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 index 900cf84c5..e75aa8105 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 @@ -161,10 +161,10 @@ function Get-TargetResource return @{ Name = $params.Name UserProfileService = $params.UserProfileService - Forest = $namingContexts.DistinguishedName + Forest = $namingContexts.DistinguishedName.Replace(",DC=", ".").Replace("DC=", ""); ConnectionCredentials = $accountCredentials - IncludedOUs = ,$inclOUs - ExcludedOUs = ,$exclOUs + IncludedOUs = $inclOUs + ExcludedOUs = $exclOUs Server = $null Port = $params.Port UseSSL = $useSSL @@ -201,8 +201,8 @@ function Get-TargetResource Forest = $connection.Server Name = $params.Name ConnectionCredentials = $accountCredentials - IncludedOUs = ,$inclOUs - ExcludedOUs = ,$exclOUs + IncludedOUs = $inclOUs + ExcludedOUs = $exclOUs Server = $domainController UseSSL = $connection.UseSSL UseDisabledFilter = $connection.UseDisabledFilter @@ -299,6 +299,8 @@ function Set-TargetResource } } + $installedVersion = Get-SPDSCInstalledProductVersion + if ($PSBoundParameters.ContainsKey("Port") -eq $false) { $PSBoundParameters.Port = $Port @@ -403,63 +405,6 @@ function Set-TargetResource else { Write-Verbose -Message "Creating a new connection " - if ($null -ne $connection -and $params.Forest -ine $connection.Server) - { - if ($params.ContainsKey("Force") -and $params.Force -eq $true) - { - Write-Verbose -Message "Force specified, deleting already existing connection" - $connection.Delete() - } - else - { - throw "connection exists and forest is different. use force" - } - - } - - $servers = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" - if ($params.ContainsKey("Server")) - { - $servers.add($params.Server) - } - $listIncludedOUs = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" - $params.IncludedOUs | ForEach-Object -Process { - $listIncludedOUs.Add($_) - } - - $listExcludedOUs = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" - if ($params.ContainsKey("ExcludedOus")) - { - $params.ExcludedOus | ForEach-Object -Process { - $listExcludedOUs.Add($_) - } - } - $list = New-Object -TypeName System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]] - - $partition = Get-SPDSCADSIObject -LdapPath ("LDAP://" +("DC=" + $params.Forest.Replace(".", ",DC="))) - $list.Add((New-Object -TypeName "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext" ` - -ArgumentList @( - $partition.distinguishedName, - $params.Forest, - $false, - (New-Object -TypeName "System.Guid" ` - -ArgumentList $partition.objectGUID), - $listIncludedOUs, - $listExcludedOUs, - $null , - $false))) - $partition = Get-SPDSCADSIObject -LdapPath ("LDAP://CN=Configuration," + ("DC=" + $params.Forest.Replace(".", ",DC="))) - $list.Add((New-Object -TypeName "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext" ` - -ArgumentList @( - $partition.distinguishedName, - $params.Forest, - $true, - (New-Object -TypeName "System.Guid" ` - -ArgumentList $partition.objectGUID), - $listIncludedOUs , - $listExcludedOUs , - $null , - $false))) $userDomain = $params.ConnectionCredentials.UserName.Split("\")[0] $userName= $params.ConnectionCredentials.UserName.Split("\")[1] @@ -470,6 +415,64 @@ function Set-TargetResource { 15 { + if ($null -ne $connection -and $params.Forest -ine $connection.Server) + { + if ($params.ContainsKey("Force") -and $params.Force -eq $true) + { + Write-Verbose -Message "Force specified, deleting already existing connection" + $connection.Delete() + } + else + { + throw "connection exists and forest is different. use force" + } + } + + $servers = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" + if ($params.ContainsKey("Server")) + { + $servers.add($params.Server) + } + $listIncludedOUs = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" + $params.IncludedOUs | ForEach-Object -Process { + $listIncludedOUs.Add($_) + } + + $listExcludedOUs = New-Object -TypeName "System.Collections.Generic.List[[System.String]]" + if ($params.ContainsKey("ExcludedOus")) + { + $params.ExcludedOus | ForEach-Object -Process { + $listExcludedOUs.Add($_) + } + } + + $list = New-Object -TypeName System.Collections.Generic.List[[Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext]] + + $partition = Get-SPDSCADSIObject -LdapPath ("LDAP://" +("DC=" + $params.Forest.Replace(".", ",DC="))) + $list.Add((New-Object -TypeName "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext" ` + -ArgumentList @( + $partition.distinguishedName, + $params.Forest, + $false, + (New-Object -TypeName "System.Guid" ` + -ArgumentList $partition.objectGUID), + $listIncludedOUs, + $listExcludedOUs, + $null , + $false))) + $partition = Get-SPDSCADSIObject -LdapPath ("LDAP://CN=Configuration," + ("DC=" + $params.Forest.Replace(".", ",DC="))) + $list.Add((New-Object -TypeName "Microsoft.Office.Server.UserProfiles.DirectoryServiceNamingContext" ` + -ArgumentList @( + $partition.distinguishedName, + $params.Forest, + $true, + (New-Object -TypeName "System.Guid" ` + -ArgumentList $partition.objectGUID), + $listIncludedOUs , + $listExcludedOUs , + $null , + $false))) + Write-Verbose -Message "Creating the new connection via object model (SP2013)" $upcm.ConnectionManager.AddActiveDirectoryConnection( [Microsoft.Office.Server.UserProfiles.ConnectionType]::ActiveDirectory, ` $params.Name, ` @@ -600,20 +603,27 @@ function Test-TargetResource return $false } - if ($Force -eq $true) + $installedVersion = Get-SPDSCInstalledProductVersion + $valuesToCheck = @("Forest", + "UserProfileService", + "Server", + "UseSSL", + "IncludedOUs", + "Ensure") + + if($installedVersion.FileMajorPart -eq 15) { - return $false + if ($Force -eq $true) + { + return $false + } + + $valuesToCheck += "ExcludedOUs" } return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("Forest", - "UserProfileService", - "Server", - "UseSSL", - "IncludedOUs", - "ExcludedOUs", - "Ensure") + -ValuesToCheck $valuesToCheck } <# diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.schema.mof index 70616765b..cebd081ea 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.schema.mof @@ -5,13 +5,13 @@ class MSFT_SPUserProfileSyncConnection : OMI_BaseResource [Required, Description("The name of the AD forest to read from")] string Forest; [Required, Description("The name of the user profile service that this connection is attached to")] string UserProfileService; [Required, Description("The credentials to connect to Active Directory with"), EmbeddedInstance("MSFT_Credential")] string ConnectionCredentials; - [Required, Description("A list of the OUs to import users from")] string IncludedOUs[]; - [Write, Description("A list of the OUs to ignore users from")] string ExcludedOUs[]; + [Required, Description("A list of the OUs to import users from. For SharePoint 2016/2019 existing OUs will not be removed if not included in this list. Use ExludedOUs for removing OUs in SharePoint 2016/2019")] string IncludedOUs[]; + [Write, Description("A list of the OUs to ignore users from. For SharePoint 2016/2019 matching existing OUs to include are removed.")] string ExcludedOUs[]; [Write, Description("The specific AD server to connect to")] string Server; [Write, Description("The specific port to connect to")] uint32 Port; [Write, Description("Should SSL be used for the connection")] boolean UseSSL; [Write, Description("Should disabled accounts be filtered")] boolean UseDisabledFilter; - [Write, Description("Set to true to run the set method on every call to this resource")] boolean Force; + [Write, Description("Set to true to run the set method on every call to this resource. Only has effect on SharePoint 2013")] boolean Force; [Write, Description("The type of the connection - currently only Active Directory is supported"), ValueMap{"ActiveDirectory","BusinessDataCatalog"}, Values{"ActiveDirectory","BusinessDataCatalog"}] string ConnectionType; [Write, Description("Present if the connection should exist, absent if it should not"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] string InstallAccount; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/readme.md index f841c746d..f6885edd9 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/readme.md @@ -7,3 +7,10 @@ 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. + +Force only works with SharePoint 2013. For SharePoint 2016/2019 +the resource is not able to remove existing OUs. +You will have to use the ExcludedOUs for this. This means you need +to know which OUs to remove. If any extra OUs exists after the +configuration has run the test method will report the resource not +in desired state. diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 index 6b4996ad6..8c7caa2ca 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 @@ -324,6 +324,11 @@ function Set-TargetResource } $count++ } + + if ($syncService.Status -ne $desiredState) + { + throw "An error occured. We couldn't properly set the User Profile Sync Service on the server." + } } } finally @@ -341,10 +346,6 @@ function Set-TargetResource Clear-SPDscKerberosToken -Account $farmAccount.UserName } } - if($syncService.Status -ne $desiredState) - { - throw "An error occured. We couldn't properly set the User Profile Sync Service on the server." - } } function Test-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 index 4d564c732..1e1c823a7 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 @@ -72,6 +72,8 @@ function Get-TargetResource else { $ensureResult = "Absent" + $templateResult = $null + $parentTopNav = $null } return @{ diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 index 012f92559..ad4692b12 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 @@ -36,7 +36,7 @@ function Get-TargetResource Write-Verbose -Message "Getting web application authentication for '$WebAppUrl'" $nullreturn = @{ - WebAppUrl = $params.Name + WebAppUrl = $WebAppUrl Default = $null Intranet = $null Internet = $null @@ -108,7 +108,7 @@ function Get-TargetResource if ($null -eq $wa) { return @{ - WebAppUrl = $params.Name + WebAppUrl = $params.WebAppUrl Default = $null Intranet = $null Internet = $null diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 index 80018ed2a..193b520ce 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 @@ -79,6 +79,7 @@ function Get-TargetResource function Set-TargetResource { + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "Ignoring this because the used AccessAccount does not use SecureString to handle the password")] [CmdletBinding()] param ( @@ -183,14 +184,21 @@ function Set-TargetResource $adsearchobj.IsForest = $searchADDomain.IsForest - $prop = $searchADDomain.CimInstanceProperties | Where-Object -FilterScript { - $_.Name -eq "AccessAccount" - } - if ($null -ne $prop) + if ($null -ne $searchADDomain.AccessAccount) { $adsearchobj.LoginName = $searchADDomain.AccessAccount.UserName - $adsearchobj.SetPassword($searchADDomain.AccessAccount.Password) + + if([string]::IsNullOrEmpty($searchADDomain.AccessAccount.Password)) + { + $adsearchobj.SetPassword($null) + } + else + { + $accessAccountPassword = ConvertTo-SecureString $searchADDomain.AccessAccount.Password -AsPlainText -Force + $adsearchobj.SetPassword($accessAccountPassword) + } } + $wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Add($adsearchobj) } } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 index 20c0a95e0..d0b8ba582 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 @@ -4,28 +4,28 @@ function Get-TargetResource [OutputType([System.Collections.Hashtable])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $WebAppUrl, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $Members, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToInclude, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToExclude, - [Parameter()] - [System.Boolean] + [Parameter()] + [System.Boolean] $SetCacheAccountsPolicy, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -67,7 +67,7 @@ function Get-TargetResource return $null } } - + $result = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { @@ -78,7 +78,7 @@ function Get-TargetResource if ($null -eq $wa) { - return $null + return $null } $SetCacheAccountsPolicy = $false @@ -96,7 +96,7 @@ function Get-TargetResource { if ($psu.PolicyRoleBindings.Type -eq 'FullControl') { - $correctPSU = $true + $correctPSU = $true } } @@ -105,7 +105,7 @@ function Get-TargetResource { if ($psr.PolicyRoleBindings.Type -eq 'FullRead') { - $correctPSR = $true + $correctPSR = $true } } @@ -115,7 +115,7 @@ function Get-TargetResource } } } - + $members = @() foreach ($policy in $wa.Policies) { @@ -174,7 +174,7 @@ function Get-TargetResource SetCacheAccountsPolicy = $SetCacheAccountsPolicy InstallAccount = $params.InstallAccount } - + return $returnval } return $result @@ -185,28 +185,28 @@ function Set-TargetResource [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $WebAppUrl, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $Members, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToInclude, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToExclude, - [Parameter()] - [System.Boolean] + [Parameter()] + [System.Boolean] $SetCacheAccountsPolicy, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) @@ -249,14 +249,14 @@ function Set-TargetResource $modulePath = "..\..\Modules\SharePointDsc.WebAppPolicy\SPWebAppPolicy.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $modulePath -Resolve) - + if ($null -eq $CurrentValues) { throw "Web application does not exist" } $cacheAccounts = Get-SPDSCCacheAccountConfiguration -InputParameters $WebAppUrl - + if ($SetCacheAccountsPolicy) { if ($cacheAccounts.SuperUserAccount -eq "" -or $cacheAccounts.SuperReaderAccount -eq "") @@ -276,8 +276,8 @@ function Set-TargetResource if ($wa.UseClaimsAuthentication -eq $true) { return "Claims" - } - else + } + else { return "Native" } @@ -314,7 +314,7 @@ function Set-TargetResource IdentityMode = $cacheAccounts.IdentityMode } $allMembers += $psuAccount - + $psrAccount = @{ UserName = $cacheAccounts.SuperReaderAccount PermissionLevel = "Full Read" @@ -333,7 +333,7 @@ function Set-TargetResource switch ($difference.Status) { Additional { - # Only remove users if the "Members" property was set + # Only remove users if the "Members" property was set # instead of "MembersToInclude" if ($Members) { @@ -359,7 +359,7 @@ function Set-TargetResource Username = $difference.Username PermissionLevel = $difference.DesiredPermissionLevel ActAsSystemAccount = $difference.DesiredActAsSystemSetting - IdentityMode = $difference.IdentityType + IdentityMode = $difference.IdentityType } } } @@ -375,7 +375,7 @@ function Set-TargetResource foreach ($member in $MembersToExclude) { $policy = $CurrentValues.Members | Where-Object -FilterScript { - $_.UserName -eq $member.UserName -and $_.IdentityType -eq $identityType + $_.UserName -eq $member.UserName -and $_.IdentityType -eq $member.IdentityType } if (($cacheAccounts.SuperUserAccount -eq $member.Username) -or ` @@ -390,11 +390,11 @@ function Set-TargetResource Type = "Delete" Username = $member.UserName } + $changeUsers += $user } - $changeUsers += $user } } - + ## Perform changes Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments @($PSBoundParameters,$PSScriptRoot,$changeUsers) ` @@ -427,7 +427,7 @@ function Set-TargetResource "Add" { # User does not exist. Add user Write-Verbose -Message "Adding $($user.Username)" - + $userToAdd = $user.Username if ($user.IdentityMode -eq "Claims") { @@ -437,13 +437,13 @@ function Set-TargetResource $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSamAccountName $userToAdd = $principal.ToEncodedString() - } - else + } + else { $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSecurityGroupName $userToAdd = $principal.ToEncodedString() - } + } } $newPolicy = $wa.Policies.Add($userToAdd, $user.UserName) foreach ($permissionLevel in $user.PermissionLevel) @@ -480,8 +480,8 @@ function Set-TargetResource $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSamAccountName $userToChange = $principal.ToEncodedString() - } - else + } + else { $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSecurityGroupName @@ -489,13 +489,13 @@ function Set-TargetResource } } $policy = $wa.Policies | Where-Object -FilterScript { - $_.UserName -eq $userToChange + $_.UserName -eq $userToChange } Write-Verbose -Message "User $($user.Username) exists, checking permissions" if ($user.ActAsSystemAccount -ne $policy.IsSystemUser) { - $policy.IsSystemUser = $user.ActAsSystemAccount + $policy.IsSystemUser = $user.ActAsSystemAccount } switch ($policy.PolicyRoleBindings.Type) @@ -543,7 +543,7 @@ function Set-TargetResource } } } - "Delete" + "Delete" { Write-Verbose -Message "Removing $($user.Username)" $userToDrop = $user.Username @@ -555,13 +555,13 @@ function Set-TargetResource $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSamAccountName $userToDrop = $principal.ToEncodedString() - } - else + } + else { $principal = New-SPClaimsPrincipal -Identity $user.Username ` -IdentityType WindowsSecurityGroupName $userToDrop = $principal.ToEncodedString() - } + } } Remove-SPDSCGenericObject -SourceCollection $wa.Policies ` -Target $userToDrop ` @@ -579,41 +579,41 @@ function Test-TargetResource [OutputType([System.Boolean])] param ( - [Parameter(Mandatory = $true)] - [System.String] + [Parameter(Mandatory = $true)] + [System.String] $WebAppUrl, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $Members, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToInclude, - [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance[]] + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance[]] $MembersToExclude, - [Parameter()] - [System.Boolean] + [Parameter()] + [System.Boolean] $SetCacheAccountsPolicy, - [Parameter()] - [System.Management.Automation.PSCredential] + [Parameter()] + [System.Management.Automation.PSCredential] $InstallAccount ) Write-Verbose -Message "Testing web app policy for $WebAppUrl" $CurrentValues = Get-TargetResource @PSBoundParameters - + $modulePath = "..\..\Modules\SharePointDsc.WebAppPolicy\SPWebAppPolicy.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $modulePath -Resolve) if ($null -eq $CurrentValues) { - return $false + return $false } $cacheAccounts = Get-SPDSCCacheAccountConfiguration -InputParameters $WebAppUrl @@ -637,14 +637,14 @@ function Test-TargetResource if ($wa.UseClaimsAuthentication -eq $true) { return "Claims" - } - else + } + else { return "Native" } } - - # If checking the full members list, or the list of members to include then build the + + # If checking the full members list, or the list of members to include then build the # appropriate members list and check for the output of Compare-SPDSCWebAppPolicy if ($Members -or $MembersToInclude) { @@ -675,7 +675,7 @@ function Test-TargetResource IdentityMode = $cacheAccounts.IdentityMode } $allMembers += $psuAccount - + $psrAccount = @{ UserName = $cacheAccounts.SuperReaderAccount PermissionLevel = "Full Read" @@ -688,18 +688,18 @@ function Test-TargetResource $differences = Compare-SPDSCWebAppPolicy -WAPolicies $CurrentValues.Members ` -DSCSettings $allMembers ` -DefaultIdentityType $defaultIdentityType - + # If checking members, any difference counts as a fail if ($Members) { if ($differences.Count -eq 0) { - return $true - } - else + return $true + } + else { - Write-Verbose -Message "Differences in the policy were found, returning false" - return $false + Write-Verbose -Message "Differences in the policy were found, returning false" + return $false } } @@ -707,15 +707,15 @@ function Test-TargetResource if ($MembersToInclude) { if (($differences | Where-Object -FilterScript { - $_.Status -eq "Different" -or $_.Status -eq "Missing" + $_.Status -eq "Different" -or $_.Status -eq "Missing" }).Count -eq 0) { - return $true - } - else + return $true + } + else { - Write-Verbose -Message "Different or Missing policy was found, returning false" - return $false + Write-Verbose -Message "Different or Missing policy was found, returning false" + return $false } } } @@ -733,7 +733,7 @@ function Test-TargetResource { throw "You cannot exclude the Cache accounts from the Web Application Policy" } - + foreach ($policy in $CurrentValues.Members) { if ($policy.Username -eq $member.Username) @@ -752,10 +752,10 @@ function Get-SPDSCCacheAccountConfiguration() [OutputType([System.Collections.Hashtable])] param ( [Parameter()] - [Object[]] + [Object[]] $InputParameters ) - + $cacheAccounts = Invoke-SPDSCCommand -Credential $InstallAccount ` -Arguments $InputParameters ` -ScriptBlock { @@ -770,7 +770,7 @@ function Get-SPDSCCacheAccountConfiguration() } $returnval = @{ - SuperUserAccount = "" + SuperUserAccount = "" SuperReaderAccount = "" } @@ -808,12 +808,12 @@ function Get-SPDSCCacheAccountConfiguration() if ($wa.UseClaimsAuthentication -eq $true) { $returnval.IdentityMode = "Claims" - } - else + } + else { $returnval.IdentityMode = "Native" } - + return $returnval } diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 index 070300433..62d615cd7 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 @@ -200,15 +200,14 @@ function Set-TargetResource { $params.Remove("InstallAccount") | Out-Null } - if ($params.ContainsKey("ProxyName")) + + $pName = "$($params.Name) Proxy" + + if ($params.ContainsKey("ProxyName") -and $null -ne $params.ProxyName) { $pName = $params.ProxyName $params.Remove("ProxyName") | Out-Null } - if ($null -eq $pName) - { - $pName = "$($params.Name) Proxy" - } $app = New-SPWorkManagementServiceApplication @params if ($null -ne $app) diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 index 1e6f36bee..b054a7416 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 @@ -12,6 +12,10 @@ function Get-TargetResource [System.String] $SPSiteUrl, + [Parameter()] + [System.String] + $ScopeName, + [Parameter()] [System.Boolean] $AllowOAuthHttp, @@ -30,17 +34,29 @@ function Get-TargetResource $returnval = @{ WorkflowHostUri = $null - SPSiteUrl = $null + SPSiteUrl = $params.SPSiteUrl + ScopeName = $null AllowOAuthHttp = $null } - $workflowProxy = Get-SPWorkflowServiceApplicationProxy - if($null -ne $workflowProxy) + $site = Get-SPSite $params.SPSiteUrl + + if ($null -eq $site) { - $returnval = @{ - WorkflowHostUri = $workflowProxy.GetHostname($SPSiteUrl) - SPSiteUrl = $params.SPSiteUrl - AllowOAuthHttp = $params.AllowOAuthHttp + Write-Verbose "Specified site collection could not be found." + } + else + { + $workflowProxy = Get-SPWorkflowServiceApplicationProxy + + if ($null -ne $workflowProxy) + { + $returnval = @{ + WorkflowHostUri = $workflowProxy.GetHostname($site).TrimEnd("/") + SPSiteUrl = $params.SPSiteUrl + ScopeName = $workflowProxy.GetWorkflowScopeName($site) + AllowOAuthHttp = $params.AllowOAuthHttp + } } } @@ -62,6 +78,10 @@ function Set-TargetResource [System.String] $SPSiteUrl, + [Parameter()] + [System.String] + $ScopeName, + [Parameter()] [System.Boolean] $AllowOAuthHttp, @@ -88,9 +108,18 @@ function Set-TargetResource Write-Verbose -Message "Processing changes" - Register-SPWorkflowService -WorkflowHostUri $params.WorkflowHostUri ` - -SPSite $params.SPSiteUrl ` - -AllowOAuthHttp:$params.AllowOAuthHttp -Force + $workflowServiceParams = @{ + WorkflowHostUri = $params.WorkflowHostUri.TrimEnd("/") + SPSite = $site + AllowOAuthHttp = $params.AllowOAuthHttp + } + + if ($params.ContainsKey("ScopeName")) + { + $workflowServiceParams.Add("ScopeName", $params.ScopeName) + } + + Register-SPWorkflowService @workflowServiceParams -Force } } @@ -108,6 +137,10 @@ function Test-TargetResource [System.String] $SPSiteUrl, + [Parameter()] + [System.String] + $ScopeName, + [Parameter()] [System.Boolean] $AllowOAuthHttp, @@ -126,9 +159,17 @@ function Test-TargetResource return $false } + $PSBoundParameters.WorkflowHostUri = $PSBoundParameters.WorkflowHostUri.TrimEnd("/") + $valuesToCheck = @("WorkflowHostUri") + + if ($ScopeName) + { + $valuesToCheck += "ScopeName" + } + return Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("Ensure") + -ValuesToCheck $valuesToCheck } Export-ModuleMember -Function *-TargetResource diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.schema.mof b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.schema.mof index 8323f0072..a4a66c506 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.schema.mof +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.schema.mof @@ -3,6 +3,7 @@ class MSFT_SPWorkflowService : OMI_BaseResource { [Key, Description("The URL of the Workflow Service")] string WorkflowHostUri; [Key, Description("The URL of the Site Collection to associate with the Workflow Service Proxy")] String SPSiteUrl; + [Write, Description("Specify scope name. If not specified SharePoint will use the default scope name 'SharePoint'")] String ScopeName; [Write, Description("Specify whether or not to allow connection to the Workflow Service over Http")] Boolean AllowOAuthHttp; [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; }; diff --git a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/readme.md b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/readme.md index 0ae3c014b..8ba2cc9d9 100644 --- a/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/readme.md +++ b/Modules/SharePointDsc/DSCResources/MSFT_SPWorkflowService/readme.md @@ -9,3 +9,11 @@ against a Workflow Manager Instance. Requirements: Provide the url of the Workflow Manager instance to connect to. +Scope name is optional and defaults to SharePoint. +If scope name is not specified any configured scope name is +allowed by this resource. + +Remarks + +Change or configuration drift for AllowOAuthHttp is not detected +by this resource. diff --git a/Modules/SharePointDsc/Examples/Resources/SPAuthenticationRealm/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPAuthenticationRealm/1-Example.ps1 new file mode 100644 index 000000000..ac3707a27 --- /dev/null +++ b/Modules/SharePointDsc/Examples/Resources/SPAuthenticationRealm/1-Example.ps1 @@ -0,0 +1,23 @@ +<# +.EXAMPLE + This example sets the farm atuhentication realm. +#> + + Configuration Example + { + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPAuthenticationRealm AuthenticationRealm + { + IsSingleInstance = "Yes" + AuthenticationRealm = "14757a87-4d74-4323-83b9-fb1e77e8f22f" + PsDscRunAsCredential = $SetupAccount + } + } + } diff --git a/Modules/SharePointDsc/Examples/Resources/SPBCSServiceApp/1-CreateServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPBCSServiceApp/1-CreateServiceApp.ps1 index a059976bd..066ae462f 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPBCSServiceApp/1-CreateServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPBCSServiceApp/1-CreateServiceApp.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE This example shows how to deploy a Business Connectivity Services application to the - local SharePoint farm. + local SharePoint farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,11 +16,11 @@ node localhost { SPBCSServiceApp BCSServiceApp { - Name = "BCS Service Application" - ApplicationPool = "SharePoint Service Applications" - DatabaseName = "SP_BCS" - DatabaseServer = "SQL.contoso.local\SQLINSTANCE" - InstallAccount = $SetupAccount + Name = "BCS Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseName = "SP_BCS" + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/1-SingleServerCache.ps1 b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/1-SingleServerCache.ps1 index d3783ff11..4e68cdbb9 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/1-SingleServerCache.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/1-SingleServerCache.ps1 @@ -5,7 +5,7 @@ other cache hosts. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -20,7 +20,7 @@ Name = "AppFabricCachingService" CacheSizeInMB = 8192 ServiceAccount = "DEMO\ServiceAccount" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount CreateFirewallRules = $true } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/2-CacheNoFirewall.ps1 b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/2-CacheNoFirewall.ps1 index e8632448d..f4f2b8c4e 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/2-CacheNoFirewall.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/2-CacheNoFirewall.ps1 @@ -1,12 +1,12 @@ <# .EXAMPLE This example applies the distributed cache service to the current server, - but will not apply the rules to allow it to communicate with other cache + but will not apply the rules to allow it to communicate with other cache hosts to the Windows Firewall. Use this approach if you have an alternate firewall solution. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -21,7 +21,7 @@ Name = "AppFabricCachingService" CacheSizeInMB = 8192 ServiceAccount = "DEMO\ServiceAccount" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount CreateFirewallRules = $false } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 index 34704a32a..e1af11de4 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPDistributedCacheService/3-MultiServerCache.ps1 @@ -2,7 +2,7 @@ .EXAMPLE This example applies the distributed cache service to both "server1" and "server2". The ServerProvisionOrder will ensure that it applies it to - server1 first and then server2, making sure they don't both attempt to + server1 first and then server2, making sure they don't both attempt to create the cache at the same time, resuling in errors. Note: Do not allow plain text passwords in production environments. @@ -21,7 +21,7 @@ ) } - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -29,8 +29,8 @@ $SetupAccount ) Import-DscResource -ModuleName SharePointDsc - - node "Server1" + + node "Server1" { SPDistributedCacheService EnableDistributedCache { @@ -39,7 +39,7 @@ ServiceAccount = "DEMO\ServiceAccount" ServerProvisionOrder = @("Server1","Server2") CreateFirewallRules = $true - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } @@ -52,7 +52,7 @@ ServiceAccount = "DEMO\ServiceAccount" ServerProvisionOrder = @("Server1","Server2") CreateFirewallRules = $true - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/1-CreateServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/1-CreateServiceApp.ps1 index 4903db6b8..d86c6b833 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/1-CreateServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/1-CreateServiceApp.ps1 @@ -3,7 +3,7 @@ This example shows how to deploy Excel Services to the local SharePoint farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,9 +15,9 @@ node localhost { SPExcelServiceApp ExcelServices { - Name = "Excel Services Service Application" - ApplicationPool = "SharePoint Service Applications" - InstallAccount = $SetupAccount + Name = "Excel Services Service Application" + ApplicationPool = "SharePoint Service Applications" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/2-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/2-RemoveServiceApp.ps1 index c89acdb02..35559d96d 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/2-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPExcelServiceApp/2-RemoveServiceApp.ps1 @@ -2,10 +2,10 @@ .EXAMPLE This example shows how to remove Excel Services from the local SharePoint farm. Here application pool is a required parameter, but it is not actually used when - removing a service app and as such can be ignored and set to any value. + removing a service app and as such can be ignored and set to any value. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -17,10 +17,10 @@ node localhost { SPExcelServiceApp ExcelServices { - Name = "Excel Services Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Excel Services Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/1-EnableAutomaticMode.ps1 b/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/1-EnableAutomaticMode.ps1 new file mode 100644 index 000000000..25e5de944 --- /dev/null +++ b/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/1-EnableAutomaticMode.ps1 @@ -0,0 +1,26 @@ +<# +.EXAMPLE + This example shows how to configure SharePoint Incoming Email in Automatic Mode +#> + +Configuration Example +{ + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPIncomingEmailSettings AutomaticEmail + { + IsSingleInstance = "Yes" + Ensure = "Present" + UseAutomaticSettings = $true + UseDirectoryManagementService = "No" + ServerDisplayAddress = "contoso.com" + PsDscRunAsCredential = $SetupAccount + } + } +} diff --git a/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/2-Enable-AdvancedMode.ps1 b/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/2-Enable-AdvancedMode.ps1 new file mode 100644 index 000000000..734b85b54 --- /dev/null +++ b/Modules/SharePointDsc/Examples/Resources/SPIncomingEmailSettings/2-Enable-AdvancedMode.ps1 @@ -0,0 +1,27 @@ +<# +.EXAMPLE + This example shows how to configure SharePoint Incoming Email in Advanced Mode +#> + +Configuration Example +{ + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPIncomingEmailSettings AutomaticEmail + { + IsSingleInstance = "Yes" + Ensure = "Present" + UseAutomaticSettings = $false + UseDirectoryManagementService = "No" + ServerDisplayAddress = "contoso.com" + DropFolder = "\\MailServer\Pickup" + PsDscRunAsCredential = $SetupAccount + } + } +} diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/1-CreateServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/1-CreateServiceApp.ps1 index b163c35cd..4934fceda 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/1-CreateServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/1-CreateServiceApp.ps1 @@ -3,7 +3,7 @@ This example shows how to deploy the Managed Metadata service app to the local SharePoint farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,11 +15,11 @@ node localhost { SPManagedMetaDataServiceApp ManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount - ApplicationPool = "SharePoint Service Applications" - DatabaseServer = "SQL.contoso.local" - DatabaseName = "SP_ManagedMetadata" + Name = "Managed Metadata Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseServer = "SQL.contoso.local" + DatabaseName = "SP_ManagedMetadata" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/2-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/2-RemoveServiceApp.ps1 index f4b7abd47..8cde10c76 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/2-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/2-RemoveServiceApp.ps1 @@ -1,13 +1,13 @@ <# .EXAMPLE - This example shows how to remove a specific managed metadata service app from the + This example shows how to remove a specific managed metadata service app from the local SharePoint farm. Because Application pool parameter is required - but is not acutally needed to remove the app, any text value can - be supplied for these as it will be ignored. + but is not acutally needed to remove the app, any text value can + be supplied for these as it will be ignored. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -19,10 +19,10 @@ node localhost { SPManagedMetaDataServiceApp ManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount - ApplicationPool = "none" - Ensure = "Absent" + Name = "Managed Metadata Service Application" + ApplicationPool = "none" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/3-SetTermStoreAdmins.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/3-SetTermStoreAdmins.ps1 index 45f74fa2a..0814da76d 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/3-SetTermStoreAdmins.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceApp/3-SetTermStoreAdmins.ps1 @@ -17,7 +17,7 @@ SPManagedMetaDataServiceApp ManagedMetadataServiceApp { Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount ApplicationPool = "SharePoint Service Applications" DatabaseServer = "SQL.contoso.local" DatabaseName = "SP_ManagedMetadata" diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceAppDefault/1-SetManagedMetadataDefault.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceAppDefault/1-SetManagedMetadataDefault.ps1 index 224e636c0..47bfe3653 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceAppDefault/1-SetManagedMetadataDefault.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedMetaDataServiceAppDefault/1-SetManagedMetadataDefault.ps1 @@ -18,7 +18,7 @@ Configuration Example IsSingleInstance = "Yes" DefaultSiteCollectionProxyName = "Managed Metadata Service Application Proxy" DefaultKeywordProxyName = "Managed Metadata Service Application Proxy" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/1-ExplicitPath.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/1-ExplicitPath.ps1 index d5d735dc0..e40d4b718 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/1-ExplicitPath.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/1-ExplicitPath.ps1 @@ -3,7 +3,7 @@ This example shows how to deploy an explicit managed path to a specifici web application #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -13,13 +13,13 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "example" - Explicit = $true - HostHeader = $false + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "example" + Explicit = $true + HostHeader = $false + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/2-WildcardPath.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/2-WildcardPath.ps1 index 8fcd254fd..91f6a7ed9 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/2-WildcardPath.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/2-WildcardPath.ps1 @@ -3,7 +3,7 @@ This example shows how to add a wildcard managed path to a specific web application #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -13,13 +13,13 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/3-RemovePath.ps1 b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/3-RemovePath.ps1 index 93daed87f..b341ac844 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPManagedPath/3-RemovePath.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPManagedPath/3-RemovePath.ps1 @@ -3,7 +3,7 @@ This example shows how to remove a wildcard managed path from a specific web application #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -13,14 +13,14 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true - Ensure = "Absent" + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-NewServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-NewServiceApp.ps1 index 2f32421e6..ca401b2e5 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-NewServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-NewServiceApp.ps1 @@ -3,7 +3,7 @@ This example creates a new performance point service app in the local farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,9 +15,9 @@ node localhost { SPPerformancePointServiceApp PerformancePoint { - Name = "Performance Point Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Performance Point Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-RemoveServiceApp.ps1 index 76a8f145c..e62c981f4 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPPerformancePointServiceApp/1-RemoveServiceApp.ps1 @@ -2,10 +2,10 @@ .EXAMPLE This example removes the specific performance point service app from the local farm. The ApplicationPool parameter is still mandatory but it is not used, so - the value can be anything. + the value can be anything. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -17,10 +17,10 @@ node localhost { SPPerformancePointServiceApp PerformancePoint { - Name = "Performance Point Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Performance Point Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/1-SPMode.ps1 b/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/1-SPMode.ps1 index e2a2dda0f..7c5204b1c 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/1-SPMode.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/1-SPMode.ps1 @@ -3,7 +3,7 @@ This example shows how to a specific PWA site to use SharePoint permission mode. #> -Configuration Example +Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,9 +15,9 @@ Configuration Example node localhost { SPProjectServerPermissionMode PermissionMode { - Url = "http://projects.contoso.com" - PermissionMode = "SharePoint" - InstallAccount = $SetupAccount + Url = "http://projects.contoso.com" + PermissionMode = "SharePoint" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/2-PSMode.ps1 b/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/2-PSMode.ps1 index 47bb72b20..aa417c056 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/2-PSMode.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPProjectServerPermissionMode/2-PSMode.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE - This example shows how to a specific PWA site to use Project server + This example shows how to a specific PWA site to use Project server permission mode. #> -Configuration Example +Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ Configuration Example node localhost { SPProjectServerPermissionMode PermissionMode { - Url = "http://projects.contoso.com" - PermissionMode = "ProjectServer" - InstallAccount = $SetupAccount + Url = "http://projects.contoso.com" + PermissionMode = "ProjectServer" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/1-NewServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/1-NewServiceApp.ps1 index 61cc5a878..e45ff36d2 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/1-NewServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/1-NewServiceApp.ps1 @@ -4,7 +4,7 @@ in the local farm #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ node localhost { SPProjectServerServiceApp ProjectServiceApp { - Name = "Project Server Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Project Server Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/2-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/2-RemoveServiceApp.ps1 index 288819047..ab905b074 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/2-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPProjectServerServiceApp/2-RemoveServiceApp.ps1 @@ -5,7 +5,7 @@ the value used here doesn't matter. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -17,10 +17,10 @@ node localhost { SPProjectServerServiceApp ProjectServiceApp { - Name = "Project Server Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Project Server Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/1-PublishServiceApplication.ps1 b/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/1-PublishServiceApplication.ps1 index c17e36d89..b3d4642cc 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/1-PublishServiceApplication.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/1-PublishServiceApplication.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE This example shows how to ensure that the managed metadata service is published - within the farm. + within the farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ node localhost { SPPublishServiceApplication PublishManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - Ensure = "Present" - InstallAccount = $SetupAccount + Name = "Managed Metadata Service Application" + Ensure = "Present" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/2-UnpublishServiceApplication.ps1 b/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/2-UnpublishServiceApplication.ps1 index a87eefb12..05380b433 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/2-UnpublishServiceApplication.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPPublishServiceApplication/2-UnpublishServiceApplication.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE - This example shows how to ensure that the Secure Store Service is not - published within the farm. + This example shows how to ensure that the Secure Store Service is not + published within the farm. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ node localhost { SPPublishServiceApplication UnpublishSecureStoreServiceApp { - Name = "Secure Store Service Application" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Secure Store Service Application" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/1-NewServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/1-NewServiceApp.ps1 index dbfea3a07..ba59af22a 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/1-NewServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/1-NewServiceApp.ps1 @@ -3,7 +3,7 @@ This example creates a new secure store service app. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,12 +15,12 @@ node localhost { SPSecureStoreServiceApp SecureStoreServiceApp { - Name = "Secure Store Service Application" - ApplicationPool = "SharePoint Service Applications" - AuditingEnabled = $true - AuditlogMaxSize = 30 - DatabaseName = "SP_SecureStore" - InstallAccount = $SetupAccount + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Service Applications" + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = "SP_SecureStore" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/2-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/2-RemoveServiceApp.ps1 index 38daea633..4c5206e1a 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/2-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPSecureStoreServiceApp/2-RemoveServiceApp.ps1 @@ -5,7 +5,7 @@ are able to be set to anything. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -17,11 +17,11 @@ node localhost { SPSecureStoreServiceApp SecureStoreServiceApp { - Name = "Secure Store Service Application" - ApplicationPool = "n/a" - AuditingEnabled = $false - InstallAccount = $SetupAccount - Ensure = "Absent" + Name = "Secure Store Service Application" + ApplicationPool = "n/a" + AuditingEnabled = $false + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/1-StartService.ps1 b/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/1-StartService.ps1 index d918cc711..dbff281af 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/1-StartService.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/1-StartService.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE This example shows how to ensure that the managed metadata service is running - on the local server. + on the local server. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ node localhost { SPServiceInstance ManagedMetadataServiceInstance { - Name = "Managed Metadata Web Service" - Ensure = "Present" - InstallAccount = $SetupAccount + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/2-StopService.ps1 b/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/2-StopService.ps1 index f7c70b71b..a11cb1558 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/2-StopService.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPServiceInstance/2-StopService.ps1 @@ -1,10 +1,10 @@ <# .EXAMPLE - This example shows how to ensure that the Business Data Connectivity Service - is not running on the local server. + This example shows how to ensure that the Business Data Connectivity Service + is not running on the local server. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -16,9 +16,9 @@ node localhost { SPServiceInstance StopBCSServiceInstance { - Name = "Business Data Connectivity Service" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Business Data Connectivity Service" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPUsageApplication/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPUsageApplication/1-Example.ps1 index 93d347df0..f9f0567d9 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPUsageApplication/1-Example.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPUsageApplication/1-Example.ps1 @@ -3,7 +3,7 @@ This example deploys a usage application to the local farm #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -13,7 +13,7 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPUsageApplication UsageApplication + SPUsageApplication UsageApplication { Name = "Usage Service Application" DatabaseName = "SP_Usage" @@ -21,7 +21,7 @@ UsageLogLocation = "L:\UsageLogs" UsageLogMaxFileSizeKB = 1024 Ensure = "Present" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPUserProfileSyncService/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPUserProfileSyncService/1-Example.ps1 index 74771cb49..6dc9325ca 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPUserProfileSyncService/1-Example.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPUserProfileSyncService/1-Example.ps1 @@ -3,7 +3,7 @@ This example provisions the user profile sync service to the local server #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -19,11 +19,11 @@ node localhost { SPUserProfileSyncService UserProfileSyncService { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - RunOnlyWhenWriteable = $true - InstallAccount = $SetupAccount + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + RunOnlyWhenWriteable = $true + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/1-NewServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/1-NewServiceApp.ps1 index 66e1277de..0f5085e78 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/1-NewServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/1-NewServiceApp.ps1 @@ -3,7 +3,7 @@ This example shows how to create a new visio services service app in the local farm #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -15,9 +15,9 @@ node localhost { SPVisioServiceApp VisioServices { - Name = "Visio Graphics Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Visio Graphics Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/2-RemoveServiceApp.ps1 b/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/2-RemoveServiceApp.ps1 index b1cf41a8a..38fda849a 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/2-RemoveServiceApp.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPVisioServiceApp/2-RemoveServiceApp.ps1 @@ -5,7 +5,7 @@ the value used here doesn't matter. #> - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -17,10 +17,10 @@ node localhost { SPVisioServiceApp VisioServices { - Name = "Visio Graphics Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Visio Graphics Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/1-Inclusion.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/1-Inclusion.ps1 index ed527d3b5..9d93c2527 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/1-Inclusion.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/1-Inclusion.ps1 @@ -17,7 +17,7 @@ node localhost { SPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" EnsureBlocked = @("exe", "dll", "msi") EnsureAllowed = @("pdf", "docx", "xlsx") PsDscRunAsCredential = $SetupAccount diff --git a/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/2-SpecificList.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/2-SpecificList.ps1 index 4c21e96d7..fa93a9cae 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/2-SpecificList.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPWebAppBlockedFileTypes/2-SpecificList.ps1 @@ -16,7 +16,7 @@ node localhost { SPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" Blocked = @("exe", "dll", "msi") PsDscRunAsCredential = $SetupAccount } diff --git a/Modules/SharePointDsc/Examples/Resources/SPWebAppGeneralSettings/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWebAppGeneralSettings/1-Example.ps1 index 5c5f8fe37..f00eb9fce 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPWebAppGeneralSettings/1-Example.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPWebAppGeneralSettings/1-Example.ps1 @@ -16,7 +16,7 @@ node localhost { SPWebAppGeneralSettings PrimaryWebAppGeneralSettings { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" TimeZone = 76 Alerts = $true RSS = $false diff --git a/Modules/SharePointDsc/Examples/Resources/SPWebAppThrottlingSettings/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWebAppThrottlingSettings/1-Example.ps1 index 716310194..0a565f269 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPWebAppThrottlingSettings/1-Example.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPWebAppThrottlingSettings/1-Example.ps1 @@ -15,7 +15,7 @@ node localhost { SPWebAppThrottlingSettings PrimaryWebAppThrottlingSettings { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" ListViewThreshold = 5000 AllowObjectModelOverride = $false HappyHourEnabled = $true diff --git a/Modules/SharePointDsc/Examples/Resources/SPWebAppWorkflowSettings/1-Example.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWebAppWorkflowSettings/1-Example.ps1 index 85ba0d93b..ce5b2c09a 100644 --- a/Modules/SharePointDsc/Examples/Resources/SPWebAppWorkflowSettings/1-Example.ps1 +++ b/Modules/SharePointDsc/Examples/Resources/SPWebAppWorkflowSettings/1-Example.ps1 @@ -15,7 +15,7 @@ node localhost { SPWebAppWorkflowSettings PrimaryWebAppWorkflowSettings { - WebAppUrl = "Shttp://exmaple.contoso.local" + WebAppUrl = "Shttp://example.contoso.local" ExternalWorkflowParticipantsEnabled = $false EmailToNoPermissionWorkflowParticipantsEnable = $false PsDscRunAsCredential = $SetupAccount diff --git a/Modules/SharePointDsc/Examples/Resources/SPWorkflowService/2-RegisterWorkflowService.ps1 b/Modules/SharePointDsc/Examples/Resources/SPWorkflowService/2-RegisterWorkflowService.ps1 new file mode 100644 index 000000000..13bab14bd --- /dev/null +++ b/Modules/SharePointDsc/Examples/Resources/SPWorkflowService/2-RegisterWorkflowService.ps1 @@ -0,0 +1,25 @@ +<# +.EXAMPLE + This example registers the workflow service specifying a custom scope name. +#> + + Configuration Example + { + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPWorkflowService WorkflowService + { + WorkflowHostUri = "http://workflow.sharepoint.contoso.com" + ScopeName = "SharePointWorkflow" + SPSiteUrl = "http://sites.sharepoint.com" + AllowOAuthHttp = $true + PsDscRunAsCredential = $SetupAccount + } + } + } diff --git a/Modules/SharePointDsc/Examples/Small Farm/SharePoint.SSL.ps1 b/Modules/SharePointDsc/Examples/Small Farm/SharePoint.SSL.ps1 new file mode 100644 index 000000000..5a2851fbc --- /dev/null +++ b/Modules/SharePointDsc/Examples/Small Farm/SharePoint.SSL.ps1 @@ -0,0 +1,468 @@ +$ConfigurationData = @{ + AllNodes = @( + @{ + NodeName = 'Server1' + PSDscAllowPlainTextPassword = $true + }, + @{ + NodeName = 'Server2' + PSDscAllowPlainTextPassword = $true + } + ) +} + +Configuration Example +{ + param ( + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPSetupAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, + [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $Passphrase + ) + + Import-DscResource -ModuleName PSDesiredStateConfiguration + Import-DscResource -ModuleName SharePointDsc + Import-DscResource -ModuleName xWebAdministration + + node "Server1" + { + #********************************************************** + # Install Binaries + # + # This section installs SharePoint and its Prerequisites + #********************************************************** + + SPInstallPrereqs InstallPrereqs { + IsSingleInstance = "Yes" + Ensure = "Present" + InstallerPath = "C:\binaries\prerequisiteinstaller.exe" + OnlineMode = $true + } + + SPInstall InstallSharePoint { + IsSingleInstance = "Yes" + Ensure = "Present" + BinaryDir = "C:\binaries\" + ProductKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" + DependsOn = "[SPInstallPrereqs]InstallPrereqs" + } + + #********************************************************** + # Basic farm configuration + # + # This section creates the new SharePoint farm object, and + # provisions generic services and components used by the + # whole farm + #********************************************************** + SPFarm CreateSPFarm + { + IsSingleInstance = "Yes" + Ensure = "Present" + DatabaseServer = "sql.contoso.com" + FarmConfigDatabaseName = "SP_Config" + Passphrase = $Passphrase + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + AdminContentDatabaseName = "SP_AdminContent" + CentralAdministrationPort = 9999 + RunCentralAdmin = $true + DependsOn = "[SPInstall]InstallSharePoint" + } + SPManagedAccount ServicePoolManagedAccount + { + AccountName = $ServicePoolManagedAccount.UserName + Account = $ServicePoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + SPManagedAccount WebPoolManagedAccount + { + AccountName = $WebPoolManagedAccount.UserName + Account = $WebPoolManagedAccount + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + SPDiagnosticLoggingSettings ApplyDiagnosticLogSettings + { + IsSingleInstance = "Yes" + PsDscRunAsCredential = $SPSetupAccount + LogPath = "C:\ULS" + LogSpaceInGB = 5 + AppAnalyticsAutomaticUploadEnabled = $false + CustomerExperienceImprovementProgramEnabled = $true + DaysToKeepLogs = 7 + DownloadErrorReportingUpdatesEnabled = $false + ErrorReportingAutomaticUploadEnabled = $false + ErrorReportingEnabled = $false + EventLogFloodProtectionEnabled = $true + EventLogFloodProtectionNotifyInterval = 5 + EventLogFloodProtectionQuietPeriod = 2 + EventLogFloodProtectionThreshold = 5 + EventLogFloodProtectionTriggerPeriod = 2 + LogCutInterval = 15 + LogMaxDiskSpaceUsageEnabled = $true + ScriptErrorReportingDelay = 30 + ScriptErrorReportingEnabled = $true + ScriptErrorReportingRequireAuth = $true + DependsOn = "[SPFarm]CreateSPFarm" + } + SPUsageApplication UsageApplication + { + Name = "Usage Service Application" + DatabaseName = "SP_Usage" + UsageLogCutTime = 5 + UsageLogLocation = "C:\UsageLogs" + UsageLogMaxFileSizeKB = 1024 + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + SPStateServiceApp StateServiceApp + { + Name = "State Service Application" + DatabaseName = "SP_State" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + SPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 1024 + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + CreateFirewallRules = $true + DependsOn = @('[SPFarm]CreateSPFarm','[SPManagedAccount]ServicePoolManagedAccount') + } + + #********************************************************** + # Web applications + # + # This section creates the web applications in the + # SharePoint farm, as well as managed paths and other web + # application settings + #********************************************************** + + SPWebApplication SharePointSites + { + Name = "SharePoint Sites" + ApplicationPool = "SharePoint Sites" + ApplicationPoolAccount = $WebPoolManagedAccount.UserName + AllowAnonymous = $false + DatabaseName = "SP_Content" + WebAppUrl = "https://sites.contoso.com" + HostHeader = "sites.contoso.com" + Port = 443 + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPManagedAccount]WebPoolManagedAccount" + } + + #********************************************************** + # This resource depends on module xWebAdministration and + # uses SNI to bind to a specific hostname. If you don't + # want to use SNI, set SslFlags to 0. + #********************************************************** + xWebsite SslWebAppSharePointSites + { + Ensure = 'Present' + Name = "SharePoint Sites" + BindingInfo = @( + MSFT_xWebBindingInformation + { + Protocol = 'https' + IPAddress = '*' + Port = 443 + CertificateThumbprint = '' + CertificateStoreName = 'My' + HostName = 'sites.contoso.com' + SslFlags = 1 + } + ) + DependsOn = '[SPWebApplication]SharePointSites' + } + + SPCacheAccounts WebAppCacheAccounts + { + WebAppUrl = "https://sites.contoso.com" + SuperUserAlias = "CONTOSO\SP_SuperUser" + SuperReaderAlias = "CONTOSO\SP_SuperReader" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPWebApplication]SharePointSites" + } + + SPSite TeamSite + { + Url = "https://sites.contoso.com" + OwnerAlias = "CONTOSO\SP_Admin" + Name = "DSC Demo Site" + Template = "STS#0" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPWebApplication]SharePointSites" + } + + #********************************************************** + # Now set up binding and AAM for Central Admin + #********************************************************** + xWebsite SslWebAppCentralAdmin + { + Ensure = 'Present' + Name = 'SharePoint Central Administration v4' + BindingInfo = @( + MSFT_xWebBindingInformation + { + Protocol = 'https' + IPAddress = '*' + Port = '443' + CertificateThumbprint = '' + CertificateStoreName = 'My' + HostName = 'admin.contoso.com' + SslFlags = 1 + } + ) + DependsOn = '[xWebsite]SslWebAppSharePointSites' + } + + # Change AAM for Central Admin + SPAlternateUrl CentralAdminAam + { + WebAppName = "SharePoint Central Administration v4" + Zone = "Default" + Url = 'https://admin.contoso.com' + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[xWebsite]SslWebAppCentralAdmin" + } + + + #********************************************************** + # Service instances + # + # This section describes which services should be running + # and not running on the server + #********************************************************** + + SPServiceInstance ClaimsToWindowsTokenServiceInstance + { + Name = "Claims to Windows Token Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + + SPServiceInstance SecureStoreServiceInstance + { + Name = "Secure Store Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + + SPServiceInstance SearchServiceInstance + { + Name = "SharePoint Server Search" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + + #********************************************************** + # Service applications + # + # This section creates service applications and required + # dependencies + #********************************************************** + + $serviceAppPoolName = "SharePoint Service Applications" + SPServiceAppPool MainServiceAppPool + { + Name = $serviceAppPoolName + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]CreateSPFarm" + } + + SPSecureStoreServiceApp SecureStoreServiceApp + { + Name = "Secure Store Service Application" + ApplicationPool = $serviceAppPoolName + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = "SP_SecureStore" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPServiceAppPool]MainServiceAppPool" + } + + SPManagedMetaDataServiceApp ManagedMetadataServiceApp + { + Name = "Managed Metadata Service Application" + PsDscRunAsCredential = $SPSetupAccount + ApplicationPool = $serviceAppPoolName + DatabaseName = "SP_MMS" + DependsOn = "[SPServiceAppPool]MainServiceAppPool" + } + + SPBCSServiceApp BCSServiceApp + { + Name = "BCS Service Application" + ApplicationPool = $serviceAppPoolName + DatabaseName = "SP_BCS" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = @('[SPServiceAppPool]MainServiceAppPool', '[SPSecureStoreServiceApp]SecureStoreServiceApp') + } + + SPSearchServiceApp SearchServiceApp + { + Name = "Search Service Application" + DatabaseName = "SP_Search" + ApplicationPool = $serviceAppPoolName + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPServiceAppPool]MainServiceAppPool" + } + + #********************************************************** + # Local configuration manager settings + # + # This section contains settings for the LCM of the host + # that this configuraiton is applied to + #********************************************************** + LocalConfigurationManager + { + RebootNodeIfNeeded = $true + } + } + + node "Server2" + { + #********************************************************** + # Install Binaries + # + # This section installs SharePoint and its Prerequisites + #********************************************************** + + SPInstallPrereqs InstallPrereqs { + IsSingleInstance = "Yes" + Ensure = "Present" + InstallerPath = "C:\binaries\prerequisiteinstaller.exe" + OnlineMode = $true + } + + SPInstall InstallSharePoint { + IsSingleInstance = "Yes" + Ensure = "Present" + BinaryDir = "C:\binaries\" + ProductKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" + DependsOn = "[SPInstallPrereqs]InstallPrereqs" + } + + #********************************************************** + # Basic farm configuration + # + # This section creates the new SharePoint farm object, and + # provisions generic services and components used by the + # whole farm + #********************************************************** + SPFarm JoinSPFarm + { + IsSingleInstance = "Yes" + Ensure = "Present" + DatabaseServer = "sql.contoso.com" + FarmConfigDatabaseName = "SP_Config" + Passphrase = $Passphrase + FarmAccount = $FarmAccount + PsDscRunAsCredential = $SPSetupAccount + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $false + DependsOn = "[SPInstall]InstallSharePoint" + } + + SPDistributedCacheService EnableDistributedCache + { + Name = "AppFabricCachingService" + Ensure = "Present" + CacheSizeInMB = 1024 + ServiceAccount = $ServicePoolManagedAccount.UserName + PsDscRunAsCredential = $SPSetupAccount + CreateFirewallRules = $true + DependsOn = "[SPFarm]JoinSPFarm" + } + + #********************************************************** + # Service instances + # + # This section describes which services should be running + # and not running on the server + #********************************************************** + + SPServiceInstance ClaimsToWindowsTokenServiceInstance + { + Name = "Claims to Windows Token Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]JoinSPFarm" + } + + SPServiceInstance ManagedMetadataServiceInstance + { + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]JoinSPFarm" + } + + SPServiceInstance BCSServiceInstance + { + Name = "Business Data Connectivity Service" + Ensure = "Present" + PsDscRunAsCredential = $SPSetupAccount + DependsOn = "[SPFarm]JoinSPFarm" + } + + #********************************************************** + # IMPORTANT NOTE: The following section configures the + # bindings for the web application, so the web application + # must already exist. Since this example configures the + # web application on Server1, we need to either start the + # DSC configuration on Server1 first and wait until the + # web application has been created, or use a WaitForAll + # resource here to ensure the SPWebApplication resource + # finishes successfully on Server1 before configuring the + # bindings here on Server2. Note the DependsOn below that's + # commented out. + #********************************************************** + + #********************************************************** + # This resource depends on module xWebAdministration and + # uses SNI to bind to a specific hostname. If you don't + # want to use SNI, set SslFlags to 0. + #********************************************************** + xWebsite SslWebAppSharePointSites + { + Ensure = 'Present' + Name = "SharePoint Sites" + BindingInfo = @( + MSFT_xWebBindingInformation + { + Protocol = 'https' + IPAddress = '*' + Port = 443 + CertificateThumbprint = '' + CertificateStoreName = 'My' + HostName = 'sites.contoso.com' + SslFlags = 1 + } + ) + # DependsOn = '[WaitForAll]WebApplicationCreated' + } + + #********************************************************** + # Local configuration manager settings + # + # This section contains settings for the LCM of the host + # that this configuraiton is applied to + #********************************************************** + LocalConfigurationManager + { + RebootNodeIfNeeded = $true + } + } +} diff --git a/Modules/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/Modules/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index f3e9433e7..6035c6d1c 100644 --- a/Modules/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/Modules/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -95,6 +95,29 @@ function Convert-SPDscADGroupNameToID return ([Guid]::new($result.objectGUID.Value)) } +function Convert-SPDscHashtableToString +{ + param + ( + [System.Collections.Hashtable] + $Hashtable + ) + $first = $true + foreach($pair in $Hashtable.GetEnumerator()) + { + if ($first) + { + $first = $false + } + else + { + $output += '; ' + } + $output+="{0}={1}" -f $($pair.key),$($pair.Value) + } + return $output +} + function Get-SPDscOSVersion { [CmdletBinding()] @@ -370,7 +393,7 @@ function Invoke-SPDSCCommand try { - $result = Invoke-Command @invokeArgs -Verbose + return Invoke-Command @invokeArgs -Verbose } catch { @@ -385,7 +408,6 @@ function Invoke-SPDSCCommand throw $_ } } - return $result } else { @@ -420,7 +442,7 @@ function Invoke-SPDSCCommand try { - $result = Invoke-Command @invokeArgs -Verbose + return Invoke-Command @invokeArgs -Verbose } catch { @@ -440,7 +462,6 @@ function Invoke-SPDSCCommand { Remove-PSSession -Session $session } - return $result } } diff --git a/Modules/SharePointDsc/SharePointDsc.psd1 b/Modules/SharePointDsc/SharePointDsc.psd1 index 47bfb2614..17eb0ec98 100644 --- a/Modules/SharePointDsc/SharePointDsc.psd1 +++ b/Modules/SharePointDsc/SharePointDsc.psd1 @@ -12,7 +12,7 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '3.1.0.0' +ModuleVersion = '3.2.0.0' # ID used to uniquely identify this module GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' @@ -128,40 +128,70 @@ PrivateData = @{ # ReleaseNotes of this module ReleaseNotes = " - * Changes to SharePointDsc - * Updated LICENSE file to match the Microsoft Open Source Team standard. - * ProjectServerConnector - * Added a file hash validation check to prevent the ability to load custom code - into the module. + * Changes to SharePointDsc unit testing + * Implemented Strict Mode version 1 for all code run during unit tests. + * Changed InstallAccount into PSDscRunAsCredential parameter in examples + * SPAuthenticationRealm + * New resource for setting farm authentication realm + * SPConfigWizard + * Updated PSConfig parameters according recommendations in blog post of + Stefan Gossner + * SPDistributedCacheService + * Fixed exception on Stop-SPServiceInstance with SharePoint 2019 * SPFarm - * Fixed localization issue where TypeName was in the local language. + * Improved logging + * Added ability to manage the Developer Dashboard settings + * SPFarmSolution + * Fixed issue where uninstalling a solution would not work as expected if it + contained web application resources. + * SPIncomingEmailSettings + * New resource for configuring incoming email settings * SPInstallPrereqs - * Updated links in the Readme.md file to docs.microsoft.com. - * Fixed required prereqs for SharePoint 2019, added MSVCRT11. - * SPManagedMetadataServiceApp - * Fixed issue where Get-TargetResource method throws an error when the - service app proxy does not exist. - * SPSearchContentSource - * Corrected issue where the New-SPEnterpriseSearchCrawlContentSource cmdlet - was called twice. - * SPSearchServiceApp - * Fixed issue where Get-TargetResource method throws an error when the - service application pool does not exist. - * Implemented check to make sure cmdlets are only executed when it actually - has something to update. - * Deprecated WindowsServiceAccount parameter and moved functionality to - new resource (SPSearchServiceSettings). - * SPSearchServiceSettings - * Added new resource to configure search service settings. + * Improved logging + * Corrected detection for Windows Server 2019 + * Corrected support for Windows Server 2019 for SharePoint 2016 + * SPProductUpgrade + * Fixed issue where upgrading SP2013 would not properly detect the installed + version + * Fixed issue where the localized SharePoint 2019 CU was detected as a + Service Pack for a Language Pack + * SPSearchAuthorativePage + * Fixed issue where modifying search query would not target the correct + search application + * SPSearchResultSource + * Updated resource to allow localized ProviderTypes * SPServiceAppSecurity - * Fixed unavailable utility method (ExpandAccessLevel). - * Updated the schema to no longer specify username as key for the sub class. + * Updated resource to allow localized permission levels + * SPServiceInstance + * Added -All switch to resolve 'Unable to locate service application' in SP2013 + * SPSite + * Improved logging + * SPUserProfileProperty + * Fix user profile property mappings does not work * SPUserProfileServiceApp - * Fixed issue where localized versions of Windows and SharePoint would throw - an error. + * Added warning message when MySiteHostLocation is not specified. This is + currently not required, which results in an error. Will be corrected in + SPDsc v4.0 (is a breaking change). * SPUserProfileSyncConnection - * Corrected implementation of Ensure parameter. - " + * Fixed issue where test resource never would return true for any configurations + on SharePoint 2016/2019 + * Fixed issue where updating existing connection never would work for any + configurations on SharePoint 2016/2019 + * Updated documentation to reflect that Fore will not impact configurations for + SharePoint 2016/2019. Updated the test method accordingly. + * SPUserProfileSyncService + * Fixed issue where failure to configure the sync service would not throw error + * SPWebAppPeoplePickerSettings + * Converted password for access account to secure string. Previsouly + the resource would fail setting the password and an exeption was thrown that + printed the password in clear text. + * SPWebAppPolicy + * Fixed issue where parameter MembersToExclude did not work as expected + * SPWorkflowService + * Added support for specifying scope name. + * Added support for detecting incorrect configuration for scope name and + WorkflowHostUri +" } # End of PSData hashtable } # End of PrivateData hashtable diff --git a/Modules/SharePointDsc/en-US/about_SPAuthenticationRealm.help.txt b/Modules/SharePointDsc/en-US/about_SPAuthenticationRealm.help.txt new file mode 100644 index 000000000..4098b0467 --- /dev/null +++ b/Modules/SharePointDsc/en-US/about_SPAuthenticationRealm.help.txt @@ -0,0 +1,56 @@ +.NAME + SPAuthenticationRealm + +# Description + + **Type:** Distributed + **Requires CredSSP:** No + + This resource is used to set the authentication realm for a farm. + By default the authentication realm for a new farm installation + is the same as the farm id. + + Note: + + SharePoint automatically converts the realm to lower case ASCII printable characters. + The specified authentication realm must therefore conform to this for the test + method to be able to detect a correct configuration. + +.PARAMETER IsSingleInstance + Key - String + Allowed values: Yes + Specifies the resource is a single instance, the value must be 'Yes' + +.PARAMETER AuthenticationRealm + Required - String + The authentication realm to be set + +.PARAMETER InstallAccount + Write - String + POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5 + + +.EXAMPLE + This example sets the farm atuhentication realm. + + + Configuration Example + { + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPAuthenticationRealm AuthenticationRealm + { + IsSingleInstance = "Yes" + AuthenticationRealm = "14757a87-4d74-4323-83b9-fb1e77e8f22f" + PsDscRunAsCredential = $SetupAccount + } + } + } + + diff --git a/Modules/SharePointDsc/en-US/about_SPBCSServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPBCSServiceApp.help.txt index c213a52d2..15c05165d 100644 --- a/Modules/SharePointDsc/en-US/about_SPBCSServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPBCSServiceApp.help.txt @@ -50,10 +50,10 @@ .EXAMPLE This example shows how to deploy a Business Connectivity Services application to the - local SharePoint farm. + local SharePoint farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -65,11 +65,11 @@ node localhost { SPBCSServiceApp BCSServiceApp { - Name = "BCS Service Application" - ApplicationPool = "SharePoint Service Applications" - DatabaseName = "SP_BCS" - DatabaseServer = "SQL.contoso.local\SQLINSTANCE" - InstallAccount = $SetupAccount + Name = "BCS Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseName = "SP_BCS" + DatabaseServer = "SQL.contoso.local\SQLINSTANCE" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt b/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt index d2387c7e4..aa26c70a7 100644 --- a/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPDistributedCacheService.help.txt @@ -65,7 +65,7 @@ other cache hosts. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -80,7 +80,7 @@ Name = "AppFabricCachingService" CacheSizeInMB = 8192 ServiceAccount = "DEMO\ServiceAccount" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount CreateFirewallRules = $true } } @@ -89,12 +89,12 @@ .EXAMPLE This example applies the distributed cache service to the current server, - but will not apply the rules to allow it to communicate with other cache + but will not apply the rules to allow it to communicate with other cache hosts to the Windows Firewall. Use this approach if you have an alternate firewall solution. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -109,7 +109,7 @@ Name = "AppFabricCachingService" CacheSizeInMB = 8192 ServiceAccount = "DEMO\ServiceAccount" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount CreateFirewallRules = $false } } @@ -119,7 +119,7 @@ .EXAMPLE This example applies the distributed cache service to both "server1" and "server2". The ServerProvisionOrder will ensure that it applies it to - server1 first and then server2, making sure they don't both attempt to + server1 first and then server2, making sure they don't both attempt to create the cache at the same time, resuling in errors. Note: Do not allow plain text passwords in production environments. @@ -138,7 +138,7 @@ ) } - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -146,8 +146,8 @@ $SetupAccount ) Import-DscResource -ModuleName SharePointDsc - - node "Server1" + + node "Server1" { SPDistributedCacheService EnableDistributedCache { @@ -156,7 +156,7 @@ ServiceAccount = "DEMO\ServiceAccount" ServerProvisionOrder = @("Server1","Server2") CreateFirewallRules = $true - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } @@ -169,7 +169,7 @@ ServiceAccount = "DEMO\ServiceAccount" ServerProvisionOrder = @("Server1","Server2") CreateFirewallRules = $true - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPExcelServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPExcelServiceApp.help.txt index 217884c77..4c38fc440 100644 --- a/Modules/SharePointDsc/en-US/about_SPExcelServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPExcelServiceApp.help.txt @@ -106,7 +106,7 @@ This example shows how to deploy Excel Services to the local SharePoint farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -118,9 +118,9 @@ node localhost { SPExcelServiceApp ExcelServices { - Name = "Excel Services Service Application" - ApplicationPool = "SharePoint Service Applications" - InstallAccount = $SetupAccount + Name = "Excel Services Service Application" + ApplicationPool = "SharePoint Service Applications" + PsDscRunAsCredential = $SetupAccount } } } @@ -129,10 +129,10 @@ .EXAMPLE This example shows how to remove Excel Services from the local SharePoint farm. Here application pool is a required parameter, but it is not actually used when - removing a service app and as such can be ignored and set to any value. + removing a service app and as such can be ignored and set to any value. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -144,10 +144,10 @@ node localhost { SPExcelServiceApp ExcelServices { - Name = "Excel Services Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Excel Services Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPFarm.help.txt b/Modules/SharePointDsc/en-US/about_SPFarm.help.txt index de881fe49..5079a0b4e 100644 --- a/Modules/SharePointDsc/en-US/about_SPFarm.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPFarm.help.txt @@ -37,13 +37,21 @@ specified, it defaults to NTLM. If using Kerberos, make sure to have appropriate SPNs setup for Farm account and Central Administration URI. + DeveloperDashboard can be specified as "On", "Off" and (only when using + SharePoint 2013) to "OnDemand". + + NOTE: + When using SharePoint 2016 and later and enabling the Developer Dashboard, + please make sure you also provision the Usage and Health service application + to make sure the Developer Dashboard works properly. + .PARAMETER IsSingleInstance Key - String Allowed values: Yes Specifies the resource is a single instance, the value must be 'Yes' .PARAMETER Ensure - Write - string + Write - String Allowed values: Present, Absent Present to create/join the farm. Absent is currently not supported @@ -72,7 +80,7 @@ Should the central admin site run on this specific server? .PARAMETER CentralAdministrationPort - Write - uint32 + Write - Uint32 What port will Central Admin be provisioned to - default is 9999 .PARAMETER CentralAdministrationAuth @@ -81,10 +89,15 @@ The authentication provider of the CentralAdministration web application .PARAMETER ServerRole - Write - string + Write - String Allowed values: Application, ApplicationWithSearch, Custom, DistributedCache, Search, SingleServer, SingleServerFarm, WebFrontEnd, WebFrontEndWithDistributedCache SharePoint 2016 & 2019 only - the MinRole role to enroll this server as +.PARAMETER DeveloperDashboard + Write - String + Allowed values: Off, On, OnDemand + Specifies the state of the Developer Dashboard ('OnDemand' is SP2013 only) + .PARAMETER InstallAccount Write - String POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5 diff --git a/Modules/SharePointDsc/en-US/about_SPIncomingEmailSettings.help.txt b/Modules/SharePointDsc/en-US/about_SPIncomingEmailSettings.help.txt new file mode 100644 index 000000000..dd70dbad7 --- /dev/null +++ b/Modules/SharePointDsc/en-US/about_SPIncomingEmailSettings.help.txt @@ -0,0 +1,120 @@ +.NAME + SPIncomingEmailSettings + +# Description + + **Type:** Common + **Requires CredSSP:** No + + This resource is used to enable and configure SharePoint incoming email. + Setting the Ensure parameter to 'Present' or 'Absent' will enable or disable + incoming email accordingly. When enabled, this resource allows for configuring + of required parameters for both Automatic and Advanced methods of supporting + SharePoint incoming email. + + This resource does not currently support setting the Active Directory OU + where SharePoint can create mail contacts and distribution groups. + +.PARAMETER IsSingleInstance + Key - String + Allowed values: Yes + Specifies the resource is a single instance, the value must be 'Yes' + +.PARAMETER Ensure + Required - String + Allowed values: Present, Absent + Present ensures Incoming Email is enabled. Absent disables incoming email + +.PARAMETER UseAutomaticSettings + Write - Boolean + Automatic Settings enables a local SMTP service on the SharePoint server. Set to False to use an external drop folder + +.PARAMETER UseDirectoryManagementService + Write - string + Allowed values: Yes, No, Remote + Set to Yes, the service supports the creation and management of e-mail distribution groups from SharePoint Sites, and creates mail contacts mail enabled SharePoint lists. Set to Remote to use a remote SharePoint Directory Management Web Service + +.PARAMETER RemoteDirectoryManagementURL + Write - String + URL to the remote SharePoint Directory Management Web Service + +.PARAMETER ServerAddress + Write - String + SMTP Server Address when Directory Managment Service mode is used + +.PARAMETER DLsRequireAuthenticatedSenders + Write - Boolean + SharePoint Distribution lists accept from authenticated senders only + +.PARAMETER DistributionGroupsEnabled + Write - Boolean + Allow creation of distribution groups from within SharePoint + +.PARAMETER ServerDisplayAddress + Write - String + Email server display address 'mylist@example.com' + +.PARAMETER DropFolder + Write - String + Path to email drop folder if not using Automatic Settings + +.PARAMETER InstallAccount + Write - String + POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5 + + +.EXAMPLE + This example shows how to configure SharePoint Incoming Email in Automatic Mode + + +Configuration Example +{ + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPIncomingEmailSettings AutomaticEmail + { + IsSingleInstance = "Yes" + Ensure = "Present" + UseAutomaticSettings = $true + UseDirectoryManagementService = "No" + ServerDisplayAddress = "contoso.com" + PsDscRunAsCredential = $SetupAccount + } + } +} + + +.EXAMPLE + This example shows how to configure SharePoint Incoming Email in Advanced Mode + + +Configuration Example +{ + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPIncomingEmailSettings AutomaticEmail + { + IsSingleInstance = "Yes" + Ensure = "Present" + UseAutomaticSettings = $false + UseDirectoryManagementService = "No" + ServerDisplayAddress = "contoso.com" + DropFolder = "\\MailServer\Pickup" + PsDscRunAsCredential = $SetupAccount + } + } +} + + diff --git a/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceApp.help.txt index 7a7cb9ddd..60ae1d5ef 100644 --- a/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceApp.help.txt @@ -82,7 +82,7 @@ This example shows how to deploy the Managed Metadata service app to the local SharePoint farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -94,11 +94,11 @@ node localhost { SPManagedMetaDataServiceApp ManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount - ApplicationPool = "SharePoint Service Applications" - DatabaseServer = "SQL.contoso.local" - DatabaseName = "SP_ManagedMetadata" + Name = "Managed Metadata Service Application" + ApplicationPool = "SharePoint Service Applications" + DatabaseServer = "SQL.contoso.local" + DatabaseName = "SP_ManagedMetadata" + PsDscRunAsCredential = $SetupAccount } } } @@ -106,13 +106,13 @@ .EXAMPLE - This example shows how to remove a specific managed metadata service app from the + This example shows how to remove a specific managed metadata service app from the local SharePoint farm. Because Application pool parameter is required - but is not acutally needed to remove the app, any text value can - be supplied for these as it will be ignored. + but is not acutally needed to remove the app, any text value can + be supplied for these as it will be ignored. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -124,10 +124,10 @@ node localhost { SPManagedMetaDataServiceApp ManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount - ApplicationPool = "none" - Ensure = "Absent" + Name = "Managed Metadata Service Application" + ApplicationPool = "none" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } @@ -151,7 +151,7 @@ SPManagedMetaDataServiceApp ManagedMetadataServiceApp { Name = "Managed Metadata Service Application" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount ApplicationPool = "SharePoint Service Applications" DatabaseServer = "SQL.contoso.local" DatabaseName = "SP_ManagedMetadata" diff --git a/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceAppDefault.help.txt b/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceAppDefault.help.txt index db888be2f..5646b491e 100644 --- a/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceAppDefault.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPManagedMetaDataServiceAppDefault.help.txt @@ -51,7 +51,7 @@ Configuration Example IsSingleInstance = "Yes" DefaultSiteCollectionProxyName = "Managed Metadata Service Application Proxy" DefaultKeywordProxyName = "Managed Metadata Service Application Proxy" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPManagedPath.help.txt b/Modules/SharePointDsc/en-US/about_SPManagedPath.help.txt index 290bc0a98..fd77db72e 100644 --- a/Modules/SharePointDsc/en-US/about_SPManagedPath.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPManagedPath.help.txt @@ -47,7 +47,7 @@ This example shows how to deploy an explicit managed path to a specifici web application - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -57,13 +57,13 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "example" - Explicit = $true - HostHeader = $false + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "example" + Explicit = $true + HostHeader = $false + PsDscRunAsCredential = $SetupAccount } } } @@ -73,7 +73,7 @@ This example shows how to add a wildcard managed path to a specific web application - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -83,13 +83,13 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + PsDscRunAsCredential = $SetupAccount } } } @@ -99,7 +99,7 @@ This example shows how to remove a wildcard managed path from a specific web application - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -109,14 +109,14 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPManagedPath TestManagedPath + SPManagedPath TestManagedPath { - WebAppUrl = "http://sharepoint.contoso.com" - InstallAccount = $SetupAccount - RelativeUrl = "teams" - Explicit = $false - HostHeader = $true - Ensure = "Absent" + WebAppUrl = "http://sharepoint.contoso.com" + RelativeUrl = "teams" + Explicit = $false + HostHeader = $true + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPPerformancePointServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPPerformancePointServiceApp.help.txt index dce2562ff..7abb8a8e5 100644 --- a/Modules/SharePointDsc/en-US/about_SPPerformancePointServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPPerformancePointServiceApp.help.txt @@ -47,7 +47,7 @@ This example creates a new performance point service app in the local farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -59,9 +59,9 @@ node localhost { SPPerformancePointServiceApp PerformancePoint { - Name = "Performance Point Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Performance Point Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } @@ -70,10 +70,10 @@ .EXAMPLE This example removes the specific performance point service app from the local farm. The ApplicationPool parameter is still mandatory but it is not used, so - the value can be anything. + the value can be anything. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -85,10 +85,10 @@ node localhost { SPPerformancePointServiceApp PerformancePoint { - Name = "Performance Point Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Performance Point Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPProjectServerPermissionMode.help.txt b/Modules/SharePointDsc/en-US/about_SPProjectServerPermissionMode.help.txt index ec9426453..b6984f2bb 100644 --- a/Modules/SharePointDsc/en-US/about_SPProjectServerPermissionMode.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPProjectServerPermissionMode.help.txt @@ -27,7 +27,7 @@ This example shows how to a specific PWA site to use SharePoint permission mode. -Configuration Example +Configuration Example { param( [Parameter(Mandatory = $true)] @@ -39,20 +39,20 @@ Configuration Example node localhost { SPProjectServerPermissionMode PermissionMode { - Url = "http://projects.contoso.com" - PermissionMode = "SharePoint" - InstallAccount = $SetupAccount + Url = "http://projects.contoso.com" + PermissionMode = "SharePoint" + PsDscRunAsCredential = $SetupAccount } } } .EXAMPLE - This example shows how to a specific PWA site to use Project server + This example shows how to a specific PWA site to use Project server permission mode. -Configuration Example +Configuration Example { param( [Parameter(Mandatory = $true)] @@ -64,9 +64,9 @@ Configuration Example node localhost { SPProjectServerPermissionMode PermissionMode { - Url = "http://projects.contoso.com" - PermissionMode = "ProjectServer" - InstallAccount = $SetupAccount + Url = "http://projects.contoso.com" + PermissionMode = "ProjectServer" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPProjectServerServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPProjectServerServiceApp.help.txt index 0e39cf7b2..3b09af3d0 100644 --- a/Modules/SharePointDsc/en-US/about_SPProjectServerServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPProjectServerServiceApp.help.txt @@ -58,7 +58,7 @@ in the local farm - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -70,9 +70,9 @@ node localhost { SPProjectServerServiceApp ProjectServiceApp { - Name = "Project Server Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Project Server Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } @@ -84,7 +84,7 @@ the value used here doesn't matter. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -96,10 +96,10 @@ node localhost { SPProjectServerServiceApp ProjectServiceApp { - Name = "Project Server Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Project Server Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPPublishServiceApplication.help.txt b/Modules/SharePointDsc/en-US/about_SPPublishServiceApplication.help.txt index 715c2ff59..fc39354f8 100644 --- a/Modules/SharePointDsc/en-US/about_SPPublishServiceApplication.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPPublishServiceApplication.help.txt @@ -40,10 +40,10 @@ .EXAMPLE This example shows how to ensure that the managed metadata service is published - within the farm. + within the farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -55,20 +55,20 @@ node localhost { SPPublishServiceApplication PublishManagedMetadataServiceApp { - Name = "Managed Metadata Service Application" - Ensure = "Present" - InstallAccount = $SetupAccount + Name = "Managed Metadata Service Application" + Ensure = "Present" + PsDscRunAsCredential = $SetupAccount } } } .EXAMPLE - This example shows how to ensure that the Secure Store Service is not - published within the farm. + This example shows how to ensure that the Secure Store Service is not + published within the farm. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -80,9 +80,9 @@ node localhost { SPPublishServiceApplication UnpublishSecureStoreServiceApp { - Name = "Secure Store Service Application" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Secure Store Service Application" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPSearchResultSource.help.txt b/Modules/SharePointDsc/en-US/about_SPSearchResultSource.help.txt index 0ce15567d..56f434a35 100644 --- a/Modules/SharePointDsc/en-US/about_SPSearchResultSource.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPSearchResultSource.help.txt @@ -17,12 +17,27 @@ * Remote People Provider * Remote SharePoint Provider + > **Important:** + > The above provider types are specific to the used localized version of SharePoint. + > Please make sure you use the correct localized values. Use the below script to + > check of all possible values. + The default value for the Ensure parameter is Present. When not specifying this parameter, the result source is created. To define a result source as global, use the value 'SSA' as the ScopeName value. + ## Script + + ``` PowerShell + $serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity "SearchServiceAppName" + + $fedManager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($serviceApp) + $providers = $fedManager.ListProviders() + $providers.Keys + ``` + .PARAMETER Name Key - String The name of the result source @@ -46,7 +61,6 @@ .PARAMETER ProviderType Required - String - Allowed values: Exchange Search Provider, Local People Provider, Local SharePoint Provider, OpenSearch Provider, Remote People Provider, Remote SharePoint Provider The provider type to use for the result source .PARAMETER ConnectionUrl diff --git a/Modules/SharePointDsc/en-US/about_SPSecureStoreServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPSecureStoreServiceApp.help.txt index f865daa12..05a8c583c 100644 --- a/Modules/SharePointDsc/en-US/about_SPSecureStoreServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPSecureStoreServiceApp.help.txt @@ -77,7 +77,7 @@ This example creates a new secure store service app. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -89,12 +89,12 @@ node localhost { SPSecureStoreServiceApp SecureStoreServiceApp { - Name = "Secure Store Service Application" - ApplicationPool = "SharePoint Service Applications" - AuditingEnabled = $true - AuditlogMaxSize = 30 - DatabaseName = "SP_SecureStore" - InstallAccount = $SetupAccount + Name = "Secure Store Service Application" + ApplicationPool = "SharePoint Service Applications" + AuditingEnabled = $true + AuditlogMaxSize = 30 + DatabaseName = "SP_SecureStore" + PsDscRunAsCredential = $SetupAccount } } } @@ -106,7 +106,7 @@ are able to be set to anything. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -118,11 +118,11 @@ node localhost { SPSecureStoreServiceApp SecureStoreServiceApp { - Name = "Secure Store Service Application" - ApplicationPool = "n/a" - AuditingEnabled = $false - InstallAccount = $SetupAccount - Ensure = "Absent" + Name = "Secure Store Service Application" + ApplicationPool = "n/a" + AuditingEnabled = $false + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPServiceAppSecurity.help.txt b/Modules/SharePointDsc/en-US/about_SPServiceAppSecurity.help.txt index 991887cff..8768e73e9 100644 --- a/Modules/SharePointDsc/en-US/about_SPServiceAppSecurity.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPServiceAppSecurity.help.txt @@ -25,6 +25,13 @@ ## Permission overview + > **Important** + > When using localized versions of Windows and/or SharePoint, it is possible + > that permissions levels are also in the local language. In that case, use + > the localized permissions levels. All possible values can be retrieved using + > the script at the bottom of this page. The below permissions are the English + > versions. + Available permissions for Administrators are Full Control except for these service applications: @@ -64,6 +71,18 @@ will include all other permissions. It is not required to specify all available permissions if Full Control is specified. + ## Script + + ``` PowerShell + $serviceApp = Get-SPServiceApplication -Name "ServiceAppName" + + $perms = Get-SPServiceApplicationSecurity -Identity $serviceApp + $perms.NamedAccessRights.Name + + $perms = Get-SPServiceApplicationSecurity -Identity $serviceApp -Admin + $perms.NamedAccessRights.Name + ``` + .PARAMETER ServiceAppName Key - String The name of the service application you wish to apply security settings to diff --git a/Modules/SharePointDsc/en-US/about_SPServiceInstance.help.txt b/Modules/SharePointDsc/en-US/about_SPServiceInstance.help.txt index 68330cf6d..234778b9b 100644 --- a/Modules/SharePointDsc/en-US/about_SPServiceInstance.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPServiceInstance.help.txt @@ -29,10 +29,10 @@ .EXAMPLE This example shows how to ensure that the managed metadata service is running - on the local server. + on the local server. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -44,20 +44,20 @@ node localhost { SPServiceInstance ManagedMetadataServiceInstance { - Name = "Managed Metadata Web Service" - Ensure = "Present" - InstallAccount = $SetupAccount + Name = "Managed Metadata Web Service" + Ensure = "Present" + PsDscRunAsCredential = $SetupAccount } } } .EXAMPLE - This example shows how to ensure that the Business Data Connectivity Service - is not running on the local server. + This example shows how to ensure that the Business Data Connectivity Service + is not running on the local server. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -69,9 +69,9 @@ node localhost { SPServiceInstance StopBCSServiceInstance { - Name = "Business Data Connectivity Service" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Business Data Connectivity Service" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPUsageApplication.help.txt b/Modules/SharePointDsc/en-US/about_SPUsageApplication.help.txt index 8654c0986..7a78137dc 100644 --- a/Modules/SharePointDsc/en-US/about_SPUsageApplication.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPUsageApplication.help.txt @@ -63,7 +63,7 @@ This example deploys a usage application to the local farm - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -73,7 +73,7 @@ Import-DscResource -ModuleName SharePointDsc node localhost { - SPUsageApplication UsageApplication + SPUsageApplication UsageApplication { Name = "Usage Service Application" DatabaseName = "SP_Usage" @@ -81,7 +81,7 @@ UsageLogLocation = "L:\UsageLogs" UsageLogMaxFileSizeKB = 1024 Ensure = "Present" - InstallAccount = $SetupAccount + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPUserProfileServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPUserProfileServiceApp.help.txt index eaaa0d399..40cf7d83e 100644 --- a/Modules/SharePointDsc/en-US/about_SPUserProfileServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPUserProfileServiceApp.help.txt @@ -35,6 +35,10 @@ implications. More information about these risks can be found at: http://www.powershellmagazine.com/2014/03/06/accidental-sabotage-beware-of-credssp/ + NOTE2: + You should always specify the MySiteHostLocation parameter. Currently this is not + a required parameter, but will be as of SharePointDsc v4.0. + .PARAMETER Name Key - string The name of the user profile service diff --git a/Modules/SharePointDsc/en-US/about_SPUserProfileSyncConnection.help.txt b/Modules/SharePointDsc/en-US/about_SPUserProfileSyncConnection.help.txt index 7504a3caf..9f39949a0 100644 --- a/Modules/SharePointDsc/en-US/about_SPUserProfileSyncConnection.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPUserProfileSyncConnection.help.txt @@ -11,6 +11,13 @@ This resource currently supports AD only. + Force only works with SharePoint 2013. For SharePoint 2016/2019 + the resource is not able to remove existing OUs. + You will have to use the ExcludedOUs for this. This means you need + to know which OUs to remove. If any extra OUs exists after the + configuration has run the test method will report the resource not + in desired state. + .PARAMETER Name Key - string The name of the connection @@ -29,11 +36,11 @@ .PARAMETER IncludedOUs Required - string - A list of the OUs to import users from + A list of the OUs to import users from. For SharePoint 2016/2019 existing OUs will not be removed if not included in this list. Use ExludedOUs for removing OUs in SharePoint 2016/2019 .PARAMETER ExcludedOUs Write - string - A list of the OUs to ignore users from + A list of the OUs to ignore users from. For SharePoint 2016/2019 matching existing OUs to include are removed. .PARAMETER Server Write - string @@ -53,7 +60,7 @@ .PARAMETER Force Write - boolean - Set to true to run the set method on every call to this resource + Set to true to run the set method on every call to this resource. Only has effect on SharePoint 2013 .PARAMETER ConnectionType Write - string diff --git a/Modules/SharePointDsc/en-US/about_SPUserProfileSyncService.help.txt b/Modules/SharePointDsc/en-US/about_SPUserProfileSyncService.help.txt index 42ae55316..d0814a799 100644 --- a/Modules/SharePointDsc/en-US/about_SPUserProfileSyncService.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPUserProfileSyncService.help.txt @@ -56,7 +56,7 @@ This example provisions the user profile sync service to the local server - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -72,11 +72,11 @@ node localhost { SPUserProfileSyncService UserProfileSyncService { - UserProfileServiceAppName = "User Profile Service Application" - Ensure = "Present" - FarmAccount = $FarmAccount - RunOnlyWhenWriteable = $true - InstallAccount = $SetupAccount + UserProfileServiceAppName = "User Profile Service Application" + Ensure = "Present" + FarmAccount = $FarmAccount + RunOnlyWhenWriteable = $true + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPVisioServiceApp.help.txt b/Modules/SharePointDsc/en-US/about_SPVisioServiceApp.help.txt index 5a7cf1b9c..f2064e744 100644 --- a/Modules/SharePointDsc/en-US/about_SPVisioServiceApp.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPVisioServiceApp.help.txt @@ -39,7 +39,7 @@ This example shows how to create a new visio services service app in the local farm - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -51,9 +51,9 @@ node localhost { SPVisioServiceApp VisioServices { - Name = "Visio Graphics Service Application" - ApplicationPool = "SharePoint Web Services" - InstallAccount = $SetupAccount + Name = "Visio Graphics Service Application" + ApplicationPool = "SharePoint Web Services" + PsDscRunAsCredential = $SetupAccount } } } @@ -65,7 +65,7 @@ the value used here doesn't matter. - Configuration Example + Configuration Example { param( [Parameter(Mandatory = $true)] @@ -77,10 +77,10 @@ node localhost { SPVisioServiceApp VisioServices { - Name = "Visio Graphics Service Application" - ApplicationPool = "n/a" - Ensure = "Absent" - InstallAccount = $SetupAccount + Name = "Visio Graphics Service Application" + ApplicationPool = "n/a" + Ensure = "Absent" + PsDscRunAsCredential = $SetupAccount } } } diff --git a/Modules/SharePointDsc/en-US/about_SPWebAppBlockedFileTypes.help.txt b/Modules/SharePointDsc/en-US/about_SPWebAppBlockedFileTypes.help.txt index 9c1e71b49..250c210c4 100644 --- a/Modules/SharePointDsc/en-US/about_SPWebAppBlockedFileTypes.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPWebAppBlockedFileTypes.help.txt @@ -57,7 +57,7 @@ node localhost { SPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" EnsureBlocked = @("exe", "dll", "msi") EnsureAllowed = @("pdf", "docx", "xlsx") PsDscRunAsCredential = $SetupAccount @@ -83,7 +83,7 @@ node localhost { SPWebAppBlockedFileTypes PrimaryWebAppBlockedFileTypes { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" Blocked = @("exe", "dll", "msi") PsDscRunAsCredential = $SetupAccount } diff --git a/Modules/SharePointDsc/en-US/about_SPWebAppGeneralSettings.help.txt b/Modules/SharePointDsc/en-US/about_SPWebAppGeneralSettings.help.txt index 8825ced80..f39677ea4 100644 --- a/Modules/SharePointDsc/en-US/about_SPWebAppGeneralSettings.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPWebAppGeneralSettings.help.txt @@ -119,7 +119,7 @@ node localhost { SPWebAppGeneralSettings PrimaryWebAppGeneralSettings { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" TimeZone = 76 Alerts = $true RSS = $false diff --git a/Modules/SharePointDsc/en-US/about_SPWebAppThrottlingSettings.help.txt b/Modules/SharePointDsc/en-US/about_SPWebAppThrottlingSettings.help.txt index 8e62dc284..f9cba718a 100644 --- a/Modules/SharePointDsc/en-US/about_SPWebAppThrottlingSettings.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPWebAppThrottlingSettings.help.txt @@ -83,7 +83,7 @@ node localhost { SPWebAppThrottlingSettings PrimaryWebAppThrottlingSettings { - WebAppUrl = "http://exmaple.contoso.local" + WebAppUrl = "http://example.contoso.local" ListViewThreshold = 5000 AllowObjectModelOverride = $false HappyHourEnabled = $true diff --git a/Modules/SharePointDsc/en-US/about_SPWebAppWorkflowSettings.help.txt b/Modules/SharePointDsc/en-US/about_SPWebAppWorkflowSettings.help.txt index 656211252..c6986127b 100644 --- a/Modules/SharePointDsc/en-US/about_SPWebAppWorkflowSettings.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPWebAppWorkflowSettings.help.txt @@ -49,7 +49,7 @@ node localhost { SPWebAppWorkflowSettings PrimaryWebAppWorkflowSettings { - WebAppUrl = "Shttp://exmaple.contoso.local" + WebAppUrl = "Shttp://example.contoso.local" ExternalWorkflowParticipantsEnabled = $false EmailToNoPermissionWorkflowParticipantsEnable = $false PsDscRunAsCredential = $SetupAccount diff --git a/Modules/SharePointDsc/en-US/about_SPWorkflowService.help.txt b/Modules/SharePointDsc/en-US/about_SPWorkflowService.help.txt index 62304ade7..1de03496f 100644 --- a/Modules/SharePointDsc/en-US/about_SPWorkflowService.help.txt +++ b/Modules/SharePointDsc/en-US/about_SPWorkflowService.help.txt @@ -12,6 +12,14 @@ Requirements: Provide the url of the Workflow Manager instance to connect to. + Scope name is optional and defaults to SharePoint. + If scope name is not specified any configured scope name is + allowed by this resource. + + Remarks + + Change or configuration drift for AllowOAuthHttp is not detected + by this resource. .PARAMETER WorkflowHostUri Key - string @@ -21,6 +29,10 @@ Key - String The URL of the Site Collection to associate with the Workflow Service Proxy +.PARAMETER ScopeName + Write - String + Specify scope name. If not specified SharePoint will use the default scope name 'SharePoint' + .PARAMETER AllowOAuthHttp Write - Boolean Specify whether or not to allow connection to the Workflow Service over Http @@ -55,3 +67,29 @@ } +.EXAMPLE + This example registers the workflow service specifying a custom scope name. + + + Configuration Example + { + param( + [Parameter(Mandatory = $true)] + [PSCredential] + $SetupAccount + ) + Import-DscResource -ModuleName SharePointDsc + + node localhost { + SPWorkflowService WorkflowService + { + WorkflowHostUri = "http://workflow.sharepoint.contoso.com" + ScopeName = "SharePointWorkflow" + SPSiteUrl = "http://sites.sharepoint.com" + AllowOAuthHttp = $true + PsDscRunAsCredential = $SetupAccount + } + } + } + + diff --git a/Tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 index 0671f2308..e91e27fca 100644 --- a/Tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 @@ -1,7 +1,7 @@ [CmdletBinding()] param( [Parameter()] - [string] + [string] $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot ` -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" ` -Resolve) @@ -21,7 +21,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { # Initialize tests $getTypeFullName = "Microsoft.Office.Server.PowerPoint.Administration.PowerPointConversionServiceApplication" - # Mocks for all + # Mocks for all Mock -CommandName Get-SPServiceApplication -MockWith { } Mock -CommandName Get-SPServiceApplicationPool -MockWith { } Mock -CommandName Get-SPServiceApplicationProxy -MockWith { } @@ -30,7 +30,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPPowerPointConversionServiceApplicationProxy -MockWith { } Mock -CommandName Remove-SPServiceApplication -MockWith { } - # Test contexts + # Test contexts Context -Name "When Ensure is Absent and we specify additional paramters" -Fixture { $testParams = @{ Name = "Power Point Automation Service Application" @@ -43,12 +43,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { WorkerTimeoutInSeconds = 300 Ensure = "Absent" } - - It "Should throw an exception as additional parameters are not allowed when Ensure = 'Absent'" { + + It "Should throw an exception as additional parameters are not allowed when Ensure = 'Absent'" { { Get-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" { Test-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" - { Set-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" - } + { Set-TargetResource @testParams } | Should throw "You cannot use any of the parameters when Ensure is specified as Absent" + } } Context -Name "When Ensure is Present but we don't specify an ApplicationPool" -Fixture { @@ -63,18 +63,18 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplicationPool -MockWith { + Mock -CommandName Get-SPServiceApplicationPool -MockWith { return $null - } - - It "Should throw an exception as additional parameters are not allowed when Ensure = 'Absent'" { + } + + It "Should throw an exception as additional parameters are not allowed when Ensure = 'Absent'" { { Get-TargetResource @testParams } | Should throw "An Application Pool is required to configure the PowerPoint Automation Service Application" { Test-TargetResource @testParams } | Should throw "An Application Pool is required to configure the PowerPoint Automation Service Application" { Set-TargetResource @testParams } | Should throw "An Application Pool is required to configure the PowerPoint Automation Service Application" - } + } } - + Context -Name "When no service applications exist in the current farm" -Fixture { $testParams = @{ @@ -89,14 +89,14 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplicationPool -MockWith { - return @{ - Name = $testParams.ApplicationPool - } + Mock -CommandName Get-SPServiceApplicationPool -MockWith { + return @{ + Name = $testParams.ApplicationPool + } } - - Mock -CommandName New-SPPowerPointConversionServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + + Mock -CommandName New-SPPowerPointConversionServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = 0 @@ -107,8 +107,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name Update ` - -Value { - return @{ + -Value { + return @{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds @@ -116,18 +116,18 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { WorkerKeepAliveTimeoutInSeconds = $testParams.WorkerKeepAliveTimeoutInSeconds WorkerProcessCount = $testParams.WorkerProcessCount WorkerTimeoutInSeconds = $testParams.WorkerTimeoutInSeconds - } - } -PassThru -Force + } + } -PassThru -Force return $($spServiceApp) - + } Mock -CommandName New-SPPowerPointConversionServiceApplicationProxy -MockWith { } - Mock -CommandName Get-SPServiceApplication -MockWith { - return $null + Mock -CommandName Get-SPServiceApplication -MockWith { + return $null } - + It "Should return absent from the Get method" { - (Get-TargetResource @testParams).Ensure | Should Be "Absent" + (Get-TargetResource @testParams).Ensure | Should Be "Absent" } It "Should return false when the Test method is called" { Test-TargetResource @testParams | Should Be $false @@ -154,15 +154,15 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - - Mock -CommandName Get-SPServiceApplicationPool -MockWith { - return @{ - Name = $testParams.ApplicationPool - } + + Mock -CommandName Get-SPServiceApplicationPool -MockWith { + return @{ + Name = $testParams.ApplicationPool + } } - Mock -CommandName New-SPPowerPointConversionServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + Mock -CommandName New-SPPowerPointConversionServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = 0 @@ -173,8 +173,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name Update ` - -Value { - return @{ + -Value { + return @{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds @@ -182,35 +182,35 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { WorkerKeepAliveTimeoutInSeconds = $testParams.WorkerKeepAliveTimeoutInSeconds WorkerProcessCount = $testParams.WorkerProcessCount WorkerTimeoutInSeconds = $testParams.WorkerTimeoutInSeconds - } - } -PassThru -Force + } + } -PassThru -Force return $($spServiceApp) - + } - + Mock -CommandName New-SPPowerPointConversionServiceApplicationProxy -MockWith { } - + Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ - DisplayName = $testParams.Name + $spServiceApp = [PSCustomObject]@{ + DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } - } + } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = "Microsoft.Office.UnKnownWebServiceApplication" - } - } -PassThru -Force - return $($spServiceApp) + -Value { + return @{ + FullName = "Microsoft.Office.UnKnownWebServiceApplication" + } + } -PassThru -Force + return $($spServiceApp) } It "Should return 'Absent' from the Get method" { - (Get-TargetResource @testParams).Ensure | Should Be "Absent" + (Get-TargetResource @testParams).Ensure | Should Be "Absent" } It "Should return 'false' from the Test method" { - Test-TargetResource @testParams | Should Be $false - } + Test-TargetResource @testParams | Should Be $false + } It "Should create a new Power Point Automation Service Application from the Set method" { Set-TargetResource @testParams Assert-MockCalled Get-SPServiceApplicationPool @@ -232,17 +232,17 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ - DisplayName = $testParams.Name - } + Mock -CommandName Get-SPServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ + DisplayName = $testParams.Name + } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = "Microsoft.Office.UnKnownWebServiceApplication" - } - } -PassThru -Force + -Value { + return @{ + FullName = "Microsoft.Office.UnKnownWebServiceApplication" + } + } -PassThru -Force return $($spServiceApp) } @@ -251,11 +251,11 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } It "Should return 'Absent' from the Get method" { - (Get-TargetResource @testParams).Ensure | Should Be "Absent" + (Get-TargetResource @testParams).Ensure | Should Be "Absent" } It "Should return 'false' from the Test method" { - Test-TargetResource @testParams | Should Be $false - } + Test-TargetResource @testParams | Should Be $false + } It "Should create a new Power Point Automation Service Application from the Set method" { { Set-TargetResource @testParams } | Should throw "Specified application pool does not exist" } @@ -274,8 +274,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + Mock -CommandName Get-SPServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds @@ -286,12 +286,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = $getTypeFullName - } - } -PassThru -Force - + -Value { + return @{ + FullName = $getTypeFullName + } + } -PassThru -Force + $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name IsConnected ` -Value { @@ -329,8 +329,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + Mock -CommandName Get-SPServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds @@ -338,15 +338,15 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { WorkerKeepAliveTimeoutInSeconds = $testParams.WorkerKeepAliveTimeoutInSeconds WorkerProcessCount = $testParams.WorkerProcessCount WorkerTimeoutInSeconds = $testParams.WorkerTimeoutInSeconds - + } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = $getTypeFullName - } - } -PassThru -Force + -Value { + return @{ + FullName = $getTypeFullName + } + } -PassThru -Force $spServiceApp = $spServiceApp | Add-Member -MemberType SCriptMethod ` -Name IsConnected ` -Value { @@ -354,8 +354,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } -PassThru -Force $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name Update ` - -Value { - return @{ + -Value { + return @{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds @@ -363,19 +363,19 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { WorkerKeepAliveTimeoutInSeconds = $testParams.WorkerKeepAliveTimeoutInSeconds WorkerProcessCount = $testParams.WorkerProcessCount WorkerTimeoutInSeconds = $testParams.WorkerTimeoutInSeconds - } - } -PassThru -Force - + } + } -PassThru -Force + return $($spServiceApp) } - Mock -CommandName Get-SPServiceApplicationPool -MockWith { - return @{ - Name = $testParams.ApplicationPool - } + Mock -CommandName Get-SPServiceApplicationPool -MockWith { + return @{ + Name = $testParams.ApplicationPool + } } - + Mock -CommandName Get-SPServiceApplicationProxy -MockWith { $spServiceAppProxy = [PSCustomObject]@{ @@ -386,7 +386,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { -Value { return $null } -PassThru -Force - + return $spServiceAppProxy } @@ -416,18 +416,18 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + Mock -CommandName Get-SPServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = "Other SharePoint Services App Pool" } } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = $getTypeFullName - } - } -PassThru -Force + -Value { + return @{ + FullName = $getTypeFullName + } + } -PassThru -Force return $spServiceApp } @@ -438,56 +438,56 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should Be $false } } - + Context -Name "When the service application exists but it shouldn't" -Fixture { $testParams = @{ Name = "Power Point Automation Service Application" Ensure = "Absent" } - Mock -CommandName Get-SPServiceApplication -MockWith { - $spServiceApp = [PSCustomObject]@{ + Mock -CommandName Get-SPServiceApplication -MockWith { + $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` - -Value { - return @{ - FullName = $getTypeFullName - } - } -PassThru -Force + -Value { + return @{ + FullName = $getTypeFullName + } + } -PassThru -Force return $spServiceApp } - + It "Should return present from the Get method" { - (Get-TargetResource @testParams).Ensure | Should Be "Present" + (Get-TargetResource @testParams).Ensure | Should Be "Present" } - + It "Should return false when the Test method is called" { Test-TargetResource @testParams | Should Be $false } - + It "Should call the remove service application cmdlet in the set method" { Set-TargetResource @testParams Assert-MockCalled Remove-SPServiceApplication } } - + Context -Name "When the service application doesn't exist and it shouldn't" -Fixture { $testParams = @{ Name = "Power Point Automation Service Application" Ensure = "Absent" } - Mock -CommandName Get-SPServiceApplication -MockWith { - return $null + Mock -CommandName Get-SPServiceApplication -MockWith { + return $null } - + It "Should return absent from the Get method" { - (Get-TargetResource @testParams).Ensure | Should Be "Absent" + (Get-TargetResource @testParams).Ensure | Should Be "Absent" } - + It "Should return true when the Test method is called" { Test-TargetResource @testParams | Should Be $true } @@ -506,8 +506,8 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" } - Mock -CommandName Get-SPServiceApplication -MockWith { - return $nulls + Mock -CommandName Get-SPServiceApplication -MockWith { + return $null } It "Should return Absent from the get method" { @@ -518,7 +518,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should Be $false } } - + } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPAuthenticationRealm.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPAuthenticationRealm.Tests.ps1 new file mode 100644 index 000000000..a78c67301 --- /dev/null +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPAuthenticationRealm.Tests.ps1 @@ -0,0 +1,62 @@ +[CmdletBinding()] +param( + [Parameter()] + [string] + $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot ` + -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" ` + -Resolve) +) + +Import-Module -Name (Join-Path -Path $PSScriptRoot ` + -ChildPath "..\UnitTestHelper.psm1" ` + -Resolve) + +$Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule ` + -DscResource "SPAuthenticationRealm" + +Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { + InModuleScope -ModuleName $Global:SPDscHelper.ModuleName -ScriptBlock { + Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + + Mock -CommandName Get-SPAuthenticationRealm { + return $Global:SPAuthenticationRealm + } + + Mock -CommandName Set-SPAuthenticationRealm { + $Global:SPAuthenticationRealm = $Realm + } + + Context -Name "Authentication realm matches the farm's current atuhentication realm" -Fixture { + $Global:SPAuthenticationRealm = "14757a87-4d74-4323-83b9-fb1e77e8f22f" + $testParams = @{ + IsSingleInstance = "Yes" + AuthenticationRealm = $Global:SPAuthenticationRealm + } + + It "Should return true from the set method" { + Test-TargetResource @testParams | Should Be $true + } + } + + Context -Name "Authentication realm does not match the farm's current atuhentication realm" -Fixture { + $Global:SPAuthenticationRealm = "11111111-1111-1111-1111-111111111111" + + $testParams = @{ + IsSingleInstance = "Yes" + AuthenticationRealm = "14757a87-4d74-4323-83b9-fb1e77e8f22f" + } + + It "Should return false from the set method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should modify the authentication realm in the set method" { + Set-TargetResource @testParams + Assert-MockCalled -CommandName Set-SPAuthenticationRealm -Times 1 + $Global:SPAuthenticationRealm | Should Be "14757a87-4d74-4323-83b9-fb1e77e8f22f" + } + } + } +} + +Invoke-Command -ScriptBlock $Global:SPDscHelper.CleanupScript -NoNewScope diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 index 2e4d52615..b358f82f1 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPFarm.Tests.ps1 @@ -28,6 +28,19 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.Farm\SPFarm.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) + try + { + [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel] + } + catch + { + Add-Type -TypeDefinition @" +namespace Microsoft.SharePoint.Administration { + public enum SPDeveloperDashboardLevel { On, OnDemand, Off }; +} +"@ + } + # Mocks for all contexts Mock -CommandName Add-SPDscConfigDBLock -MockWith { } Mock -CommandName Remove-SPDscConfigDBLock -MockWith { } @@ -49,7 +62,20 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { ProductBuildPart = $Global:SPDscHelper.CurrentStubBuildNumber.Build } } + Mock -CommandName Get-SPDSCContentService -MockWith { + $developerDashboardSettings = @{ + DisplayLevel = "Off" + } + $developerDashboardSettings = $developerDashboardSettings | Add-Member -MemberType ScriptMethod -Name Update -Value { + $Global:SPDscDevDashUpdated = $true + } -PassThru + + $returnVal = @{ + DeveloperDashboardSettings = $developerDashboardSettings + } + return $returnVal + } # Test Contexts Context -Name "No config databases exists, and this server should be connected to one" -Fixture { @@ -705,6 +731,101 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } } + Context -Name "Server is connected to a farm, but Developer Dashboard settings are incorrect" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $true + DeveloperDashboard = "On" + } + + Mock -CommandName "Get-SPDSCRegistryKey" -MockWith { + return "Connection string example" + } + + Mock -CommandName "Get-SPFarm" -MockWith { + return @{ + Name = $testParams.FarmConfigDatabaseName + DatabaseServer = @{ + Name = $testParams.DatabaseServer + } + AdminContentDatabaseName = $testParams.AdminContentDatabaseName + } + } + Mock -CommandName "Get-SPDSCConfigDBStatus" -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDSCSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + Mock -CommandName "Get-SPDatabase" -MockWith { + return @(@{ + Name = $testParams.FarmConfigDatabaseName + Type = "Configuration Database" + NormalizedDataSource = $testParams.DatabaseServer + }) + } + Mock -CommandName "Get-SPWebApplication" -MockWith { + return @{ + IsAdministrationWebApplication = $true + ContentDatabases = @(@{ + Name = $testParams.AdminContentDatabaseName + }) + IISSettings = @(@{ + DisableKerberos = $true + }) + Url = "http://localhost:9999" + } + } + Mock -CommandName "Get-SPServiceInstance" -MockWith { + if ($global:SPDscCentralAdminCheckDone -eq $true) + { + return @( + @{ + Name = "WSS_Administration" + Status = "Online" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + else + { + $global:SPDscCentralAdminCheckDone = $true + return $null + } + } + + It "Should return present from the get method" { + (Get-TargetResource @testParams).DeveloperDashboard | Should Be "Off" + } + + $Global:SPDscDevDashUpdated = $false + It "Should update DevDashboard settings in the set method" { + Set-TargetResource @testParams + $Global:SPDscDevDashUpdated | Should Be $true + } + + It "Should return true from the test method" { + Test-TargetResource @testParams | Should be $false + } + } + Context -Name "A config database exists, and this server is connected to it and should be" -Fixture { $testParams = @{ IsSingleInstance = "Yes" @@ -1005,6 +1126,99 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { { Set-TargetResource @testParams } | Should Not Throw } } + + Context -Name "DeveloperDashboard is set to OnDemand, which is not allowed in SP2016 and above" -Fixture { + $testParams = @{ + IsSingleInstance = "Yes" + Ensure = "Present" + FarmConfigDatabaseName = "SP_Config" + DatabaseServer = "sql.contoso.com" + FarmAccount = $mockFarmAccount + Passphrase = $mockPassphrase + AdminContentDatabaseName = "SP_AdminContent" + RunCentralAdmin = $true + DeveloperDashboard = "OnDemand" + } + + Mock -CommandName "Get-SPDSCRegistryKey" -MockWith { + return "Connection string example" + } + + Mock -CommandName "Get-SPFarm" -MockWith { + return @{ + Name = $testParams.FarmConfigDatabaseName + DatabaseServer = @{ + Name = $testParams.DatabaseServer + } + AdminContentDatabaseName = $testParams.AdminContentDatabaseName + } + } + Mock -CommandName "Get-SPDSCConfigDBStatus" -MockWith { + return @{ + Locked = $false + ValidPermissions = $true + DatabaseExists = $true + } + } + Mock -CommandName "Get-SPDSCSQLInstanceStatus" -MockWith { + return @{ + MaxDOPCorrect = $true + } + } + Mock -CommandName "Get-SPDatabase" -MockWith { + return @(@{ + Name = $testParams.FarmConfigDatabaseName + Type = "Configuration Database" + NormalizedDataSource = $testParams.DatabaseServer + }) + } + Mock -CommandName "Get-SPWebApplication" -MockWith { + return @{ + IsAdministrationWebApplication = $true + ContentDatabases = @(@{ + Name = $testParams.AdminContentDatabaseName + }) + IISSettings = @(@{ + DisableKerberos = $true + }) + Url = "http://localhost:9999" + } + } + Mock -CommandName "Get-SPServiceInstance" -MockWith { + if ($global:SPDscCentralAdminCheckDone -eq $true) + { + return @( + @{ + Name = "WSS_Administration" + Status = "Online" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + return @{ + Name = "SPWebServiceInstance" + } + } -PassThru -Force + ) + } + else + { + $global:SPDscCentralAdminCheckDone = $true + return $null + } + } + + It "Should throw and exception in the get method" { + { Get-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" + } + + It "Should throw and exception in the set method" { + { Set-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" + } + + It "Should throw and exception in the test method" { + { Test-TargetResource @testParams } | Should Throw "The DeveloperDashboard value 'OnDemand' is not allowed in SharePoint 2016 and 2019" + } + } } Context -Name "no serverrole is specified but get-targetresource needs to identify and return it" -Fixture { diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPIncomingEmailSettings.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPIncomingEmailSettings.Tests.ps1 new file mode 100644 index 000000000..3b76a2905 --- /dev/null +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPIncomingEmailSettings.Tests.ps1 @@ -0,0 +1,598 @@ +[CmdletBinding()] +param( + [Parameter()] + [string] + $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot ` + -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" ` + -Resolve) +) + +Import-Module -Name (Join-Path -Path $PSScriptRoot ` + -ChildPath "..\UnitTestHelper.psm1" ` + -Resolve) + +$Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule ` + -DscResource "SPIncomingEmailSettings" + +Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { + InModuleScope -ModuleName $Global:SPDscHelper.ModuleName -ScriptBlock { + Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + + # Initialize tests + + # Mocks for all contexts + Mock -CommandName 'Get-SPServiceInstance' -MockWith { + $serviceInstance = + @{ + Service = @{ + Enabled = $mock.Enabled + DropFolder = $mock.DropFolder + UseAutomaticSettings = $mock.UseAutomaticSettings + ServerDisplayAddress = $mock.ServerDisplayAddress + ServerAddress = $mock.ServerAddress + UseDirectoryManagementService = $mock.UseDirectoryManagementService + RemoteDirectoryManagementService = $mock.RemoteDirectoryManagementService + DirectoryManagementServiceURL = $mock.DirectoryManagementServiceURL + DistributionGroupsEnabled = $mock.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $mock.DLsRequireAuthenticatedSenders + } + } + $serviceInstance = $serviceInstance | Add-Member -MemberType ScriptMethod -Name GetType -Value { + return @{ FullName = "Microsoft.SharePoint.Administration.SPIncomingEmailServiceInstance"} } -force -PassThru + $serviceInstance.Service = $serviceInstance.Service | Add-Member -MemberType ScriptMethod -Name GetType -Value { + return @{ FullName = "Microsoft.SharePoint.Administration.SPIncomingEmailService"} } -force -PassThru + $serviceInstance.Service = $serviceInstance.Service | Add-Member -MemberType ScriptMethod -Name Update -Value { + $Global:SPDscUpdateCalled = $true } -PassThru + return @($serviceInstance) + } + + # Test contexts + Context -Name 'Cannot retrieve instance of mail service' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $true + ServerDisplayAddress = "contoso.com" + } + + Mock -CommandName 'Get-SPServiceInstance' -MockWith { + $serviceInstance = @{} + $serviceInstance = $serviceInstance | Add-Member -MemberType ScriptMethod -Name GetType -Value { + return $null } -force -PassThru + return @($serviceInstance) + } + + It 'Should return null values for the Get method' { + $result = Get-TargetResource @testParams + $result.Ensure | Should BeNullorEmpty + $result.UseAutomaticSettings | Should BeNullorEmpty + $result.UseDirectoryManagementService | Should BeNullorEmpty + $result.RemoteDirectoryManagementURL | Should BeNullorEmpty + $result.ServerAddress | Should BeNullorEmpty + $result.DLsRequireAuthenticatedSenders| Should BeNullorEmpty + $result.DistributionGroupsEnabled | Should BeNullorEmpty + $result.ServerDisplayAddress| Should BeNullorEmpty + $result.DropFolder | Should BeNullorEmpty + } + + It 'Should return false for the Test method' { + Test-TargetResource @testParams | Should Be $false + } + + It 'Should throw and exception for the Set method' { + { Set-TargetResource @testParams } | Should throw "Error getting the SharePoint Incoming Email Service" + } + } + + Context -Name 'When configured values are correct' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + TypeName = 'Microsoft SharePoint Foundation Incoming E-Mail' + Enabled = $true + DropFolder = $testParams.DropFolder + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $testParams.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should Be $testParams.DropFolder + } + + It "Should return True for the Test method" { + Test-TargetResource @testParams | Should Be $true + } + + } + + Context -Name 'When configured values are incorrect' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = (-not $testParams.UseAutomaticSettings) + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $false + DirectoryManagementServiceURL = $null + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be (-not $testParams.UseAutomaticSettings) + $result.UseDirectoryManagementService | Should Be $true + $result.RemoteDirectoryManagementURL | Should BeNullorEmpty + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should update settings for the Set method" { + Set-TargetResource @testParams + $Global:SPDscUpdateCalled | Should Be $true + } + } + + Context -Name 'When service is disabled, but should be enabled' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $false + DropFolder = $null + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $null + ServerAddress = $null + UseDirectoryManagementService = $false + RemoteDirectoryManagementService = $false + DirectoryManagementServiceURL = $null + DistributionGroupsEnabled = $false + DLsRequireAuthenticatedSenders = $false + } + + It "Should return null values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be 'Absent' + $result.UseAutomaticSettings | Should BeNullorEmpty + $result.UseDirectoryManagementService | Should BeNullorEmpty + $result.RemoteDirectoryManagementURL | Should BeNullorEmpty + $result.DLsRequireAuthenticatedSenders | Should BeNullorEmpty + $result.DistributionGroupsEnabled | Should BeNullorEmpty + $result.ServerDisplayAddress | Should BeNullorEmpty + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should update settings for the Set method" { + Set-TargetResource @testParams + $Global:SPDscUpdateCalled | Should Be $true + } + } + + Context -Name 'When service is enabled, but should be disabled' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Absent' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $true + ServerDisplayAddress = 'contoso.com' + ServerAddress = $null + UseDirectoryManagementService = $false + RemoteDirectoryManagementService = $false + DirectoryManagementServiceURL = $null + DistributionGroupsEnabled = $false + DLsRequireAuthenticatedSenders = $false + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be 'Present' + $result.UseAutomaticSettings | Should Be $mock.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be 'No' + $result.RemoteDirectoryManagementURL | Should BeNullorEmpty + $result.DLsRequireAuthenticatedSenders | Should Be $mock.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $mock.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $mock.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should update settings for the Set method" { + Set-TargetResource @testParams + $Global:SPDscUpdateCalled | Should Be $true + } + } + + Context -Name 'When switching from manual to automatic settings' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $true + UseDirectoryManagementService = 'No' + ServerDisplayAddress = "contoso.com" + } + + $mock = @{ + Enabled = $true + DropFolder = '\\MailServer\SharedFolder' + UseAutomaticSettings = (-not $testParams.UseAutomaticSettings) + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $null + UseDirectoryManagementService = $false + RemoteDirectoryManagementService = $false + DirectoryManagementServiceURL = $null + DistributionGroupsEnabled = $false + DLsRequireAuthenticatedSenders = $false + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be (-not $testParams.UseAutomaticSettings) + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should BeNullorEmpty + $result.DLsRequireAuthenticatedSenders | Should Be $mock.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $mock.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should Be $mock.DropFolder + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should update settings for the Set method" { + Set-TargetResource @testParams + $Global:SPDscUpdateCalled | Should Be $true + } + } + + Context -Name 'When updating ServerAddress and Directory Managment Service' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Yes' + ServerDisplayAddress = "contoso.com" + ServerAddress = "mail.contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $testParams.DropFolder + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = "oldserver.contoso.com" + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DistributionGroupsEnabled = $false + DLsRequireAuthenticatedSenders = $false + } + + It "Should return null values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be 'Present' + $result.UseAutomaticSettings | Should Be $mock.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be 'Remote' + $result.RemoteDirectoryManagementURL | Should Be $mock.DirectoryManagementServiceURL + $result.DLsRequireAuthenticatedSenders | Should Be $mock.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $mock.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $mock.ServerDisplayAddress + $result.ServerAddress | Should Be $mock.ServerAddress + $result.DropFolder | Should Be $mock.DropFolder + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should update settings for the Set method" { + Set-TargetResource @testParams + $Global:SPDscUpdateCalled | Should Be $true + } + } + + Context -Name 'When enabling Incoming Email, but not specifying required ServerDisplayAddress parameter' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + #ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $testParams.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should throw an exception for the Set method" { + { Set-TargetResource @testParams } | Should throw "ServerDisplayAddress parameter must be specified when enabling incoming email" + } + } + + Context -Name 'When enabling Incoming Email, but not specifying required UseAutomaticSettings parameter' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + #UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $true + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $mock.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should throw an exception for the Set method" { + { Set-TargetResource @testParams } | Should throw "UseAutomaticSettings parameter must be specified when enabling incoming email." + } + } + + Context -Name 'When no RemoteDirectoryManagementURL specified for UseDirectoryManagementService = Remote' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + #RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $testParams.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should throw an exception for the Set method" { + { Set-TargetResource @testParams } | Should throw "RemoteDirectoryManagementURL must be specified only when UseDirectoryManagementService is set to 'Remote'" + } + } + + Context -Name 'When AutomaticMode is false, but no DropFolder specified' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $false + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + #DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $true + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $true + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should throw an exception for the Set method" { + { Set-TargetResource @testParams } | Should throw "DropFolder parameter must be specified when not using Automatic Mode" + } + } + + Context -Name 'When AutomaticMode is true, but a DropFolder was specified' -Fixture { + $testParams = @{ + IsSingleInstance = 'Yes' + Ensure = 'Present' + UseAutomaticSettings = $true + UseDirectoryManagementService = 'Remote' + RemoteDirectoryManagementURL = 'http://server:adminport/_vti_bin/SharepointEmailWS.asmx' + DLsRequireAuthenticatedSenders = $false + DistributionGroupsEnabled = $true + ServerDisplayAddress = "contoso.com" + DropFolder = '\\MailServer\SharedFolder' + } + + $mock = @{ + Enabled = $true + DropFolder = $null + UseAutomaticSettings = $testParams.UseAutomaticSettings + ServerDisplayAddress = $testParams.ServerDisplayAddress + ServerAddress = $testParams.ServerAddress + UseDirectoryManagementService = $true + RemoteDirectoryManagementService = $true + DirectoryManagementServiceURL = $testParams.RemoteDirectoryManagementURL + DistributionGroupsEnabled = $testParams.DistributionGroupsEnabled + DLsRequireAuthenticatedSenders = $testParams.DLsRequireAuthenticatedSenders + } + + It "Should return current values for the Get method" { + $result = Get-TargetResource @testParams + $result.Ensure | Should Be $testParams.Ensure + $result.UseAutomaticSettings | Should Be $testParams.UseAutomaticSettings + $result.UseDirectoryManagementService | Should Be $testParams.UseDirectoryManagementService + $result.RemoteDirectoryManagementURL | Should Be $testParams.RemoteDirectoryManagementURL + $result.DLsRequireAuthenticatedSenders | Should Be $testParams.DLsRequireAuthenticatedSenders + $result.DistributionGroupsEnabled | Should Be $testParams.DistributionGroupsEnabled + $result.ServerDisplayAddress | Should Be $testParams.ServerDisplayAddress + $result.DropFolder | Should BeNullorEmpty + } + + It "Should return False for the Test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should throw an exception for the Set method" { + { Set-TargetResource @testParams } | Should throw "DropFolder parameter is not valid when using Automatic Mode" + } + } + + } +} + +Invoke-Command -ScriptBlock $Global:SPDscHelper.CleanupScript -NoNewScope diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1 index 17634da34..53bbe5e2e 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPInstallPrereqs.Tests.ps1 @@ -292,6 +292,14 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { if ($Global:SPDscHelper.CurrentStubBuildNumber.Build -lt 10000) { # SharePoint 2016 + Mock -CommandName Get-SPDscOSVersion -MockWith { + # SharePoint 2016 + return @{ + Major = 10 + Build = 16000 + } + } + Mock -CommandName Get-ItemProperty -ParameterFilter { $Path -eq "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" } -MockWith { @@ -313,6 +321,14 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { else { # SharePoint 2019 + Mock -CommandName Get-SPDscOSVersion -MockWith { + # SharePoint 2016 + return @{ + Major = 10 + Build = 17763 + } + } + Mock -CommandName Get-ItemProperty -ParameterFilter { $Path -eq "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" } -MockWith { @@ -514,7 +530,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } } - if ($majorBuildNumber -eq 15) + if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq 15) { Context -Name "SharePoint 2013 is installing on a server with .NET 4.6" -Fixture { $testParams = @{ diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchContentSource.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchContentSource.Tests.ps1 index 022ef3d86..5c25339fa 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchContentSource.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchContentSource.Tests.ps1 @@ -831,6 +831,8 @@ namespace Microsoft.Office.Server.Search.Administration { } -ClientOnly) } + $Global:SPDscContentSourceLoopCount = 0 + Mock -CommandName Get-SPEnterpriseSearchCrawlContentSource -MockWith { $schedule = New-Object -TypeName Microsoft.Office.Server.Search.Administration.DailySchedule $schedule.RepeatDuration = 1439 diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchResultSource.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchResultSource.Tests.ps1 index 6d0d3c727..8b54bad38 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchResultSource.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPSearchResultSource.Tests.ps1 @@ -46,30 +46,42 @@ catch { return @{} } - $Global:SPDscResultSourceProvicers = @( + $Global:SPDscResultSourceProviders = @( @{ - Id = "c1e2843d-1825-4a37-ad15-dce5d50f46d2" - Name = "Exchange Search Provider" + "Exchange Search Provider" = @{ + Id = "c1e2843d-1825-4a37-ad15-dce5d50f46d2" + Name = "Exchange Search Provider" + } }, @{ - Id = "5acc53f4-64b1-4f5d-ad16-7e9ab7372f93" - Name = "Local People Provider" + "Local People Provider" = @{ + Id = "5acc53f4-64b1-4f5d-ad16-7e9ab7372f93" + Name = "Local People Provider" + } }, @{ - Id = "2d443d0a-61ba-472d-9964-ef27b14c8a07" - Name = "Local SharePoint Provider" + "Local SharePoint Provider" = @{ + Id = "2d443d0a-61ba-472d-9964-ef27b14c8a07" + Name = "Local SharePoint Provider" + } }, @{ - Id = "eec636ac-013c-4dea-b794-dadcb4136dfe" - Name = "OpenSearch Provider" + "OpenSearch Provider" = @{ + Id = "eec636ac-013c-4dea-b794-dadcb4136dfe" + Name = "OpenSearch Provider" + } }, @{ - Id = "bb76bb0b-035d-4981-86ae-bd9587f3b0e4" - Name = "Remote People Provider" + "Remote People Provider" = @{ + Id = "bb76bb0b-035d-4981-86ae-bd9587f3b0e4" + Name = "Remote People Provider" + } }, @{ - Id = "f7a3db86-fb85-40e4-a178-7ad85c732ba6" - Name = "Remote SharePoint Provider" + "Remote SharePoint Provider" = @{ + Id = "f7a3db86-fb85-40e4-a178-7ad85c732ba6" + Name = "Remote SharePoint Provider" + } } ) @@ -303,6 +315,34 @@ catch { Set-TargetResource @testParams } } + + Context -Name "The specified ProviderType doesn't exist" -Fixture { + $testParams = @{ + Name = "New source" + ScopeName = "SSA" + ScopeUrl = "Global" + SearchServiceAppName = "Search Service Application" + ProviderType = "DoesNotExist" + Query = "{searchTerms}" + ConnectionUrl = "https://sharepoint.contoso.com" + Ensure = "Present" + } + + $Global:SPDscCurrentResultSourceMocks = $null + $Global:SPDscResultSourceProviders = @() + + It "Should return absent from the get method" { + (Get-TargetResource @testParams).Ensure | Should Be "Absent" + } + + It "Should return false from the test method" { + Test-TargetResource @testParams | Should Be $false + } + + It "Should create the result source in the set method" { + { Set-TargetResource @testParams } | Should Throw "Unknown ProviderType" + } + } } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 index 09e076fda..0e5dfcb10 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 @@ -135,7 +135,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } } - Context -Name "The service app exists and a fixed members list is provided that does not match the current settings" -Fixture { + Context -Name "A specified access level does not match the allowed list of (localized) access levels (Members)" -Fixture { $testParams = @{ ServiceAppName = "Example Service App" SecurityType = "SharingPermissions" @@ -144,7 +144,56 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { -ClientOnly ` -Property @{ Username = "CONTOSO\user1" + AccessLevels = "Read" + }), + (New-CimInstance -ClassName "MSFT_SPSearchServiceAppSecurityEntry" ` + -ClientOnly ` + -Property @{ + Username = "CONTOSO\user2" AccessLevels = "Full Control" + }) + ) + } + + Mock -CommandName Get-SPServiceApplication -MockWith { + return @{ + Name = $testParams.ServiceAppName + } + } + + Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + } + ) + } + } + + It "Should return en empty ServiceAppName from the get method" { + (Get-TargetResource @testParams).ServiceAppName | Should Be "" + } + + 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 "Unknown AccessLevel is used" + } + } + + Context -Name "A specified access level does not match the allowed list of (localized) access levels (MembersToInclude)" -Fixture { + $testParams = @{ + ServiceAppName = "Example Service App" + SecurityType = "SharingPermissions" + MembersToInclude = @( + (New-CimInstance -ClassName "MSFT_SPSearchServiceAppSecurityEntry" ` + -ClientOnly ` + -Property @{ + Username = "CONTOSO\user1" + AccessLevels = "Read" }), (New-CimInstance -ClassName "MSFT_SPSearchServiceAppSecurityEntry" ` -ClientOnly ` @@ -156,28 +205,95 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{} + return @{ + Name = $testParams.ServiceAppName + } } - Mock -CommandName Get-SPServiceApplicationSecurity { + Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { return @{ - AccessRules = @( + NamedAccessRights = @( @{ - Name = "CONTOSO\user1" - AllowedRights = "Read" + Name = "Full Control" } ) } } + It "Should return en empty ServiceAppName from the get method" { + (Get-TargetResource @testParams).ServiceAppName | Should Be "" + } + + 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 "Unknown AccessLevel is used" + } + } + + Context -Name "The service app exists and a fixed members list is provided that does not match the current settings" -Fixture { + $testParams = @{ + ServiceAppName = "Example Service App" + SecurityType = "SharingPermissions" + Members = @( + (New-CimInstance -ClassName "MSFT_SPSearchServiceAppSecurityEntry" ` + -ClientOnly ` + -Property @{ + Username = "CONTOSO\user1" + AccessLevels = "Full Control" + }), + (New-CimInstance -ClassName "MSFT_SPSearchServiceAppSecurityEntry" ` + -ClientOnly ` + -Property @{ + Username = "CONTOSO\user2" + AccessLevels = "Full Control" + }) + ) + } + + Mock -CommandName Get-SPServiceApplication -MockWith { + return @{} + } + + Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user1" + AllowedRights = "Read" + } + ) + } + } + } + + $Global:SPDscRunCount = 0 It "Should return a list of current members from the get method" { (Get-TargetResource @testParams).Members | Should Not BeNullOrEmpty } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity -ParameterFilter {$Replace -eq $true} @@ -209,7 +325,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { return @{} } - Mock -CommandName Get-SPServiceApplicationSecurity { + Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { $security = @{ NamedAccessRights = @( @{ @@ -276,24 +392,42 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - @{ - Name = "CONTOSO\user2" - AllowedRights = "FullControl" - } - ) + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user2" + AllowedRights = "FullControl" + } + ) + } } } + $Global:SPDscRunCount = 0 It "Should return a list of current members from the get method" { (Get-TargetResource @testParams).Members | Should Not BeNullOrEmpty } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity @@ -417,16 +551,35 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - @{ - Name = "CONTOSO\user1" - AllowedRights = "FullControl" - } - ) + if ($Global:SPDscRunCount -in 0,1) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + }, + @{ + Name = "Read" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user1" + AllowedRights = "FullControl" + } + ) + } } } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } @@ -451,20 +604,37 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - @{ - Name = "CONTOSO\user1" - AllowedRights = "FullControl" - } - ) + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Read" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user1" + AllowedRights = "FullControl" + } + ) + } } } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity -Times 1 -ParameterFilter {$Replace -eq $true} @@ -491,20 +661,37 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - @{ - Name = "CONTOSO\user1" - AllowedRights = "FullControl" - } - ) + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Read" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user1" + AllowedRights = "FullControl" + } + ) + } } } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity -Times 1 -ParameterFilter {$Replace -eq $true} @@ -714,16 +901,33 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - ) + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + ) + } } } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity @@ -751,20 +955,37 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { - return @{ - AccessRules = @( - @{ - Name = "CONTOSO\user2" - AllowedRights = "FullControl" - } - ) + if ($Global:SPDscRunCount -in 0,1,3,4) + { + $Global:SPDscRunCount++ + return @{ + NamedAccessRights = @( + @{ + Name = "Full Control" + } + ) + } + } + else + { + $Global:SPDscRunCount++ + return @{ + AccessRules = @( + @{ + Name = "CONTOSO\user2" + AllowedRights = "FullControl" + } + ) + } } } + $Global:SPDscRunCount = 0 It "Should return false from the test method" { Test-TargetResource @testParams | Should Be $false } + $Global:SPDscRunCount = 0 It "Should call the update cmdlet from the set method" { Set-TargetResource @testParams Assert-MockCalled Grant-SPObjectSecurity diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 index 05bfc9404..af1cdc84a 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 @@ -17,17 +17,13 @@ $Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointC Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { - # Pester seems to have an issue with the mocks of New-Object when this sits inside the ModuleName - # scope. I have no idea why and it drives me nuts that this is here because it breaks the simple - # test template I had, but I didnt wanna hold things up on the rest of the test refactoring, so - # here it is. Will resolve later when I can understand what is going on here. - Brian - $mockPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force - $farmAccount = New-Object -TypeName "System.Management.Automation.PSCredential" ` - -ArgumentList @("username", $mockPassword) - InModuleScope -ModuleName $Global:SPDscHelper.ModuleName -ScriptBlock { Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + $mockPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force + $farmAccount = New-Object -TypeName "System.Management.Automation.PSCredential" ` + -ArgumentList @("username", $mockPassword) + $testParamsNewProperty = @{ Name = "WorkEmailNew" UserProfileService = "User Profile Service Application" @@ -211,7 +207,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { DisplayName = $testParamsNewProperty.DisplayName Description = $testParamsNewProperty.Description PrivacyPolicy = $testParamsNewProperty.PolicySetting - DefaultPrivacy = $testParamsNewProperty.PrivateSetting + DefaultPrivacy = $testParamsNewProperty.PrivacySetting DisplayOrder = $testParamsNewProperty.DisplayOrder IsUserEditable = $testParamsNewProperty.IsUserEditable IsAlias = $testParamsNewProperty.IsAlias diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 index 362b5e65b..a57e6cdaa 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 @@ -97,10 +97,10 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } Mock -CommandName New-Object -MockWith { - $ProfilePropertyManager = @{"Contoso" = $connection} + $ProfilePropertyManager = @{"Contoso" = $null} # $connection is never set, so it will always be $null return (@{ ProfilePropertyManager = $ProfilePropertyManager - ConnectionManager = $ConnnectionManager + ConnectionManager = $null # $ConnnectionManager is never set, so it will always be $null } | Add-Member -MemberType ScriptMethod GetPropertiesWithSection { $Global:UpsConfigManagerGetPropertiesWithSectionCalled=$true; @@ -121,13 +121,13 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } $Global:UpsConfigManagerGetSectionByNameCalled=$true return $result - return $userProfileSubTypePropertiesUpdateProperty; + return $null # $userProfileSubTypePropertiesUpdateProperty is never set, so it will always be $null; } -PassThru | Add-Member -MemberType ScriptMethod SetDisplayOrderBySectionName { $Global:UpsConfigManagerSetDisplayOrderBySectionNameCalled=$true; - return $userProfileSubTypePropertiesUpdateProperty; + return $null # $userProfileSubTypePropertiesUpdateProperty is never set, so it will always be $null; } -PassThru | Add-Member -MemberType ScriptMethod CommitDisplayOrder { $Global:UpsConfigManagerCommitDisplayOrderCalled=$true; - return $userProfileSubTypePropertiesUpdateProperty; + return $null # $userProfileSubTypePropertiesUpdateProperty is never set, so it will always be $null; } -PassThru| Add-Member -MemberType ScriptMethod RemoveSectionByName { $Global:UpsConfigManagerRemoveSectionByNameCalled=$true; return ($coreProperties); diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 index 8c12ddfdc..7cd72d556 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 @@ -27,10 +27,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { if ($Global:SPDscHelper.CurrentStubBuildNumber.Major -eq 16) { $name = "contoso-com" + $defaultDistinguishedName = "DC=litware,DC=net" } else { $name = "contoso" + $defaultDistinguishedName = "litware.net" } try { [Microsoft.Office.Server.UserProfiles] } @@ -422,10 +424,15 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should Be $false } - It "Should throw exception as force isn't specified" { - $Global:SPDscUPSSyncConnectionDeleteCalled=$false - {Set-TargetResource @testParams} | should throw - $Global:SPDscUPSSyncConnectionDeleteCalled | Should be $false + switch ($Global:SPDscHelper.CurrentStubBuildNumber.Major) + { + 15 { + It "Should throw exception as force isn't specified" { + $Global:SPDscUPSSyncConnectionDeleteCalled=$false + {Set-TargetResource @testParams} | should throw + $Global:SPDscUPSSyncConnectionDeleteCalled | Should be $false + } + } } $forceTestParams = @{ @@ -440,12 +447,17 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { ConnectionType = "ActiveDirectory" } - It "delete and create as force is specified" { - $Global:SPDscUPSSyncConnectionDeleteCalled=$false - $Global:SPDscUPSAddActiveDirectoryConnectionCalled =$false - Set-TargetResource @forceTestParams - $Global:SPDscUPSSyncConnectionDeleteCalled | Should be $true - $Global:SPDscUPSAddActiveDirectoryConnectionCalled | Should be $true + switch ($Global:SPDscHelper.CurrentStubBuildNumber.Major) + { + 15 { + It "delete and create as force is specified" { + $Global:SPDscUPSSyncConnectionDeleteCalled=$false + $Global:SPDscUPSAddActiveDirectoryConnectionCalled =$false + Set-TargetResource @forceTestParams + $Global:SPDscUPSSyncConnectionDeleteCalled | Should be $true + $Global:SPDscUPSAddActiveDirectoryConnectionCalled | Should be $true + } + } } It "returns false in Test method as force is specified" { @@ -589,6 +601,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Type= "ActiveDirectory" } + $namingContext =@{ + DistinguishedName = $defaultDistinguishedName + } + + $litWareconnection.NamingContexts.Add($namingContext); + $userProfileServiceValidConnection = @{ Name = "User Profile Service Application" TypeName = "User Profile Service Application" @@ -687,6 +705,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } } + $namingContext =@{ + DistinguishedName = $defaultDistinguishedName + } + + $litWareconnection.NamingContexts.Add($namingContext); + $litWareconnection = $litWareconnection | Add-Member -MemberType ScriptMethod ` -Name Delete ` -Value { @@ -779,6 +803,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Type= "ActiveDirectory" } + $namingContext =@{ + DistinguishedName = "DC=LITWARE,DC=NET" + } + + $litWareconnection.NamingContexts.Add($namingContext); + $userProfileServiceValidConnection = @{ Name = "User Profile Service Application" TypeName = "User Profile Service Application" @@ -853,6 +883,12 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Type= "ActiveDirectory" } + $namingContext =@{ + DistinguishedName = "DC=LITWARE,DC=NET" + } + + $litWareconnection.NamingContexts.Add($namingContext); + $userProfileServiceValidConnection = @{ Name = "User Profile Service Application" TypeName = "User Profile Service Application" diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 index fd49d4f56..4f7376f77 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 @@ -33,7 +33,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { return $mockFarmCredential } Mock -CommandName Start-SPServiceInstance -MockWith { } - Mock -CommandName Stop-SPServiceInstance -MockWith { } + Mock -CommandName Stop-SPServiceInstance -MockWith { $Global:ServiceStatus = "Disabled" } Mock -CommandName Restart-Service -MockWith { } Mock -CommandName Add-SPDSCUserToLocalAdmin -MockWith { } Mock -CommandName Test-SPDSCUserIsLocalAdmin -MockWith { @@ -436,6 +436,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Ensure = "Present" RunOnlyWhenWriteable = $true } + $Global:ServiceStatus = "Online" Mock -CommandName Get-SPServiceInstance -MockWith { $spSvcInstance = [pscustomobject]@{ @@ -445,7 +446,9 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { $spSvcInstance = $spSvcInstance | Add-Member ScriptMethod GetType { return @{ Name = "ProfileSynchronizationServiceInstance" } } -PassThru -Force - $spSvcInstance = $spSvcInstance | Add-Member NoteProperty Status "Online" -PassThru + $spSvcInstance | Add-Member ScriptProperty Status { + return $Global:ServiceStatus + } $spSvcInstance = $spSvcInstance | Add-Member NoteProperty UserProfileApplicationGuid ([Guid]::NewGuid()) -PassThru return $spSvcInstance } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 index d32244a3f..40d3d205e 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppAuthentication.Tests.ps1 @@ -1,7 +1,7 @@ [CmdletBinding()] param( [Parameter()] - [string] + [string] $SharePointCmdletModule = (Join-Path -Path $PSScriptRoot ` -ChildPath "..\Stubs\SharePoint\15.0.4805.1000\Microsoft.SharePoint.PowerShell.psm1" ` -Resolve) @@ -20,7 +20,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { # Initialize tests - # Mocks for all contexts + # Mocks for all contexts Mock -CommandName Set-SPWebApplication {} # Test contexts @@ -52,6 +52,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { $result.Extranet | Should BeNullOrEmpty $result.Internet | Should BeNullOrEmpty $result.Custom | Should BeNullOrEmpty + $result.WebAppUrl | Should Not BeNullOrEmpty } It "Should return false from the test method" { @@ -93,7 +94,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { { Set-TargetResource @testParams } | Should throw "You cannot use AuthenticationProvider, MembershipProvider or RoleProvider when using NTLM" } } - + Context -Name "AuthenticationMethod=Kerberos used with MembershipProvider parameter" -Fixture { $testParams = @{ WebAppUrl = "http://sharepoint.contoso.com" @@ -282,7 +283,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should throw exception in the set method" { { Set-TargetResource @testParams } | Should throw "You cannot use both NTLM and Kerberos in the same zone" } - } + } Context -Name "No zones are specified" -Fixture { $testParams = @{ @@ -308,7 +309,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { { Set-TargetResource @testParams } | Should throw "You have to specify at least one zone." } } - + Context -Name "WebApplication is Classic, but Default Zone config is Claims" -Fixture { $testParams = @{ WebAppUrl = "http://sharepoint.contoso.com" @@ -330,7 +331,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Default[0].AuthenticationMethod | Should Be "Classic" @@ -387,7 +388,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } ) } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Default[0].AuthenticationMethod | Should Be "NTLM" @@ -437,7 +438,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { { Set-TargetResource @testParams } | Should Throw "Specified AuthenticationProvider ADFS does not exist" } } - + Context -Name "Default Zone of Web application is not configured as specified" -Fixture { $testParams = @{ WebAppUrl = "http://sharepoint.contoso.com" @@ -480,7 +481,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Default[0].AuthenticationMethod | Should Be "NTLM" @@ -494,7 +495,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should run the Set-SPWebApplication cmdlet in the set method" { Set-TargetResource @testParams - Assert-MockCalled Set-SPWebApplication + Assert-MockCalled Set-SPWebApplication } } @@ -540,7 +541,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } ) } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Intranet[0].AuthenticationMethod | Should Be "NTLM" @@ -595,7 +596,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Intranet[0].AuthenticationMethod | Should Be "NTLM" @@ -609,7 +610,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should run the Set-SPWebApplication cmdlet in the set method" { Set-TargetResource @testParams - Assert-MockCalled Set-SPWebApplication + Assert-MockCalled Set-SPWebApplication } } @@ -655,7 +656,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } ) } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Internet[0].AuthenticationMethod | Should Be "NTLM" @@ -710,7 +711,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Internet[0].AuthenticationMethod | Should Be "NTLM" @@ -724,7 +725,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should run the Set-SPWebApplication cmdlet in the set method" { Set-TargetResource @testParams - Assert-MockCalled Set-SPWebApplication + Assert-MockCalled Set-SPWebApplication } } @@ -770,7 +771,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } ) } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Extranet[0].AuthenticationMethod | Should Be "NTLM" @@ -823,7 +824,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Extranet[0].AuthenticationMethod | Should Be "NTLM" @@ -837,7 +838,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should run the Set-SPWebApplication cmdlet in the set method" { Set-TargetResource @testParams - Assert-MockCalled Set-SPWebApplication + Assert-MockCalled Set-SPWebApplication } } @@ -883,7 +884,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } ) } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Custom[0].AuthenticationMethod | Should Be "NTLM" @@ -938,7 +939,7 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Mock -CommandName New-SPAuthenticationProvider -MockWith { return @{} } Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith { return @{} } - + It "Should return null from the get method" { $result = Get-TargetResource @testParams $result.Custom[0].AuthenticationMethod | Should Be "Kerberos" @@ -952,10 +953,10 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { It "Should run the Set-SPWebApplication cmdlet in the set method" { Set-TargetResource @testParams - Assert-MockCalled Set-SPWebApplication + Assert-MockCalled Set-SPWebApplication } } - + } } diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPeoplePickerSettings.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPeoplePickerSettings.Tests.ps1 index f60bf7ba2..d69f0d58f 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPeoplePickerSettings.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPeoplePickerSettings.Tests.ps1 @@ -78,7 +78,7 @@ namespace Microsoft.SharePoint.Administration { AccessAccount = (New-CimInstance -ClassName MSFT_Credential ` -Property @{ Username=[string]$mockAccount.UserName; - Password=[string]$null + Password=[string]$mockAccount.Password; } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly) @@ -199,7 +199,7 @@ namespace Microsoft.SharePoint.Administration { AccessAccount = (New-CimInstance -ClassName MSFT_Credential ` -Property @{ Username=[string]$mockAccount.UserName; - Password=[string]$null + Password=[string]$mockAccount.Password; } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly) diff --git a/Tests/Unit/SharePointDsc/SharePointDsc.SPWorkflowService.Tests.ps1 b/Tests/Unit/SharePointDsc/SharePointDsc.SPWorkflowService.Tests.ps1 index c5273491a..a853d01bc 100644 --- a/Tests/Unit/SharePointDsc/SharePointDsc.SPWorkflowService.Tests.ps1 +++ b/Tests/Unit/SharePointDsc/SharePointDsc.SPWorkflowService.Tests.ps1 @@ -21,6 +21,30 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { # Initialize tests # Mocks for all contexts + Mock -CommandName Get-SPWorkflowServiceApplicationProxy -MockWith{ + return @(@{ + Value = $true + } | Add-Member -MemberType ScriptMethod ` + -Name GetHostname ` + -Value { + return "http://workflow.sharepoint.com" + } -PassThru ` + | Add-Member -MemberType ScriptMethod ` + -Name GetWorkflowScopeName ` + -Value { + return "SharePoint" + } -PassThru) + } + + Mock -CommandName Get-SPSite -MockWith { + return @( + @{ + Url = "http://sites.sharepoint.com" + } + ) + } + + Mock -CommandName Register-SPWorkflowService -MockWith{ } # Test contexts Context -Name "Specified Site Collection does not exist" -Fixture { @@ -41,7 +65,10 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { } It "return empty workflow service instance"{ - (Get-TargetResource @testParams).WorkflowHostUri | Should Be $null + $result = Get-TargetResource @testParams + $result.WorkflowHostUri | Should Be $null + $result.SPSiteUrl | Should Be "http://sites.sharepoint.com" + $result.ScopeName | Should Be $null } It "return false from the test method"{ @@ -56,34 +83,22 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { AllowOAuthHttp = $true } - Mock -CommandName Get-SPSite -MockWith {return @(@{ - Url = "http://sites.sharepoint.com" - } - )} - Mock -CommandName Register-SPWorkflowService -MockWith{ return @(@{ Value = $true }) } - Mock -CommandName Get-SPWorkflowServiceApplicationProxy -MockWith{ - return @(@{ - Value = $true - } | Add-Member -MemberType ScriptMethod ` - -Name GetHostname ` - -Value { - return "http://workflow.sharepoint.com" - } -PassThru) - } - It "properly creates the workflow service proxy" { Set-TargetResource @testParams - Assert-MockCalled Register-SPWorkflowService + Assert-MockCalled Register-SPWorkflowService -ParameterFilter {$ScopeName -eq $null -and $WorkflowHostUri -eq "http://workflow.sharepoint.com"} } It "returns the workflow service instance" { - (Get-TargetResource @testParams).WorkflowHostUri | Should Be "http://workflow.sharepoint.com" + $result = Get-TargetResource @testParams + $result.WorkflowHostUri | Should Be "http://workflow.sharepoint.com" + $result.SPSiteUrl = "http://sites.sharepoint.com" + $result.ScopeName | Should Be "SharePoint" Assert-MockCalled Get-SPWorkflowServiceApplicationProxy } @@ -91,6 +106,49 @@ Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { Test-TargetResource @testParams | Should Be $true } } + + Context -Name "workflow host URL is incorrect" -Fixture { + $testParams = @{ + WorkflowHostUri = "http://new-workflow.sharepoint.com" + ScopeName = "SharePoint" + SPSiteUrl = "http://sites.sharepoint.com" + AllowOAuthHttp = $true + } + + It "properly creates the workflow service proxy" { + Set-TargetResource @testParams + Assert-MockCalled Register-SPWorkflowService -ParameterFilter {$ScopeName -eq "SharePoint" -and $WorkflowHostUri -eq "http://new-workflow.sharepoint.com"} + } + + It "return false from the test method"{ + Test-TargetResource @testParams | Should Be $false + } + } + + Context -Name "workflow scope name is incorrect" -Fixture { + $testParams = @{ + WorkflowHostUri = "http://workflow.sharepoint.com" + ScopeName = "AnotherScope" + SPSiteUrl = "http://sites.sharepoint.com" + AllowOAuthHttp = $true + } + + It "return false from the test method"{ + Test-TargetResource @testParams | Should Be $false + } + } + + Context -Name "workflow host URL contains a trailing forward slash" -Fixture { + $testParams = @{ + WorkflowHostUri = "http://workflow.sharepoint.com/" + SPSiteUrl = "http://sites.sharepoint.com" + AllowOAuthHttp = $true + } + + It "return true from the test method"{ + Test-TargetResource @testParams | Should Be $true + } + } } } diff --git a/Tests/Unit/UnitTestHelper.psm1 b/Tests/Unit/UnitTestHelper.psm1 index 20be24c30..3534765aa 100644 --- a/Tests/Unit/UnitTestHelper.psm1 +++ b/Tests/Unit/UnitTestHelper.psm1 @@ -54,6 +54,7 @@ function New-SPDscUnitTestHelper Import-Module -Name $moduleToLoad -Global $initScript = @" + Set-StrictMode -Version 1 Remove-Module -Name "Microsoft.SharePoint.PowerShell" -Force -ErrorAction SilentlyContinue Import-Module -Name "$SharePointStubModule" -WarningAction SilentlyContinue Import-Module -Name "$moduleToLoad"