diff --git a/CHANGELOG.md b/CHANGELOG.md index dbdd1c435..1290afde3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- SPAccessServiceApp, SPAccessServices2010, SPAppManagementServiceApp, SPBCSServiceApp, + SPExcelServiceApp, SPMachineTranslationServiceApp, SPManagedMetadataServiceApp, + SPPerformancePointServiceApp, SPPowerPointAutomationServiceApp, SPProjectServerServiceApp, + SPPublishServiceApplication, SPSearchCrawlRule, SPSearchFileType, SPSearchServiceApp, + SPSecureStoreServiceApp, SPServiceAppSecurity, SPSubscriptionSettingsServiceApp, + SPUsageApplication, SPUserProfileProperty, SPUserProfileSection, SPUserProfileServiceApp, + SPUserProfileSyncConnection, SPUserProfileSyncService, SPVisioServiceApp, + SPWordAutomationServiceApp, SPWorkManagementServiceApp + - Fixed issue with the Name parameter of Get-SPServiceApplication, which is case + sensitive +- SPExcelServiceApp + - Fixed issue where PSBoundParameters was used multiple times, but manipulated at an early + stage, breaking all subsequent usages - SPInstallLanguagePack - - Fixes issue in the Norwegian Language Pack detection + - Fixed issue in the Norwegian Language Pack detection - SPSearchManagedProperty - Fixed issue where setting Searchable=True resulted in an error - SPSearchResultSource @@ -38,6 +51,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SPUserProfileServiceApp - Fixed issue where MySiteHostLocation was return from Get method including port number, which causes the Test method to fail +- SPWebAppAuthentication + - Fix issue in Get method to return Null when zone does not exist. That way the Test and + Set method can detect a non-existent zone and throw a proper error. - SPWordAutomation - Fixed issue where the resource never went into desired state when using AddToDefault diff --git a/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 index d24dded67..c47a00ba0 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 @@ -36,7 +36,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -128,8 +130,9 @@ function Set-TargetResource $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Access.Services.MossHost.AccessServicesWebServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Access.Services.MossHost.AccessServicesWebServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 b/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 index a8b92a458..1e25a32f1 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 @@ -31,8 +31,10 @@ function Get-TargetResource -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -107,8 +109,10 @@ function Set-TargetResource -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - $apps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $apps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -ne $apps) { $app = $apps | Where-Object -FilterScript { @@ -138,8 +142,10 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $apps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $apps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -eq $apps) { return diff --git a/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 index 2467f76b8..94eb96f4d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 @@ -52,7 +52,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -209,8 +212,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" } if ($null -eq $params.ProxyName) @@ -238,8 +242,9 @@ function Set-TargetResource $params = $args[0] $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" } $app.ApplicationPool = $appPool $app.Update() @@ -256,8 +261,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.AppManagement.AppManagementServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 index 30630c328..7f8ad7efe 100644 --- a/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 @@ -52,7 +52,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -218,9 +221,9 @@ function Set-TargetResource $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplication" + Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplication" } ` | Set-SPBusinessDataCatalogServiceApplication -ApplicationPool $appPool } @@ -236,8 +239,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/readme.md b/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/readme.md index 3bc2cbd30..df461a621 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/readme.md +++ b/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/readme.md @@ -6,3 +6,6 @@ This resource is responsible for configuring the Diagnostics Provider within the local SharePoint farm. Using Ensure equals to Absent is not supported. This resource can only apply configuration, not ensure they don't exist. + +To get an overview of all available Diagnostics Providers, use the cmdlet +Get-SPDiagnosticsProvider. diff --git a/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 index 1ec1d2697..c1a89972e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 @@ -143,8 +143,10 @@ function Get-TargetResource $params = $args[0] $serviceAppObjectType = $args[1] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -354,18 +356,19 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $params.Add("Identity", $params.Name) + $newParams = @{ + Identity = $params.Name + } - # Remove parameters that do not belong on the set method - @("InstallAccount", "Ensure", "TrustedFileLocations", "Name", "ApplicationPool") | - ForEach-Object -Process { - if ($params.ContainsKey($_) -eq $true) - { - $params.Remove($_) | Out-Null - } + foreach ($key in $params.Keys) + { + if ($key -notin @("InstallAccount", "Ensure", "TrustedFileLocations", "Name", "ApplicationPool")) + { + $newParams.Add($key, $params.$key) } + } - Set-SPExcelServiceApplication @params + Set-SPExcelServiceApplication @newParams } @@ -395,8 +398,9 @@ function Set-TargetResource $newArgs.Add($_, $desiredLocation.$_) } } - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq $serviceAppObjectType + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq $serviceAppObjectType } $newArgs.Add("ExcelServiceApplication", $serviceApp) @@ -421,8 +425,9 @@ function Set-TargetResource $updateArgs.Add($_, $desiredLocation.$_) } } - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq $serviceAppObjectType + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq $serviceAppObjectType } $updateArgs.Add("Identity", $desiredLocation.Address) $updateArgs.Add("ExcelServiceApplication", $serviceApp) @@ -463,8 +468,9 @@ function Set-TargetResource $params = $args[0] $serviceAppObjectType = $args[1] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq $serviceAppObjectType + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq $serviceAppObjectType } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 index d43692a70..be8fa9ec5 100644 --- a/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 @@ -51,7 +51,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $nullReturn = @{ Name = $params.Name @@ -169,7 +171,9 @@ function Set-TargetResource $databaseCredentialsParam = "" } - $serviceApps = Get-SPServiceApplication -Identity $params.Name + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $serviceApp = $serviceApps | Where-Object -FilterScript { $_.GetType().FullName -eq "Microsoft.Office.TranslationServices.TranslationServiceApplication" @@ -236,7 +240,10 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Identity $params.Name + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $serviceApp = $serviceApps | Where-Object -FilterScript { $_.GetType().FullName -eq "Microsoft.Office.TranslationServices.TranslationServiceApplication" } diff --git a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 index 31c92b4bd..606b6b672 100644 --- a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 @@ -84,8 +84,9 @@ function Get-TargetResource TermStoreAdministrators = @() } - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } if ($null -eq $serviceApps) { @@ -411,10 +412,11 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" } + $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool Set-SPMetadataServiceApplication -Identity $serviceApp -ApplicationPool $appPool } @@ -429,8 +431,9 @@ function Set-TargetResource $params = $args[0] $pName = $args[1] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $serviceApp = $serviceApps | Where-Object -FilterScript { $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" } @@ -469,9 +472,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" } Set-SPMetadataServiceApplication -Identity $serviceApp -HubUri $params.ContentTypeHubUrl } @@ -758,8 +761,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 index b1a293d49..538db3041 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 @@ -52,7 +52,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -201,9 +204,9 @@ function Set-TargetResource $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.PerformancePoint.Scorecards.BIMonitoringServiceApplication" + Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.PerformancePoint.Scorecards.BIMonitoringServiceApplication" } | Set-SPPerformancePointServiceApplication -ApplicationPool $appPool } } @@ -216,8 +219,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.PerformancePoint.Scorecards.BIMonitoringServiceApplication" + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.PerformancePoint.Scorecards.BIMonitoringServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 index f65af6ccf..da43cae8e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 @@ -82,8 +82,10 @@ function Get-TargetResource -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name Ensure = "Absent" @@ -274,8 +276,10 @@ function Set-TargetResource $eventSource = $args[1] $result = $args[2] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -eq $serviceApps) { $message = "No Service applications are available in the farm." @@ -355,7 +359,10 @@ function Set-TargetResource Invoke-SPDscCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -eq $serviceApps) { return; diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 index 52ae98bf7..9d6e1bc5f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 @@ -47,8 +47,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = "" @@ -171,9 +173,9 @@ function Set-TargetResource $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Project.Server.Administration.PsiServiceApplication" + Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Project.Server.Administration.PsiServiceApplication" } | Set-SPProjectServiceApplication -ApplicationPool $appPool } } @@ -187,8 +189,8 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Project.Server.Administration.PsiServiceApplication" } diff --git a/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 b/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 index fac874d4c..8fe6dde85 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 @@ -28,7 +28,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } if ($null -eq $serviceApp) { @@ -90,7 +92,10 @@ function Set-TargetResource $params = $args[0] $eventSource = $args[1] - $serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -eq $serviceApp) { $message = ("The service application $Name does not exist") diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 index 5b1654e8d..a5dfd2147 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 @@ -145,8 +145,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.ServiceAppName ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } $nullReturn = @{ Path = $params.Path diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 index 9d48d6b8a..b5b353574 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 @@ -57,8 +57,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.ServiceAppName ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } $nullReturn = @{ FileType = $params.FileType @@ -171,8 +172,9 @@ function Set-TargetResource $params = $args[0] $eventSource = $args[1] - $serviceApps = Get-SPServiceApplication -Name $params.ServiceAppName ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } if ($null -eq $serviceApps) { diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 index d82806705..eb0e0e82c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 @@ -88,7 +88,9 @@ function Get-TargetResource "does not exist.") } - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $nullReturn = @{ Name = $params.Name @@ -326,10 +328,10 @@ function Set-TargetResource if ($params.ContainsKey("SearchCenterUrl") -eq $true) { Write-Verbose -Message "Setting SearchCenterUrl to $($params.SearchCenterUrl)" - $serviceApp = Get-SPServiceApplication -Name $params.Name | ` - Where-Object -FilterScript { + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - } + } $serviceApp.SearchCenterUrl = $params.SearchCenterUrl $serviceApp.Update() } @@ -337,10 +339,10 @@ function Set-TargetResource if ($params.ContainsKey("AlertsEnabled") -eq $true) { Write-Verbose -Message "Setting AlertsEnabled to $($params.AlertsEnabled)" - $serviceApp = Get-SPServiceApplication -Name $params.Name | ` - Where-Object -FilterScript { + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - } + } $serviceApp.AlertsEnabled = $params.AlertsEnabled $serviceApp.Update() } @@ -358,10 +360,10 @@ function Set-TargetResource $params = $args[0] $result = $args[1] - $serviceApp = Get-SPServiceApplication -Name $params.Name | ` - Where-Object -FilterScript { + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - } + } if ($null -eq $params.ProxyName) { @@ -422,10 +424,10 @@ function Set-TargetResource $result.SearchCenterUrl -ne $params.SearchCenterUrl) { Write-Verbose -Message "Updating SearchCenterUrl to $($params.SearchCenterUrl)" - $serviceApp = Get-SPServiceApplication -Name $params.Name | ` - Where-Object -FilterScript { + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - } + } $serviceApp.SearchCenterUrl = $params.SearchCenterUrl $serviceApp.Update() } @@ -434,10 +436,10 @@ function Set-TargetResource $result.AlertsEnabled -ne $params.AlertsEnabled) { Write-Verbose -Message "Updating AlertsEnabled to $($params.AlertsEnabled)" - $serviceApp = Get-SPServiceApplication -Name $params.Name | ` - Where-Object -FilterScript { + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - } + } $serviceApp.AlertsEnabled = $params.AlertsEnabled $serviceApp.Update() } @@ -453,9 +455,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" - + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 index 8f3d2596b..175215583 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 @@ -83,7 +83,10 @@ function Get-TargetResource Ensure = "Absent" } - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + if ($null -eq $serviceApps) { return $nullReturn @@ -298,8 +301,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplication" } $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool Set-SPSecureStoreServiceApplication -Identity $serviceApp -ApplicationPool $appPool @@ -316,8 +320,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.SecureStoreService.Server.SecureStoreServiceApplication" } # Remove the connected proxy(ies) diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 index e9e54711a..be759459d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 @@ -63,7 +63,9 @@ function Get-TargetResource $params = $args[0] Write-Verbose -Message "Getting Service Application $($params.ServiceAppName)" - $serviceApp = Get-SPServiceApplication -Name $params.ServiceAppName + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } $nullReturn = @{ ServiceAppName = "" @@ -273,7 +275,10 @@ function Set-TargetResource $eventSource = $args[1] $CurrentValues = $args[2] - $serviceApp = Get-SPServiceApplication -Name $params.ServiceAppName + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } + if ($null -eq $serviceApp) { $message = "Unable to locate service application $($params.ServiceAppName)" @@ -583,7 +588,10 @@ function Test-TargetResource $relPath = "..\..\Modules\SharePointDsc.ServiceAppSecurity\SPServiceAppSecurity.psm1" Import-Module (Join-Path -Path $ScriptRoot -ChildPath $relPath -Resolve) - $serviceApp = Get-SPServiceApplication -Name $params.ServiceAppName + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.ServiceAppName + } + switch ($params.SecurityType) { "Administrators" diff --git a/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 index 63bb60f3d..9b7301b5d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 @@ -48,8 +48,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -177,8 +179,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $serviceAppProxies = Get-SPServiceApplicationProxy -ErrorAction SilentlyContinue @@ -210,9 +213,9 @@ function Set-TargetResource $params = $args[0] $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - $service = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.SPSubscriptionSettingsServiceApplication" + $service = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.SPSubscriptionSettingsServiceApplication" } $service.ApplicationPool = $appPool $service.Update() @@ -227,9 +230,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $service = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.SharePoint.SPSubscriptionSettingsServiceApplication" + $service = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.SharePoint.SPSubscriptionSettingsServiceApplication" } Remove-SPServiceApplication $service -Confirm:$false } @@ -294,8 +297,9 @@ function Test-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $serviceAppProxies = Get-SPServiceApplicationProxy -ErrorAction SilentlyContinue diff --git a/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 b/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 index 21ea41ab6..9a625574d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 @@ -60,8 +60,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name Ensure = "Absent" @@ -247,8 +249,8 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $service = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { + $service = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.SharePoint.Administration.SPUsageApplication" } Remove-SPServiceApplication $service -Confirm:$false diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 index 21013cfca..d4dd3f4a8 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 @@ -126,8 +126,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $upsa = Get-SPServiceApplication -Name $params.UserProfileService ` - -ErrorAction SilentlyContinue + $upsa = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } + $nullReturn = @{ Name = $params.Name UserProfileService = $params.UserProfileService @@ -455,8 +457,9 @@ function Set-TargetResource throw $message } - $ups = Get-SPServiceApplication -Name $params.UserProfileService ` - -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } if ($null -eq $ups) { diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 index 6de611393..12af205ad 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 @@ -40,8 +40,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $upsa = Get-SPServiceApplication -Name $params.UserProfileService ` - -ErrorAction SilentlyContinue + $upsa = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } + $nullReturn = @{ Name = $params.Name Ensure = "Absent" @@ -122,8 +124,9 @@ function Set-TargetResource $params = $args[0] $eventSource = $args[1] - $ups = Get-SPServiceApplication -Name $params.UserProfileService ` - -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } if ($null -eq $ups) { diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 index c37ba0662..a3ab4cb5e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 @@ -151,7 +151,10 @@ function Get-TargetResource $params = $args[0] $eventSource = $args[1] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name Ensure = "Absent" @@ -516,8 +519,10 @@ function Set-TargetResource $params.Remove("UseSQLAuthentication") | Out-Null $params.Remove("DatabaseCredentials") | Out-Null - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $app = $serviceApps | Select-Object -First 1 if ($null -eq $serviceApps) { @@ -547,8 +552,9 @@ function Set-TargetResource Set-SPServiceApplicationSecurity -Identity $app ` -ObjectSecurity $serviceAppSecurity - $app = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } } $updateServiceApp = $false @@ -640,8 +646,8 @@ function Set-TargetResource $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Server.Administration.UserProfileApplication" } diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 index dcd2e17a5..58ae4a547 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 @@ -73,8 +73,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $ups = Get-SPServiceApplication -Name $params.UserProfileService ` - -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } $nullReturn = @{ Name = $params.Name @@ -344,7 +345,9 @@ function Set-TargetResource { $params.Remove("InstallAccount") | Out-Null } - $ups = Get-SPServiceApplication -Name $params.UserProfileService -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileService + } if ($null -eq $ups) { diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 index 4d49cf820..e29b495ba 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 @@ -318,8 +318,10 @@ function Set-TargetResource # Start the Sync service if it should be running on this server if (($params.Ensure -eq "Present") -and ($syncService.Status -ne "Online")) { - $ups = Get-SPServiceApplication -Name $params.UserProfileServiceAppName ` - -ErrorAction SilentlyContinue + $ups = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.UserProfileServiceAppName + } + if ($null -eq $ups) { $message = ("No User Profile Service Application was found " + ` @@ -487,8 +489,10 @@ function Test-SPDscUserProfileDBReadOnly() $UserProfileServiceAppName = $args[0] $eventSource = $args[1] - $serviceApps = Get-SPServiceApplication -Name $UserProfileServiceAppName ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $UserProfileServiceAppName + } + if ($null -eq $serviceApps) { $message = ("No user profile service was found " + ` diff --git a/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 index 7b7815b20..cda93444b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 @@ -36,8 +36,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name ApplicationPool = $params.ApplicationPool @@ -151,8 +153,8 @@ function Set-TargetResource $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool - Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { + Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Visio.Server.Administration.VisioGraphicsServiceApplication" } | Set-SPVisioServiceApplication -ServiceApplicationPool $appPool } @@ -167,8 +169,8 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $app = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { + $app = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` $_.GetType().FullName -eq "Microsoft.Office.Visio.Server.Administration.VisioGraphicsServiceApplication" } diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 index 2fe336b2a..0a62e1799 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 @@ -121,55 +121,26 @@ function Get-TargetResource } $zones = $wa.IisSettings.Keys - $default = @() - $intranet = @() - $internet = @() - $extranet = @() - $custom = @() + $zoneConfig = @{} foreach ($zone in $zones) { + $zoneName = $zone.ToString() + $zoneConfig.$zoneName = @() + $authProviders = Get-SPAuthenticationProvider -WebApplication $params.WebAppUrl -Zone $zone if ($null -eq $authProviders) { - $localAuthMode = "Classic" - $windowsAuthMethod = $null - $basicAuth = $null - $authenticationProvider = $null - $roleProvider = $null - $membershipProvider = $null - $provider = @{ - AuthenticationMethod = $localAuthMode - WindowsAuthMethod = $windowsAuthMethod - UseBasicAuth = $basicAuth - AuthenticationProvider = $authenticationProvider - MembershipProvider = $membershipProvider - RoleProvider = $roleProvider - } - switch ($zone) - { - "Default" - { - $default += $provider - } - "Intranet" - { - $intranet += $provider - } - "Internet" - { - $internet += $provider - } - "Extranet" - { - $extranet += $provider - } - "Custom" - { - $custom += $provider - } + AuthenticationMethod = "Classic" + WindowsAuthMethod = $null + UseBasicAuth = $null + AuthenticationProvider = $null + MembershipProvider = $null + RoleProvider = $null } + + $zoneConfig.$zoneName += $provider } else { @@ -223,40 +194,19 @@ function Get-TargetResource MembershipProvider = $membershipProvider RoleProvider = $roleProvider } - switch ($zone) - { - "Default" - { - $default += $provider - } - "Intranet" - { - $intranet += $provider - } - "Internet" - { - $internet += $provider - } - "Extranet" - { - $extranet += $provider - } - "Custom" - { - $custom += $provider - } - } + + $zoneConfig.$zoneName += $provider } } } return @{ WebAppUrl = $params.WebAppUrl - Default = $default - Intranet = $intranet - Internet = $internet - Extranet = $extranet - Custom = $custom + Default = $zoneConfig.Default + Intranet = $zoneConfig.Intranet + Internet = $zoneConfig.Internet + Extranet = $zoneConfig.Extranet + Custom = $zoneConfig.Custom } } return $result @@ -416,7 +366,7 @@ function Set-TargetResource if ($Intranet) { # Check if specified zone exists - if ($CurrentValues.ContainsKey("Intranet") -eq $false) + if ($null -eq $CurrentValues.Intranet) { $message = "Specified zone Intranet does not exist" Add-SPDscEvent -Message $message ` @@ -440,7 +390,7 @@ function Set-TargetResource if ($Internet) { # Check if specified zone exists - if ($CurrentValues.ContainsKey("Internet") -eq $false) + if ($null -eq $CurrentValues.Internet) { $message = "Specified zone Internet does not exist" Add-SPDscEvent -Message $message ` @@ -464,7 +414,7 @@ function Set-TargetResource if ($Extranet) { # Check if specified zone exists - if ($CurrentValues.ContainsKey("Extranet") -eq $false) + if ($null -eq $CurrentValues.Extranet) { $message = "Specified zone Extranet does not exist" Add-SPDscEvent -Message $message ` @@ -488,7 +438,7 @@ function Set-TargetResource if ($Custom) { # Check if specified zone exists - if ($CurrentValues.ContainsKey("Custom") -eq $false) + if ($null -eq $CurrentValues.Custom) { $message = "Specified zone Custom does not exist" Add-SPDscEvent -Message $message ` @@ -577,7 +527,7 @@ function Test-TargetResource if ($Intranet) { - if ($CurrentValues.ContainsKey("Intranet") -eq $false) + if ($null -eq $CurrentValues.Intranet) { $message = "Specified zone Intranet does not exist" Add-SPDscEvent -Message $message ` @@ -600,7 +550,7 @@ function Test-TargetResource if ($Internet) { - if ($CurrentValues.ContainsKey("Internet") -eq $false) + if ($null -eq $CurrentValues.Internet) { $message = "Specified zone Internet does not exist" Add-SPDscEvent -Message $message ` @@ -623,7 +573,7 @@ function Test-TargetResource if ($Extranet) { - if ($CurrentValues.ContainsKey("Extranet") -eq $false) + if ($null -eq $CurrentValues.Extranet) { $message = "Specified zone Extranet does not exist" Add-SPDscEvent -Message $message ` @@ -646,7 +596,7 @@ function Test-TargetResource if ($Custom) { - if ($CurrentValues.ContainsKey("Custom") -eq $false) + if ($null -eq $CurrentValues.Custom) { $message = "Specified zone Custom does not exist" Add-SPDscEvent -Message $message ` diff --git a/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 index f1f953e40..3ea7a7796 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 @@ -153,8 +153,10 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name ` - -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } + $nullReturn = @{ Name = $params.Name Ensure = "Absent" @@ -439,9 +441,9 @@ function Set-TargetResource $params = $args[0] $eventSource = $args[1] - $serviceApp = Get-SPServiceApplication -Name $params.Name ` - | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Word.Server.Service.WordServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Word.Server.Service.WordServiceApplication" } # Check if the specified Application Pool is different and change if so @@ -594,8 +596,9 @@ function Set-TargetResource Invoke-SPDscCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Word.Server.Service.WordServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Word.Server.Service.WordServiceApplication" } if ($null -ne $serviceApp) { diff --git a/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 index 3f39956b4..59c260b59 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 @@ -73,7 +73,9 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue + $serviceApps = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name + } $nullReturn = @{ Name = $params.Name @@ -249,8 +251,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" } $appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool Set-SPWorkManagementServiceApplication -Identity $serviceApp -ApplicationPool $appPool @@ -311,8 +314,9 @@ function Set-TargetResource $setParams.MinimumTimeBetweenSearchQueries = New-TimeSpan -Days $setParams.MinimumTimeBetweenSearchQueries } $setParams.Add("Confirm", $false) - $appService = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" + $appService = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" } $appService | Set-SPWorkManagementServiceApplication @setPArams | Out-Null @@ -328,8 +332,9 @@ function Set-TargetResource -ScriptBlock { $params = $args[0] - $serviceApp = Get-SPServiceApplication -Name $params.Name | Where-Object -FilterScript { - $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" + $serviceApp = Get-SPServiceApplication | Where-Object -FilterScript { + $_.Name -eq $params.Name -and ` + $_.GetType().FullName -eq "Microsoft.Office.Server.WorkManagement.WorkManagementServiceApplication" } $proxies = Get-SPServiceApplicationProxy diff --git a/tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 index 0fd98cdbc..50fcf6f53 100644 --- a/tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDSC.SPPowerPointAutomationServiceApp.Tests.ps1 @@ -49,7 +49,7 @@ try InModuleScope -ModuleName $script:DSCResourceFullName -ScriptBlock { Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { BeforeAll { - Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + Invoke-Command -Scriptblock $Global:SPDscHelper.InitializeScript -NoNewScope # Initialize tests $getTypeFullName = "Microsoft.Office.Server.PowerPoint.Administration.PowerPointConversionServiceApplication" @@ -255,6 +255,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp | Add-Member -MemberType ScriptMethod ` @@ -299,6 +300,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -343,6 +345,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds MaximumConversionsPerWorker = $testParams.MaximumConversionsPerWorker @@ -400,6 +403,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CacheExpirationPeriodInSeconds = $testParams.CacheExpirationPeriodInSeconds MaximumConversionsPerWorker = $testParams.MaximumConversionsPerWorker @@ -487,6 +491,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Other SharePoint Services App Pool" } } $spServiceApp | Add-Member -MemberType ScriptMethod ` @@ -518,6 +523,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp | Add-Member -MemberType ScriptMethod ` diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 index a62e9b819..42f53e849 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 @@ -149,6 +149,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Access Services Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name DatabaseServer = $testParams.DatabaseServer ApplicationPool = @{ Name = $testParams.ApplicationPool } } @@ -191,6 +192,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Access Services Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name DatabaseServer = $testParams.DatabaseServer ApplicationPool = @{ Name = $testParams.ApplicationPool } } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServices2010.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServices2010.Tests.ps1 index 039c5cdba..01b6ee528 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServices2010.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServices2010.Tests.ps1 @@ -49,7 +49,7 @@ try InModuleScope -ModuleName $script:DSCResourceFullName -ScriptBlock { Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture { BeforeAll { - Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope + Invoke-Command -Scriptblock $Global:SPDscHelper.InitializeScript -NoNewScope # Initialize tests $getTypeFullName = "Microsoft.Office.Access.Server.MossHost.AccessServerWebServiceApplication" @@ -112,6 +112,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = [PSCustomObject]@{ Name = $testParams.ApplicationPool } @@ -153,6 +154,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = [PSCustomObject]@{ Name = $testParams.ApplicationPool } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPAppManagementServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPAppManagementServiceApp.Tests.ps1 index 985a83090..79fd07cc3 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPAppManagementServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPAppManagementServiceApp.Tests.ps1 @@ -77,7 +77,7 @@ try It "Should return absent from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the test method is called" { @@ -117,7 +117,7 @@ try It "Should return absent from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } } @@ -135,6 +135,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ TypeName = "App Management Service Application" + Name = $testParams.Name DisplayName = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ @@ -169,7 +170,7 @@ try It "Should return present from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } It "Should return true when the test method is called" { @@ -191,6 +192,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "App Management Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong app pool" } Database = @{ Name = $testParams.DatabaseName @@ -237,6 +239,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "App Management Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -305,6 +308,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "App Management Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPBCSServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPBCSServiceApp.Tests.ps1 index d147ce562..a132fa559 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPBCSServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPBCSServiceApp.Tests.ps1 @@ -124,7 +124,7 @@ try It "Should return absent from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the test method is called" { @@ -181,7 +181,7 @@ try It "Should return absent from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } } @@ -200,6 +200,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Business Data Connectivity Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -232,7 +233,7 @@ try It "Should return values from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } It "Should return true when the Test method is called" { @@ -254,6 +255,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Business Data Connectivity Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } Database = @{ Name = $testParams.DatabaseName @@ -293,6 +295,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Business Data Connectivity Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPExcelServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPExcelServiceApp.Tests.ps1 index e527bc6c5..96be90552 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPExcelServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPExcelServiceApp.Tests.ps1 @@ -164,6 +164,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -194,6 +195,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -255,6 +257,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -300,6 +303,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -349,6 +353,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -393,6 +398,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Excel Services Application Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPMachineTranslationServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPMachineTranslationServiceApp.Tests.ps1 index a48797d5d..41f597df3 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPMachineTranslationServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPMachineTranslationServiceApp.Tests.ps1 @@ -128,6 +128,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -164,6 +165,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Machine Translation Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -222,6 +224,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Machine Translation Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -277,6 +280,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Machine Translation Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPManagedMetadataServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPManagedMetadataServiceApp.Tests.ps1 index a1d5c73da..64d485a21 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPManagedMetadataServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPManagedMetadataServiceApp.Tests.ps1 @@ -265,6 +265,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -308,6 +309,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -345,6 +347,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -432,6 +435,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -469,6 +473,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -570,6 +575,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -607,6 +613,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -702,6 +709,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -739,6 +747,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -869,6 +878,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -927,6 +937,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -992,6 +1003,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1104,6 +1116,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1172,6 +1185,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1278,6 +1292,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1337,6 +1352,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1374,6 +1390,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1631,6 +1648,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -1668,6 +1686,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Managed Metadata Service" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPPerformancePointServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPPerformancePointServiceApp.Tests.ps1 index 4f223495c..f49e29a2b 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPPerformancePointServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPPerformancePointServiceApp.Tests.ps1 @@ -95,6 +95,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -127,6 +128,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "PerformancePoint Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -162,6 +164,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Access Services Web Service Application" DisplayName = $testParams.Name + Name = $testParams.Name DatabaseServer = $testParams.DatabaseName ApplicationPool = @{ Name = "Wrong app pool name" } } @@ -204,6 +207,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "PerformancePoint Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerServiceApp.Tests.ps1 index 531415eb0..9e17f712c 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerServiceApp.Tests.ps1 @@ -145,6 +145,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -174,6 +175,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Project Application Services" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -204,6 +206,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Project Application Services" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -241,6 +244,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Project Application Services" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchCrawlRule.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchCrawlRule.Tests.ps1 index f803e4e1f..0448c4eee 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchCrawlRule.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchCrawlRule.Tests.ps1 @@ -61,18 +61,19 @@ try Mock -CommandName Set-SPEnterpriseSearchCrawlRule -MockWith { } Mock -CommandName Get-SPServiceApplication -MockWith { - return @( + $returnval = @{ + Name = "Search Service Application" + } | Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { New-Object -TypeName "Object" | - Add-Member -MemberType ScriptMethod ` - -Name GetType ` - -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru - } ` - -PassThru -Force) + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru + } -PassThru -Force + + return $returnval } function Add-SPDscEvent diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchFileType.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchFileType.Tests.ps1 index 889128da1..4a1bfed57 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchFileType.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchFileType.Tests.ps1 @@ -61,18 +61,23 @@ try Mock -CommandName Set-SPEnterpriseSearchFileFormatState -MockWith { } Mock -CommandName Get-SPServiceApplication -MockWith { - return @( - New-Object -TypeName "Object" | - Add-Member -MemberType ScriptMethod ` - -Name GetType ` - -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru - } ` - -PassThru -Force) + $returnval = @{ + Name = "Search Service Application" + } + + $returnval = $returnval | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru + } ` + -PassThru -Force + + return $returnval } function Add-SPDscEvent @@ -137,9 +142,23 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @(@{ - TypeName = "Some other service app type" - }) + $returnval = @{ + Name = $testParams.ServiceAppName + } + + $returnval = $returnval | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value "Some other service app type" ` + -PassThru + } ` + -PassThru -Force + + return $returnval } } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchServiceApp.Tests.ps1 index dbbcfdfa5..51ed0266e 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPSearchServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPSearchServiceApp.Tests.ps1 @@ -169,6 +169,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } AlertsEnabled = $false Database = @{ @@ -219,6 +220,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -259,6 +261,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -274,7 +277,7 @@ try It "Should return present from the get method" { (Get-TargetResource @testParams).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name } + Assert-MockCalled Get-SPServiceApplication } It "Should return true when the Test method is called" { @@ -296,6 +299,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } Database = @{ Name = $testParams.DatabaseName @@ -351,6 +355,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -410,6 +415,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -461,6 +467,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -518,6 +525,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -563,6 +571,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } SearchCenterUrl = "http://wrong.url.here" Database = @{ @@ -630,6 +639,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } AlertsEnabled = $false Database = @{ @@ -700,6 +710,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } SearchCenterUrl = "http://search.sp.contoso.com" Database = @{ @@ -741,6 +752,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -809,6 +821,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Search Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } CloudIndex = $true Database = @{ diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPSecureStoreServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPSecureStoreServiceApp.Tests.ps1 index 447992a87..d2caebd08 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPSecureStoreServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPSecureStoreServiceApp.Tests.ps1 @@ -182,6 +182,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -216,6 +217,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Secure Store Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -236,39 +238,39 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param ($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Database" - NormalizedDataSource = "DBServer" - Server = @{ - Name = "DBServer" - } - FailoverServer = @{ - Name = "DBServer_Failover" - } - } - ) - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "AuditEnabled" ` - -PassThru | Add-Member -MemberType ScriptMethod ` -Name GetValue ` -Value { - param($x) - return $params.AuditEnabled + param ($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Database" + NormalizedDataSource = "DBServer" + Server = @{ + Name = "DBServer" + } + FailoverServer = @{ + Name = "DBServer_Failover" + } + } + ) } -PassThru - ) - ) - } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "AuditEnabled" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return $params.AuditEnabled + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp @@ -297,6 +299,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Secure Store Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -317,39 +320,39 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Database" - NormalizedDataSource = "DBServer" - Server = @{ - Name = "DBServer" - } - FailoverServer = @{ - Name = "DBServer_Failover" - } - } - ) - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "AuditEnabled" ` - -PassThru | Add-Member -MemberType ScriptMethod ` -Name GetValue ` -Value { param($x) - return $params.AuditEnabled + return ( + @{ + FullName = $getTypeFullName + Name = "Database" + NormalizedDataSource = "DBServer" + Server = @{ + Name = "DBServer" + } + FailoverServer = @{ + Name = "DBServer_Failover" + } + } + ) } -PassThru - ) - ) - } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "AuditEnabled" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return $params.AuditEnabled + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp @@ -430,6 +433,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Secure Store Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } @@ -450,39 +454,39 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Database" - NormalizedDataSource = "DBServer" - Server = @{ - Name = "DBServer" - } - FailoverServer = @{ - Name = "DBServer_Failover" - } - } - ) - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "AuditEnabled" ` - -PassThru | Add-Member -MemberType ScriptMethod ` -Name GetValue ` -Value { param($x) - return $params.AuditEnabled + return ( + @{ + FullName = $getTypeFullName + Name = "Database" + NormalizedDataSource = "DBServer" + Server = @{ + Name = "DBServer" + } + FailoverServer = @{ + Name = "DBServer_Failover" + } + } + ) } -PassThru - ) - ) - } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "AuditEnabled" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return $params.AuditEnabled + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp @@ -517,6 +521,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Secure Store Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -537,39 +542,39 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Wrong Database" - NormalizedDataSource = "DBServer" - Server = @{ - Name = "DBServer" - } - FailoverServer = @{ - Name = "DBServer_Failover" + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Wrong Database" + NormalizedDataSource = "DBServer" + Server = @{ + Name = "DBServer" + } + FailoverServer = @{ + Name = "DBServer_Failover" + } } - } + ) + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "AuditEnabled" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return $params.AuditEnabled + } -PassThru + ) ) } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "AuditEnabled" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return $params.AuditEnabled - } -PassThru - ) - ) - } -PassThru } -PassThru -Force return $spServiceApp @@ -607,6 +612,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Secure Store Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -627,39 +633,39 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "SecureStoreDB" - NormalizedDataSource = "Wrong DBServer" - Server = @{ - Name = "Wrong DBServer" - } - FailoverServer = @{ - Name = "DBServer_Failover" - } - } - ) - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "AuditEnabled" ` - -PassThru | Add-Member -MemberType ScriptMethod ` -Name GetValue ` -Value { param($x) - return $params.AuditEnabled + return ( + @{ + FullName = $getTypeFullName + Name = "SecureStoreDB" + NormalizedDataSource = "Wrong DBServer" + Server = @{ + Name = "Wrong DBServer" + } + FailoverServer = @{ + Name = "DBServer_Failover" + } + } + ) } -PassThru - ) - ) - } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "AuditEnabled" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return $params.AuditEnabled + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 index 404385f13..38bb12b60 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPServiceAppSecurity.Tests.ps1 @@ -322,7 +322,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -392,7 +394,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -460,7 +464,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -518,7 +524,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -565,7 +573,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity { @@ -625,7 +635,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -680,7 +692,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -739,7 +753,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -791,7 +807,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -820,7 +838,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -863,7 +883,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity { $security = @{ @@ -927,7 +949,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity { @@ -989,7 +1013,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -1045,7 +1071,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -1098,7 +1126,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -1134,7 +1164,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity -MockWith { @@ -1177,7 +1209,9 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @{ } + return @{ + Name = $testParams.ServiceAppName + } } Mock -CommandName Get-SPServiceApplicationSecurity { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPSubscriptionSettingsServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPSubscriptionSettingsServiceApp.Tests.ps1 index cc361a362..4fcd6c762 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPSubscriptionSettingsServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPSubscriptionSettingsServiceApp.Tests.ps1 @@ -118,6 +118,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -149,6 +150,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Microsoft SharePoint Foundation Subscription Settings Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -170,25 +172,25 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Test_DB" - NormalizedDataSource = "TestServer\Instance" - FailoverServer = @{ - Name = "DBServer_Failover" + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Test_DB" + NormalizedDataSource = "TestServer\Instance" + FailoverServer = @{ + Name = "DBServer_Failover" + } } - } - ) - } -PassThru - ) - ) - } -PassThru - } -PassThru -Force + ) + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name IsConnected ` @@ -237,6 +239,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Microsoft SharePoint Foundation Subscription Settings Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -258,24 +261,24 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Test_DB" - NormalizedDataSource = "TestServer\Instance" - FailoverServer = @{ - Name = "DBServer_Failover" + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Test_DB" + NormalizedDataSource = "TestServer\Instance" + FailoverServer = @{ + Name = "DBServer_Failover" + } } - } - ) - } -PassThru - ) - ) - } -PassThru + ) + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp @@ -305,6 +308,7 @@ try $spServiceApp = [pscustomobject]@{ TypeName = "Microsoft SharePoint Foundation Subscription Settings Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod ` @@ -329,24 +333,24 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Test_DB" - NormalizedDataSource = "TestServer\Instance" - FailoverServer = @{ - Name = "DBServer_Failover" + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Test_DB" + NormalizedDataSource = "TestServer\Instance" + FailoverServer = @{ + Name = "DBServer_Failover" + } } - } - ) - } -PassThru - ) - ) - } -PassThru + ) + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp @@ -403,6 +407,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Microsoft SharePoint Foundation Subscription Settings Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } @@ -423,24 +428,24 @@ try -Name Name ` -Value "Database" ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return ( - @{ - FullName = $getTypeFullName - Name = "Test_DB" - NormalizedDataSource = "TestServer\Instance" - FailoverServer = @{ - Name = "DBServer_Failover" + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return ( + @{ + FullName = $getTypeFullName + Name = "Test_DB" + NormalizedDataSource = "TestServer\Instance" + FailoverServer = @{ + Name = "DBServer_Failover" + } } - } - ) - } -PassThru - ) - ) - } -PassThru + ) + } -PassThru + ) + ) + } -PassThru } -PassThru -Force return $spServiceApp } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUsageApplication.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUsageApplication.Tests.ps1 index cd0194ca7..139deb709 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUsageApplication.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUsageApplication.Tests.ps1 @@ -181,6 +181,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Usage and Health Data Collection Service Application" DisplayName = $testParams.Name + Name = $testParams.Name UsageDatabase = @{ Name = $testParams.DatabaseName NormalizedDataSource = $testParams.DatabaseServer @@ -220,6 +221,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Usage and Health Data Collection Service Application" DisplayName = $testParams.Name + Name = $testParams.Name UsageDatabase = @{ Name = $testParams.DatabaseName NormalizedDataSource = $testParams.DatabaseServer @@ -269,6 +271,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Usage and Health Data Collection Service Application" DisplayName = $testParams.Name + Name = $testParams.Name UsageDatabase = @{ Name = $testParams.DatabaseName NormalizedDataSource = $testParams.DatabaseServer @@ -311,6 +314,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Usage and Health Data Collection Service Application" DisplayName = $testParams.Name + Name = $testParams.Name UsageDatabase = @{ Name = "db" NormalizedDataSource = "server" @@ -369,6 +373,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Usage and Health Data Collection Service Application" DisplayName = $testParams.Name + Name = $testParams.Name UsageDatabase = @{ Name = "db" NormalizedDataSource = "server" diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 index 0967f6705..61f8b5f9f 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileProperty.Tests.ps1 @@ -435,16 +435,16 @@ try } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } - $userProfileServiceValidConnection = @{ - Name = "User Profile Service Application" - TypeName = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - ServiceApplicationProxyGroup = "Proxy Group" - ConnectionManager = @($connection) + Mock -CommandName Get-SPServiceApplication { + return @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + ServiceApplicationProxyGroup = "Proxy Group" + ConnectionManager = @($connection) + } } - Mock -CommandName Get-SPServiceApplication { return $userProfileServiceValidConnection } - function Add-SPDscEvent { param ( @@ -487,7 +487,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $false @@ -535,7 +535,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $false @@ -572,7 +572,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $false @@ -673,7 +673,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $false @@ -712,7 +712,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsNewProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $false @@ -758,7 +758,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $true @@ -810,7 +810,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $true @@ -859,7 +859,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $true @@ -904,7 +904,7 @@ try $Global:SPUPGetPropertyByNameCalled = $false $Global:SPUPSMappingItemCalled = $false (Get-TargetResource @testParamsNewProperty).Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParamsUpdateProperty.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:SPUPGetProfileSubtypeCalled | Should -Be $true $Global:SPUPGetPropertyByNameCalled | Should -Be $true $Global:SPUPSMappingItemCalled | Should -Be $true diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 index a92f86b26..40c2d6424 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSection.Tests.ps1 @@ -184,15 +184,15 @@ try } -PassThru ) } -ParameterFilter { $TypeName -eq "Microsoft.Office.Server.UserProfiles.UserProfileConfigManager" } - $userProfileService = @{ - Name = "User Profile Service Application" - TypeName = "User Profile Service Application" - ApplicationPool = "SharePoint Service Applications" - ServiceApplicationProxyGroup = "Proxy Group" + Mock -CommandName Get-SPServiceApplication -MockWith { + return @{ + Name = "User Profile Service Application" + TypeName = "User Profile Service Application" + ApplicationPool = "SharePoint Service Applications" + ServiceApplicationProxyGroup = "Proxy Group" + } } - Mock -CommandName Get-SPServiceApplication -MockWith { return $userProfileService } - function Add-SPDscEvent { param ( @@ -220,7 +220,7 @@ try It "Should return null from the Get method" { $Global:UpsConfigManagerGetSectionByNameCalled = $false (Get-TargetResource @testParams).Ensure | Should -Be "Absent" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication $Global:UpsConfigManagerGetSectionByNameCalled | Should -Be $true } @@ -310,7 +310,7 @@ try $Global:SPUPGetSectionByNameCalled = $true $currentValues = Get-TargetResource @testParams $currentValues.Ensure | Should -Be "Present" - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 index 2c95f172a..f18a7dadd 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileServiceApp.Tests.ps1 @@ -262,84 +262,88 @@ try -Name DisplayName ` -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value $testParams.Name ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -424,14 +428,18 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name IsConnected ` + -Value { + return $true + } -PassThru ) } } @@ -488,6 +496,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -532,87 +541,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NetBIOSDomainNamesEnabled" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NetBIOSDomainNamesEnabled" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -675,87 +688,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NoILMUsed" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NoILMUsed" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -818,87 +835,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NoILMUsed" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NoILMUsed" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -965,87 +986,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NoILMUsed" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NoILMUsed" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $incorrectProxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $incorrectProxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -1103,87 +1128,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NoILMUsed" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NoILMUsed" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -1243,87 +1272,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NetBIOSDomainNamesEnabled" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NetBIOSDomainNamesEnabled" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } @@ -1373,87 +1406,91 @@ try -Value $testParams.Name ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name "NetBIOSDomainNamesEnabled" ` - -Value $false ` + -Name Name ` + -Value $testParams.Name ` -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name Update ` - -Value { - $Global:SPDscUPSAUpdateCalled = $true - } -PassThru | - Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = $testParams.ApplicationPool + Add-Member -MemberType NoteProperty ` + -Name "NetBIOSDomainNamesEnabled" ` + -Value $false ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name Update ` + -Value { + $Global:SPDscUPSAUpdateCalled = $true } -PassThru | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value $proxyGroup ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name IsConnected ` - -Value { - return $true - } -PassThru | + -Name ApplicationPool ` + -Value @{ + Name = $testParams.ApplicationPool + } -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value $proxyGroup ` + -PassThru | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name IsConnected ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - NormalizedDataSource = "SQL.domain.local" - } - } -PassThru - ) - ) + return $true + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + NormalizedDataSource = "SQL.domain.local" + } } -PassThru - } -PassThru -Force + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + NormalizedDataSource = "SQL.domain.local" + } + } -PassThru + ) + ) + } -PassThru + } -PassThru -Force ) } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 index 5f774113e..b2e8be544 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncConnection.Tests.ps1 @@ -314,7 +314,7 @@ try It "Should return null from the Get method" { (Get-TargetResource @testParams).UserProfileService | Should -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { @@ -355,7 +355,7 @@ try It "Should return null from the Get method" { (Get-TargetResource @testParams).UserProfileService | Should -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { @@ -395,7 +395,7 @@ try It "Should return service instance from the Get method" { (Get-TargetResource @testParams).UserProfileService | Should -Not -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { @@ -438,7 +438,7 @@ try It "Should return service instance from the Get method" { (Get-TargetResource @testParams).UserProfileService | Should -Not -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { @@ -521,7 +521,7 @@ try It "Should return service instance from the Get method" { (Get-TargetResource @testParams).UserProfileService | Should -Not -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { @@ -602,12 +602,13 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @( - New-Object -TypeName "Object" | Add-Member -MemberType NoteProperty ` - -Name ServiceApplicationProxyGroup ` - -Value "Proxy Group" ` - -PassThru - ) + $returnval = @{ + Name = $testParams.UserProfileService + } | Add-Member -MemberType NoteProperty ` + -Name ServiceApplicationProxyGroup ` + -Value "Proxy Group" ` + -PassThru + return $returnval } Mock -CommandName New-Object -MockWith { @@ -693,7 +694,7 @@ try It "Should return values from the get method" { (Get-TargetResource @testParams).UserProfileService | Should -Not -BeNullOrEmpty - Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.UserProfileService } + Assert-MockCalled Get-SPServiceApplication } It "Should return false when the Test method is called" { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 index 20962789a..0137420f3 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPUserProfileSyncService.Tests.ps1 @@ -86,75 +86,79 @@ try -Value "User Profile Service Service App" ` -PassThru | Add-Member -MemberType NoteProperty ` - -Name ApplicationPool ` - -Value @{ - Name = "Service Pool" - } -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetType ` - -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetProperties ` - -Value { - param($x) - return @( - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SocialDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - param($x) - return @{ - Name = "SP_SocialDB" - Server = @{ - Name = "SQL.domain.local" + -Name Name ` + -Value "User Profile Service Service App" ` + -PassThru | + Add-Member -MemberType NoteProperty ` + -Name ApplicationPool ` + -Value @{ + Name = "Service Pool" + } -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetProperties ` + -Value { + param($x) + return @( + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SocialDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + param($x) + return @{ + Name = "SP_SocialDB" + Server = @{ + Name = "SQL.domain.local" + } } - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "ProfileDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileDB" - Server = @{ - Name = "SQL.domain.local" + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "ProfileDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileDB" + Server = @{ + Name = "SQL.domain.local" + } } - } - } -PassThru - ), - (New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name Name ` - -Value "SynchronizationDatabase" ` - -PassThru | - Add-Member -MemberType ScriptMethod ` - -Name GetValue ` - -Value { - return @{ - Name = "SP_ProfileSyncDB" - Server = @{ - Name = "SQL.domain.local" + } -PassThru + ), + (New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name Name ` + -Value "SynchronizationDatabase" ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetValue ` + -Value { + return @{ + Name = "SP_ProfileSyncDB" + Server = @{ + Name = "SQL.domain.local" + } } - } - } -PassThru + } -PassThru + ) ) - ) - } -PassThru - } -PassThru -Force + } -PassThru + } -PassThru -Force ) } @@ -289,33 +293,34 @@ try } Mock -CommandName Get-SPServiceApplication -MockWith { - return @( - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name ID ` - -Value ([Guid]::Parse("21946987-5163-418f-b781-2beb83aa191f")) ` - -PassThru | + $returnval = @{ + Name = $testParams.UserProfileServiceAppName + } | Add-Member -MemberType NoteProperty ` + -Name ID ` + -Value ([Guid]::Parse("21946987-5163-418f-b781-2beb83aa191f")) ` + -PassThru | + Add-Member -MemberType ScriptMethod ` + -Name GetType ` + -Value { + New-Object -TypeName "Object" | + Add-Member -MemberType NoteProperty ` + -Name FullName ` + -Value $getTypeFullName ` + -PassThru + } ` + -PassThru -Force | Add-Member -MemberType ScriptMethod ` - -Name GetType ` + -Name SetSynchronizationMachine ` -Value { - New-Object -TypeName "Object" | - Add-Member -MemberType NoteProperty ` - -Name FullName ` - -Value $getTypeFullName ` - -PassThru - } ` - -PassThru -Force | - Add-Member -MemberType ScriptMethod ` - -Name SetSynchronizationMachine ` - -Value { - param( - $computerName, - $syncServiceID, - $FarmUserName, - $FarmPassword - ) - } -PassThru - ) + param( + $computerName, + $syncServiceID, + $FarmUserName, + $FarmPassword + ) + } -PassThru + + return $returnval } } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPVisioServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPVisioServiceApp.Tests.ps1 index fe6154410..c72fe3db6 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPVisioServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPVisioServiceApp.Tests.ps1 @@ -100,6 +100,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [PSCustomObject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod ` -Name GetType ` @@ -131,6 +132,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Visio Graphics Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -178,6 +180,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Visio Graphics Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -215,6 +218,7 @@ try $spServiceApp = [PSCustomObject]@{ TypeName = "Visio Graphics Service Application" DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPWordAutomationServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPWordAutomationServiceApp.Tests.ps1 index b91139d11..0f17a86db 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPWordAutomationServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPWordAutomationServiceApp.Tests.ps1 @@ -213,6 +213,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { return @{ FullName = "Microsoft.Office.UnKnownWebServiceApplication" } @@ -256,6 +257,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName @@ -323,6 +325,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } Database = @{ Name = $testParams.DatabaseName @@ -405,6 +408,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name Database = @{ Name = $testParams.DatabaseName NormalizedDataSource = $testParams.DatabaseServer @@ -487,6 +491,7 @@ try Mock -CommandName Get-SPServiceApplication -MockWith { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } Database = @{ Name = $testParams.DatabaseName diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPWorkManagementServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPWorkManagementServiceApp.Tests.ps1 index d541c95ba..2ccb03dc2 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPWorkManagementServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPWorkManagementServiceApp.Tests.ps1 @@ -99,6 +99,7 @@ try Mock -CommandName Get-SPServiceApplication { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } } $spServiceApp = $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { @@ -168,6 +169,7 @@ try Mock -CommandName Get-SPServiceApplication { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name } $spServiceApp | Add-Member -MemberType ScriptMethod -Name GetType -Value { return @{ FullName = "Microsoft.Office.UnKnownWebServiceApplication" } @@ -206,6 +208,7 @@ try Mock -CommandName Get-SPServiceApplication { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = $testParams.ApplicationPool } AdminSettings = @{ MinimumTimeBetweenEwsSyncSubscriptionSearches = (New-TimeSpan -Minutes 10) @@ -248,6 +251,7 @@ try Mock -CommandName Get-SPServiceApplication { $spServiceApp = [pscustomobject]@{ DisplayName = $testParams.Name + Name = $testParams.Name ApplicationPool = @{ Name = "Wrong App Pool Name" } AdminSettings = @{ MinimumTimeBetweenEwsSyncSubscriptionSearches = (New-TimeSpan -Minutes 10)