diff --git a/CHANGELOG.md b/CHANGELOG.md index 25c2cc11b..b3010f6ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- SharePointDsc + - Added verbose logging of the test results in the Test method + - Added function to create SharePointDsc event log and add log entries + - Added the logging of all test results to the new SharePointDsc event log + ### Fixed - SPFarmSolution diff --git a/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 index 1baa515af..87d2fc473 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAccessServiceApp/MSFT_SPAccessServiceApp.psm1 @@ -188,15 +188,25 @@ function Test-TargetResource if ($CurrentValues.DatabaseServer -ne $DatabaseServer) { - Write-Verbose -Message ("Specified database server does not match the actual " + ` - "database server. This resource cannot move the database " + ` - "to a different SQL instance.") - return $false + $message = "Specified database server does not match the actual database " + ` + "server. This resource cannot move the database to a different " + ` + "SQL instance. Actual: $($CurrentValues.DatabaseServer), " + ` + "Desired: $DatabaseServer" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + $result = $false + } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("Ensure") } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("Ensure") + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 b/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 index 9e25ce070..7db713e07 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAccessServices2010/MSFT_SPAccessServices2010.psm1 @@ -191,9 +191,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "ApplicationPool", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 index dea724ea6..5d60f0e0f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 @@ -283,7 +283,8 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("WebAppName", ` "Zone", ` @@ -293,8 +294,13 @@ function Test-TargetResource } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPAntivirusSettings/MSFT_SPAntivirusSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPAntivirusSettings/MSFT_SPAntivirusSettings.psm1 index 8e36ef4f5..0538cecab 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAntivirusSettings/MSFT_SPAntivirusSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAntivirusSettings/MSFT_SPAntivirusSettings.psm1 @@ -226,8 +226,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAppCatalog/MSFT_SPAppCatalog.psm1 b/SharePointDsc/DSCResources/MSFT_SPAppCatalog/MSFT_SPAppCatalog.psm1 index f41c4d069..2e0300929 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAppCatalog/MSFT_SPAppCatalog.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAppCatalog/MSFT_SPAppCatalog.psm1 @@ -176,9 +176,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SiteUrl") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAppDomain/MSFT_SPAppDomain.psm1 b/SharePointDsc/DSCResources/MSFT_SPAppDomain/MSFT_SPAppDomain.psm1 index e629f00e7..a58bd8ed5 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAppDomain/MSFT_SPAppDomain.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAppDomain/MSFT_SPAppDomain.psm1 @@ -96,9 +96,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("AppDomain", "Prefix") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 index 4865a5a9b..985e8ef94 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAppManagementServiceApp/MSFT_SPAppManagementServiceApp.psm1 @@ -299,13 +299,23 @@ function Test-TargetResource if ($CurrentValues.ProxyName -eq "") { - return $false + $message = "The specified ProxyName is empty" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + $result = $false + } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("ApplicationPool", ` + "Ensure") } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("ApplicationPool", ` - "Ensure") + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAppStoreSettings/MSFT_SPAppStoreSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPAppStoreSettings/MSFT_SPAppStoreSettings.psm1 index 83aee70d0..5565b2712 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAppStoreSettings/MSFT_SPAppStoreSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAppStoreSettings/MSFT_SPAppStoreSettings.psm1 @@ -150,7 +150,11 @@ function Test-TargetResource if ($null -eq $currentValues.WebAppUrl) { - Write-Verbose -Message "Specified web application does not exist." + $message = "Specified web application does not exist." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -158,6 +162,13 @@ function Test-TargetResource { if ($AllowAppPurchases -ne $CurrentValues.AllowAppPurchases) { + $message = ("The parameter AllowAppPurchases for web application $WebAppUrl "+ ` + "is not in the desired state. Actual: " + ` + "$($CurrentValues.AllowAppPurchases), Desired: $AllowAppPurchases") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -166,10 +177,18 @@ function Test-TargetResource { if ($AllowAppsForOffice -ne $CurrentValues.AllowAppsForOffice) { + $message = ("The parameter AllowAppsForOffice for web application $WebAppUrl "+ ` + "is not in the desired state. Actual: " + ` + "$($CurrentValues.AllowAppsForOffice), Desired: $AllowAppsForOffice") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } + Write-Verbose -Message "Test-TargetResource returned true" return $true } diff --git a/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 b/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 index 02ebbc4c2..436df03b2 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAuthenticationRealm/MSFT_SPAuthenticationRealm.psm1 @@ -95,9 +95,14 @@ function Test-TargetResource() Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("AuthenticationRealm") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPAzureAccessControlServiceAppProxy/MSFT_SPAzureAccessControlServiceAppProxy.psm1 b/SharePointDsc/DSCResources/MSFT_SPAzureAccessControlServiceAppProxy/MSFT_SPAzureAccessControlServiceAppProxy.psm1 index 3803bfe90..470f5ed0f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAzureAccessControlServiceAppProxy/MSFT_SPAzureAccessControlServiceAppProxy.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAzureAccessControlServiceAppProxy/MSFT_SPAzureAccessControlServiceAppProxy.psm1 @@ -184,16 +184,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("MetadataServiceEndpointUri", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 index 853b04938..dd974b9d3 100644 --- a/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPBCSServiceApp/MSFT_SPBCSServiceApp.psm1 @@ -269,9 +269,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 index 9ea35abf0..74fe9f870 100644 --- a/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPBlobCacheSettings/MSFT_SPBlobCacheSettings.psm1 @@ -374,18 +374,27 @@ function Test-TargetResource { if (-not (Test-Path -Path $Location)) { - Write-Verbose "Blob Cache Folder $Location does not exist" + $message = "Blob Cache Folder $Location does not exist" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("EnableCache", - "Location", - "MaxSizeInGB", - "FileType", - "MaxAgeInSeconds") + "Location", + "MaxSizeInGB", + "FileType", + "MaxAgeInSeconds") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 b/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 index a47f88c71..fa811666a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPCacheAccounts/MSFT_SPCacheAccounts.psm1 @@ -282,7 +282,8 @@ function Test-TargetResource if ($SetWebAppPolicy -eq $true) { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuperUserAlias", ` "SuperReaderAlias", ` @@ -290,11 +291,16 @@ function Test-TargetResource } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuperUserAlias", ` "SuperReaderAlias") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 b/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 index 8562a6d3e..d1fdee2e6 100644 --- a/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPConfigWizard/MSFT_SPConfigWizard.psm1 @@ -317,9 +317,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPContentDatabase/MSFT_SPContentDatabase.psm1 b/SharePointDsc/DSCResources/MSFT_SPContentDatabase/MSFT_SPContentDatabase.psm1 index 2e6a67464..3f02cdffe 100644 --- a/SharePointDsc/DSCResources/MSFT_SPContentDatabase/MSFT_SPContentDatabase.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPContentDatabase/MSFT_SPContentDatabase.psm1 @@ -398,14 +398,23 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('DatabaseServer') -and $PSBoundParameters.DatabaseServer -ne $null -and $CurrentValues.DatabaseServer -ne $PSBoundParameters.DatabaseServer) { - Write-Verbose -Message ("Specified database server does not match the actual " + ` - "database server. This resource cannot move the database " + ` - "to a different SQL instance.") + $message = ("Specified database server $DatabaseServer does not match the actual " + ` + "database server $($CurrentValues.DatabaseServer). This resource cannot move " + ` + "the database to a different SQL instance.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPDatabaseAAG/MSFT_SPDatabaseAAG.psm1 b/SharePointDsc/DSCResources/MSFT_SPDatabaseAAG/MSFT_SPDatabaseAAG.psm1 index f1c12f5ce..a086b53ea 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDatabaseAAG/MSFT_SPDatabaseAAG.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDatabaseAAG/MSFT_SPDatabaseAAG.psm1 @@ -295,8 +295,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "DatabaseName") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPDesignerSettings/MSFT_SPDesignerSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPDesignerSettings/MSFT_SPDesignerSettings.psm1 index 0b2e048df..1ddb0dc88 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDesignerSettings/MSFT_SPDesignerSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDesignerSettings/MSFT_SPDesignerSettings.psm1 @@ -443,8 +443,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPDiagnosticLoggingSettings/MSFT_SPDiagnosticLoggingSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPDiagnosticLoggingSettings/MSFT_SPDiagnosticLoggingSettings.psm1 index 5eec23813..139d35f87 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDiagnosticLoggingSettings/MSFT_SPDiagnosticLoggingSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDiagnosticLoggingSettings/MSFT_SPDiagnosticLoggingSettings.psm1 @@ -361,8 +361,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/MSFT_SPDiagnosticsProvider.psm1 b/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/MSFT_SPDiagnosticsProvider.psm1 index dd5588fc7..fbeeb0840 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/MSFT_SPDiagnosticsProvider.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDiagnosticsProvider/MSFT_SPDiagnosticsProvider.psm1 @@ -181,13 +181,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "Name", "Retention", "MaxTotalSizeInBytes", "Enabled") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPDistributedCacheClientSettings/MSFT_SPDistributedCacheClientSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPDistributedCacheClientSettings/MSFT_SPDistributedCacheClientSettings.psm1 index e6b325ccc..7614bd38a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDistributedCacheClientSettings/MSFT_SPDistributedCacheClientSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDistributedCacheClientSettings/MSFT_SPDistributedCacheClientSettings.psm1 @@ -1042,54 +1042,59 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("DLTCMaxConnectionsToServer", - "DLTCRequestTimeout", - "DLTCChannelOpenTimeOut", - "DVSCMaxConnectionsToServer", - "DVSCRequestTimeout", - "DVSCChannelOpenTimeOut", - "DACMaxConnectionsToServer", - "DACRequestTimeout", - "DACChannelOpenTimeOut", - "DAFMaxConnectionsToServer", - "DAFRequestTimeout", - "DAFChannelOpenTimeOut", - "DAFCMaxConnectionsToServer", - "DAFCRequestTimeout", - "DAFCChannelOpenTimeOut", - "DBCMaxConnectionsToServer", - "DBCRequestTimeout", - "DBCChannelOpenTimeOut", - "DDCMaxConnectionsToServer", - "DDCRequestTimeout", - "DDCChannelOpenTimeOut", - "DSCMaxConnectionsToServer", - "DSCRequestTimeout", - "DSCChannelOpenTimeOut", - "DTCMaxConnectionsToServer", - "DTCRequestTimeout", - "DTCChannelOpenTimeOut", - "DSTACMaxConnectionsToServer", - "DSTACRequestTimeout", - "DSTACChannelOpenTimeOut", - "DFLTCMaxConnectionsToServer", - "DFLTCRequestTimeout", - "DFLTCChannelOpenTimeOut", - "DSWUCMaxConnectionsToServer", - "DSWUCRequestTimeout", - "DSWUCChannelOpenTimeOut", - "DUGCMaxConnectionsToServer", - "DUGCRequestTimeout", - "DUGCChannelOpenTimeOut", - "DRTCMaxConnectionsToServer", - "DRTCRequestTimeout", - "DRTCChannelOpenTimeOut", - "DHSCMaxConnectionsToServer", - "DHSCRequestTimeout", - "DHSCChannelOpenTimeOut" - ) + "DLTCRequestTimeout", + "DLTCChannelOpenTimeOut", + "DVSCMaxConnectionsToServer", + "DVSCRequestTimeout", + "DVSCChannelOpenTimeOut", + "DACMaxConnectionsToServer", + "DACRequestTimeout", + "DACChannelOpenTimeOut", + "DAFMaxConnectionsToServer", + "DAFRequestTimeout", + "DAFChannelOpenTimeOut", + "DAFCMaxConnectionsToServer", + "DAFCRequestTimeout", + "DAFCChannelOpenTimeOut", + "DBCMaxConnectionsToServer", + "DBCRequestTimeout", + "DBCChannelOpenTimeOut", + "DDCMaxConnectionsToServer", + "DDCRequestTimeout", + "DDCChannelOpenTimeOut", + "DSCMaxConnectionsToServer", + "DSCRequestTimeout", + "DSCChannelOpenTimeOut", + "DTCMaxConnectionsToServer", + "DTCRequestTimeout", + "DTCChannelOpenTimeOut", + "DSTACMaxConnectionsToServer", + "DSTACRequestTimeout", + "DSTACChannelOpenTimeOut", + "DFLTCMaxConnectionsToServer", + "DFLTCRequestTimeout", + "DFLTCChannelOpenTimeOut", + "DSWUCMaxConnectionsToServer", + "DSWUCRequestTimeout", + "DSWUCChannelOpenTimeOut", + "DUGCMaxConnectionsToServer", + "DUGCRequestTimeout", + "DUGCChannelOpenTimeOut", + "DRTCMaxConnectionsToServer", + "DRTCRequestTimeout", + "DRTCChannelOpenTimeOut", + "DHSCMaxConnectionsToServer", + "DHSCRequestTimeout", + "DHSCChannelOpenTimeOut" + ) + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 b/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 index 9b5edaa05..6ddb7c239 100644 --- a/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1 @@ -243,8 +243,8 @@ function Set-TargetResource if ($ServerCount -ge $params.ServerProvisionOrder.Length) { throw ("The server $($env:COMPUTERNAME) was not found in the " + ` - "ServerProvisionOrder array of Distributed Cache server(s). " + ` - "The server must be included in ServerProvisionOrder or Ensure equal to Absent.") + "ServerProvisionOrder array of Distributed Cache server(s). " + ` + "The server must be included in ServerProvisionOrder or Ensure equal to Absent.") } $currentServer = $params.ServerProvisionOrder[$serverCount] } @@ -525,11 +525,19 @@ function Test-TargetResource { if ($ServiceAccount -ne $CurrentValues.ServiceAccount) { + $message = ("The parameter ServiceAccount is not in the desired "+ ` + "state. Actual: $($CurrentValues.ServiceAccount), " + ` + "Desired: $ServiceAccount") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", ` "CreateFirewallRules", ` @@ -537,10 +545,15 @@ function Test-TargetResource } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 index f984f47eb..90bca0d20 100644 --- a/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPExcelServiceApp/MSFT_SPExcelServiceApp.psm1 @@ -589,26 +589,27 @@ function Test-TargetResource Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" $mainCheck = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @( - "Ensure", - "CachingOfUnusedFilesEnable", - "CrossDomainAccessAllowed", - "EncryptedUserConnectionRequired", - "ExternalDataConnectionLifetime", - "FileAccessMethod", - "LoadBalancingScheme", - "MemoryCacheThreshold", - "PrivateBytesMax", - "SessionsPerUserMax", - "SiteCollectionAnonymousSessionsMax", - "TerminateProcessOnAccessViolation", - "ThrottleAccessViolationsPerSiteCollection", - "UnattendedAccountApplicationId", - "UnusedObjectAgeMax", - "WorkbookCache", - "WorkbookCacheSizeMax" - ) + "Ensure", + "CachingOfUnusedFilesEnable", + "CrossDomainAccessAllowed", + "EncryptedUserConnectionRequired", + "ExternalDataConnectionLifetime", + "FileAccessMethod", + "LoadBalancingScheme", + "MemoryCacheThreshold", + "PrivateBytesMax", + "SessionsPerUserMax", + "SiteCollectionAnonymousSessionsMax", + "TerminateProcessOnAccessViolation", + "ThrottleAccessViolationsPerSiteCollection", + "UnattendedAccountApplicationId", + "UnusedObjectAgeMax", + "WorkbookCache", + "WorkbookCacheSizeMax" + ) if ($Ensure -eq "Present" -and $mainCheck -eq $true -and $null -ne $TrustedFileLocations) @@ -621,8 +622,11 @@ function Test-TargetResource } if ($null -eq $matchingCurrentValue) { - Write-Verbose -Message ("Trusted file location '$($_.Address)' was not found " + ` - "in the Excel service app. Desired state is false.") + $message = ("Trusted file location '$($_.Address)' was not found " + ` + "in the Excel service app. Desired state is false.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + return $false } else @@ -632,10 +636,13 @@ function Test-TargetResource { if ($desiredLocation.$_ -ne $matchingCurrentValue.$_) { - Write-Verbose -Message ("Trusted file location '$($desiredLocation.Address)' did not match " + ` - "desired property '$_'. Desired value is " + ` - "'$($desiredLocation.$_)' but the current value is " + ` - "'$($matchingCurrentValue.$_)'") + $message = ("Trusted file location '$($desiredLocation.Address)' did not match " + ` + "desired property '$_'. Desired value is " + ` + "'$($desiredLocation.$_)' but the current value is " + ` + "'$($matchingCurrentValue.$_)'") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + return $false } } @@ -645,6 +652,8 @@ function Test-TargetResource } if ($locationCheck -contains $false) { + Write-Verbose -Message "Test-TargetResource returned false" + return $false } @@ -656,24 +665,32 @@ function Test-TargetResource } if ($null -eq $matchingDesiredValue) { - Write-Verbose -Message ("Existing trusted file location '$($_.Address)' was not " + ` - "found in the desired state for this service " + ` - "application. Desired state is false.") + $message = ("Existing trusted file location '$($_.Address)' was not " + ` + "found in the desired state for this service " + ` + "application. Desired state is false.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + return $false } return $true } if ($locationCheck -contains $false) { + Write-Verbose -Message "Test-TargetResource returned false" + return $false } # at this point if no other value has been returned, all desired entires exist and are # correct, and no existing entries exist that are not in desired state, so return true + Write-Verbose -Message "Test-TargetResource returned true" + return $true } else { + Write-Verbose -Message "Test-TargetResource returned $mainCheck" return $mainCheck } } diff --git a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 index 353751d63..689506a68 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 @@ -1137,14 +1137,19 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "RunCentralAdmin", - "CentralAdministrationUrl", - "CentralAdministrationPort", - "CentralAdministrationAuth", - "DeveloperDashboard") + "RunCentralAdmin", + "CentralAdministrationUrl", + "CentralAdministrationPort", + "CentralAdministrationAuth", + "DeveloperDashboard") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 index d278aab6a..9af6b6248 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarmAdministrators/MSFT_SPFarmAdministrators.psm1 @@ -292,6 +292,11 @@ function Test-TargetResource if ($null -eq $CurrentValues.Members) { + $message = "There are no users configured as Farm Administrator" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -303,12 +308,19 @@ function Test-TargetResource if ($null -eq $differences) { - Write-Verbose "Farm Administrators group matches" + Write-Verbose -Message "Farm Administrators group matches the specified Members" + + Write-Verbose -Message "Test-TargetResource returned true" return $true } else { - Write-Verbose "Farm Administrators group does not match" + $message = ("Farm Administrators group does not match the specified Members" + ` + "Actual: $($CurrentValues.Members -join ", "). Desired: $($Members -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -321,7 +333,11 @@ function Test-TargetResource { if (-not($CurrentValues.Members -contains $member)) { - Write-Verbose "$member is not a Farm Administrator. Set result to false" + $message = ("$member is not a Farm Administrator, but is included in MembersToInclude: " + ` + "$($MembersToInclude -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + $result = $false } else @@ -338,7 +354,11 @@ function Test-TargetResource { if ($CurrentValues.Members -contains $member) { - Write-Verbose "$member is a Farm Administrator. Set result to false" + $message = ("$member is a Farm Administrator, but is included in MembersToExclude: " + ` + "$($MembersToExclude -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + $result = $false } else @@ -348,6 +368,8 @@ function Test-TargetResource } } + Write-Verbose -Message "Test-TargetResource returned $result" + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 index e2645d5f5..a7fa1fdf1 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarmPropertyBag/MSFT_SPFarmPropertyBag.psm1 @@ -172,9 +172,14 @@ function Test-TargetResource() Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @('Ensure', 'Key', 'Value') + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 index 412841fdd..00249a821 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarmSolution/MSFT_SPFarmSolution.psm1 @@ -428,9 +428,14 @@ function Test-TargetResource $valuesToCheck += "WebAppUrls" } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Wait-SPDscSolutionJob diff --git a/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 b/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 index fca429718..7f6589874 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFeature/MSFT_SPFeature.psm1 @@ -174,7 +174,6 @@ function Set-TargetResource } } - function Test-TargetResource { [CmdletBinding()] @@ -217,9 +216,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "Version") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPHealthAnalyzerRuleState/MSFT_SPHealthAnalyzerRuleState.psm1 b/SharePointDsc/DSCResources/MSFT_SPHealthAnalyzerRuleState/MSFT_SPHealthAnalyzerRuleState.psm1 index 62b0eff9e..2e345d51f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPHealthAnalyzerRuleState/MSFT_SPHealthAnalyzerRuleState.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPHealthAnalyzerRuleState/MSFT_SPHealthAnalyzerRuleState.psm1 @@ -275,8 +275,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 index 249a0a595..8332c1da5 100644 --- a/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPIncomingEmailSettings/MSFT_SPIncomingEmailSettings.psm1 @@ -381,8 +381,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPInfoPathFormsServiceConfig/MSFT_SPInfoPathFormsServiceConfig.psm1 b/SharePointDsc/DSCResources/MSFT_SPInfoPathFormsServiceConfig/MSFT_SPInfoPathFormsServiceConfig.psm1 index bafdb46e9..55df9492e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPInfoPathFormsServiceConfig/MSFT_SPInfoPathFormsServiceConfig.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPInfoPathFormsServiceConfig/MSFT_SPInfoPathFormsServiceConfig.psm1 @@ -385,23 +385,28 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "AllowUserFormBrowserEnabling", - "AllowUserFormBrowserRendering", - "MaxDataConnectionTimeout", - "DefaultDataConnectionTimeout", - "MaxDataConnectionResponseSize", - "RequireSslForDataConnections", - "AllowEmbeddedSqlForDataConnections", - "AllowUdcAuthenticationForDataConnections", - "AllowUserFormCrossDomainDataConnections", - "AllowEventPropagation", - "MaxPostbacksPerSession", - "MaxUserActionsPerPostback", - "ActiveSessionsTimeout", - "MaxSizeOfUserFormState") + "AllowUserFormBrowserEnabling", + "AllowUserFormBrowserRendering", + "MaxDataConnectionTimeout", + "DefaultDataConnectionTimeout", + "MaxDataConnectionResponseSize", + "RequireSslForDataConnections", + "AllowEmbeddedSqlForDataConnections", + "AllowUdcAuthenticationForDataConnections", + "AllowUserFormCrossDomainDataConnections", + "AllowEventPropagation", + "MaxPostbacksPerSession", + "MaxUserActionsPerPostback", + "ActiveSessionsTimeout", + "MaxSizeOfUserFormState") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 b/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 index 67de8334a..e6efdcdbe 100644 --- a/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPInstall/MSFT_SPInstall.psm1 @@ -438,9 +438,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 b/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 index 894d1f70b..33e95d4b0 100644 --- a/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPInstallLanguagePack/MSFT_SPInstallLanguagePack.psm1 @@ -550,9 +550,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 b/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 index 44f429017..0a36e749b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPInstallPrereqs/MSFT_SPInstallPrereqs.psm1 @@ -1068,9 +1068,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Test-SPDscPrereqInstallStatus @@ -1099,8 +1104,8 @@ function Test-SPDscPrereqInstallStatus "Equals" { $prereq = $InstalledItems | Where-Object -FilterScript { - $null -ne $_.DisplayName -and $_.DisplayName.Trim() -eq $itemToCheck.SearchValue - } + $null -ne $_.DisplayName -and $_.DisplayName.Trim() -eq $itemToCheck.SearchValue + } if ($null -eq $prereq) { $itemsInstalled = $false @@ -1111,8 +1116,8 @@ function Test-SPDscPrereqInstallStatus "Match" { $prereq = $InstalledItems | Where-Object -FilterScript { - $null -ne $_.DisplayName -and $_.DisplayName.Trim() -match $itemToCheck.SearchValue - } + $null -ne $_.DisplayName -and $_.DisplayName.Trim() -match $itemToCheck.SearchValue + } if ($null -eq $prereq) { $itemsInstalled = $false @@ -1123,8 +1128,8 @@ function Test-SPDscPrereqInstallStatus "Like" { $prereq = $InstalledItems | Where-Object -FilterScript { - $null -ne $_.DisplayName -and $_.DisplayName.Trim() -like $itemToCheck.SearchValue - } + $null -ne $_.DisplayName -and $_.DisplayName.Trim() -like $itemToCheck.SearchValue + } if ($null -eq $prereq) { $itemsInstalled = $false diff --git a/SharePointDsc/DSCResources/MSFT_SPIrmSettings/MSFT_SPIrmSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPIrmSettings/MSFT_SPIrmSettings.psm1 index b399be8c5..248e65f53 100644 --- a/SharePointDsc/DSCResources/MSFT_SPIrmSettings/MSFT_SPIrmSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPIrmSettings/MSFT_SPIrmSettings.psm1 @@ -192,8 +192,13 @@ function Test-TargetResource $PSBoundParameters.UseADRMS = $false } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 b/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 index c05d2a651..de75d62b3 100644 --- a/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPLogLevel/MSFT_SPLogLevel.psm1 @@ -292,10 +292,16 @@ function Test-TargetResource if ($null -eq $CurrentValues.SPLogLevelSetting) { + $message = "Error retrieving SPLogLevelSetting for $Name" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } $mismatchedSettingFound = $false + $mismatchedSettings = @() foreach ($DesiredSetting in $SPLogLevelSetting) { @@ -305,6 +311,11 @@ function Test-TargetResource if (($null -ne $DesiredSetting.TraceLevel -and $CurrentSetting.TraceLevel -ne $DesiredSetting.TraceLevel) -or ($null -ne $DesiredSetting.EventLevel -and $CurrentSetting.EventLevel -ne $DesiredSetting.EventLevel)) { + $mismatchedSettings += @{ + Name = $Name + DesiredSetting = $DesiredSetting + $CurrentSetting = $CurrentSetting + } Write-Verbose -Message "SP Log Level setting for $($DesiredSetting.Area):$($DesiredSetting.Name) is not in the desired state" $mismatchedSettingFound = $true } @@ -312,10 +323,35 @@ function Test-TargetResource if ($mismatchedSettingFound) { - return $false + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + $driftedValue = '' + foreach ($setting in $mismatchedSettings) + { + $EventMessage += " TraceLevel: " + $setting.CurrentSetting.TraceLevel + " - EventLevel: " + $setting.CurrentSetting.EventLevel + "`r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + foreach ($setting in $mismatchedSettings) + { + $EventMessage += " TraceLevel: " + $setting.DesiredSetting.TraceLevel + " - EventLevel: " + $setting.DesiredSetting.EventLevel + "`r`n" + } + $EventMessage += " }" + $EventMessage += " `r`n" + $EventMessage += "" + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + $result = $false } else { - return $true + $result = $true } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 index f2e059e1b..73f9e972c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPMachineTranslationServiceApp/MSFT_SPMachineTranslationServiceApp.psm1 @@ -252,14 +252,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", - "ApplicationPool", - "DatabaseName", - "DatabaseServer", - "Ensure") + "ApplicationPool", + "DatabaseName", + "DatabaseServer", + "Ensure") + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPManagedAccount/MSFT_SPManagedAccount.psm1 b/SharePointDsc/DSCResources/MSFT_SPManagedAccount/MSFT_SPManagedAccount.psm1 index 90367b01c..e45c9cc94 100644 --- a/SharePointDsc/DSCResources/MSFT_SPManagedAccount/MSFT_SPManagedAccount.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPManagedAccount/MSFT_SPManagedAccount.psm1 @@ -215,13 +215,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("AccountName", - "Schedule", - "PreExpireDays", - "EmailNotification", - "Ensure") + "Schedule", + "PreExpireDays", + "EmailNotification", + "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 index 2554b856c..8cb82dff2 100644 --- a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceApp/MSFT_SPManagedMetaDataServiceApp.psm1 @@ -771,9 +771,14 @@ function Test-TargetResource "TermStoreAdministrators" "ProxyName") - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceAppDefault/MSFT_SPManagedMetadataServiceAppDefault.psm1 b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceAppDefault/MSFT_SPManagedMetadataServiceAppDefault.psm1 index 25a6f8acd..e182152a1 100644 --- a/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceAppDefault/MSFT_SPManagedMetadataServiceAppDefault.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPManagedMetadataServiceAppDefault/MSFT_SPManagedMetadataServiceAppDefault.psm1 @@ -192,9 +192,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPManagedPath/MSFT_SPManagedPath.psm1 b/SharePointDsc/DSCResources/MSFT_SPManagedPath/MSFT_SPManagedPath.psm1 index b828caa2d..f8bf61be6 100644 --- a/SharePointDsc/DSCResources/MSFT_SPManagedPath/MSFT_SPManagedPath.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPManagedPath/MSFT_SPManagedPath.psm1 @@ -203,13 +203,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("WebAppUrl", - "RelativeUrl", - "Explicit", - "HostHeader", - "Ensure") + "RelativeUrl", + "Explicit", + "HostHeader", + "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 b/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 index 8eceea49f..0733babc6 100644 --- a/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPMinRoleCompliance/MSFT_SPMinRoleCompliance.psm1 @@ -165,9 +165,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("State") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function Get-TargetResource, ` diff --git a/SharePointDsc/DSCResources/MSFT_SPOAppPrincipalMgmtServiceAppProxy/MSFT_SPOAppPrincipalMgmtServiceAppProxy.psm1 b/SharePointDsc/DSCResources/MSFT_SPOAppPrincipalMgmtServiceAppProxy/MSFT_SPOAppPrincipalMgmtServiceAppProxy.psm1 index adf8990dc..de382a0d4 100644 --- a/SharePointDsc/DSCResources/MSFT_SPOAppPrincipalMgmtServiceAppProxy/MSFT_SPOAppPrincipalMgmtServiceAppProxy.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPOAppPrincipalMgmtServiceAppProxy/MSFT_SPOAppPrincipalMgmtServiceAppProxy.psm1 @@ -184,16 +184,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("OnlineTenantUri", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPOfficeOnlineServerBinding/MSFT_SPOfficeOnlineServerBinding.psm1 b/SharePointDsc/DSCResources/MSFT_SPOfficeOnlineServerBinding/MSFT_SPOfficeOnlineServerBinding.psm1 index 6be0bba20..0ca556fa8 100644 --- a/SharePointDsc/DSCResources/MSFT_SPOfficeOnlineServerBinding/MSFT_SPOfficeOnlineServerBinding.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPOfficeOnlineServerBinding/MSFT_SPOfficeOnlineServerBinding.psm1 @@ -174,9 +174,14 @@ function Test-TargetResource { $paramsToCheck += @("Zone", "DnsName") } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $paramsToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPOutgoingEmailSettings/MSFT_SPOutgoingEmailSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPOutgoingEmailSettings/MSFT_SPOutgoingEmailSettings.psm1 index cc580731b..9d391f350 100644 --- a/SharePointDsc/DSCResources/MSFT_SPOutgoingEmailSettings/MSFT_SPOutgoingEmailSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPOutgoingEmailSettings/MSFT_SPOutgoingEmailSettings.psm1 @@ -257,14 +257,19 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SMTPServer", - "FromAddress", - "ReplyToAddress", - "CharacterSet", - "UseTLS", - "SMTPPort") + "FromAddress", + "ReplyToAddress", + "CharacterSet", + "UseTLS", + "SMTPPort") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPPasswordChangeSettings/MSFT_SPPasswordChangeSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPPasswordChangeSettings/MSFT_SPPasswordChangeSettings.psm1 index ae4c662da..e5ce6c92a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPasswordChangeSettings/MSFT_SPPasswordChangeSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPasswordChangeSettings/MSFT_SPPasswordChangeSettings.psm1 @@ -172,12 +172,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("MailAddress", - "DaysBeforeExpiry", - "PasswordChangeWaitTimeSeconds", - "NumberOfRetries") + "DaysBeforeExpiry", + "PasswordChangeWaitTimeSeconds", + "NumberOfRetries") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 index 905340e70..730e8bc6c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPerformancePointServiceApp/MSFT_SPPerformancePointServiceApp.psm1 @@ -256,9 +256,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 index 6024a0f3c..80ecd944a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPowerPointAutomationServiceApp/MSFT_SPPowerPointAutomationServiceApp.psm1 @@ -414,15 +414,21 @@ function Test-TargetResource if ($Ensure -eq "Absent") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 b/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 index 0b45e1089..5e2999738 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProductUpdate/MSFT_SPProductUpdate.psm1 @@ -664,9 +664,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Get-SPDscLocalVersionInfo diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerADResourcePoolSync/MSFT_SPProjectServerADResourcePoolSync.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerADResourcePoolSync/MSFT_SPProjectServerADResourcePoolSync.psm1 index 555858cb7..1ace7173c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerADResourcePoolSync/MSFT_SPProjectServerADResourcePoolSync.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerADResourcePoolSync/MSFT_SPProjectServerADResourcePoolSync.psm1 @@ -237,9 +237,14 @@ function Test-TargetResource } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $paramsToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerAdditionalSettings/MSFT_SPProjectServerAdditionalSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerAdditionalSettings/MSFT_SPProjectServerAdditionalSettings.psm1 index 15cf19ab3..19ad5ff94 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerAdditionalSettings/MSFT_SPProjectServerAdditionalSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerAdditionalSettings/MSFT_SPProjectServerAdditionalSettings.psm1 @@ -184,13 +184,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @( - "ProjectProfessionalMinBuildNumber" - "ServerCurrency", - "EnforceServerCurrency" - ) + "ProjectProfessionalMinBuildNumber" + "ServerCurrency", + "EnforceServerCurrency" + ) + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerGlobalPermissions/MSFT_SPProjectServerGlobalPermissions.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerGlobalPermissions/MSFT_SPProjectServerGlobalPermissions.psm1 index 31f5124b3..becc91d4b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerGlobalPermissions/MSFT_SPProjectServerGlobalPermissions.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerGlobalPermissions/MSFT_SPProjectServerGlobalPermissions.psm1 @@ -353,12 +353,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @( - "AllowPermissions", - "DenyPermissions" - ) + "AllowPermissions", + "DenyPermissions" + ) + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 index 897d69ffb..7ae63a894 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerGroup/MSFT_SPProjectServerGroup.psm1 @@ -405,10 +405,13 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey("Members") -eq $true) { $membersMatch = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Members") + if ($membersMatch -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -425,7 +428,11 @@ function Test-TargetResource } if ($missingMembers -eq $true) { - Write-Verbose -Message "Users from the MembersToInclude property are not included, returning false" + $message = "Users from the MembersToInclude property are not included" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -442,19 +449,28 @@ function Test-TargetResource } if ($extraMembers -eq $true) { - Write-Verbose -Message "Users from the MembersToExclude property are included, returning false" + $message = "Users from the MembersToExclude property are included" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @( - "Name", - "Description", - "ADGroup", - "Ensure" - ) + "Name", + "Description", + "ADGroup", + "Ensure" + ) + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerLicense/MSFT_SPProjectServerLicense.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerLicense/MSFT_SPProjectServerLicense.psm1 index 9c5796009..1a8f3f412 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerLicense/MSFT_SPProjectServerLicense.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerLicense/MSFT_SPProjectServerLicense.psm1 @@ -200,9 +200,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerPermissionMode/MSFT_SPProjectServerPermissionMode.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerPermissionMode/MSFT_SPProjectServerPermissionMode.psm1 index c204ea569..e7e0c9f77 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerPermissionMode/MSFT_SPProjectServerPermissionMode.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerPermissionMode/MSFT_SPProjectServerPermissionMode.psm1 @@ -117,10 +117,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("PermissionMode") + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 index 26aa9c27b..86798950f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerServiceApp/MSFT_SPProjectServerServiceApp.psm1 @@ -239,17 +239,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerTimeSheetSettings/MSFT_SPProjectServerTimeSheetSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerTimeSheetSettings/MSFT_SPProjectServerTimeSheetSettings.psm1 index 3c37e3239..8bb8ed266 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerTimeSheetSettings/MSFT_SPProjectServerTimeSheetSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerTimeSheetSettings/MSFT_SPProjectServerTimeSheetSettings.psm1 @@ -624,8 +624,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerUserSyncSettings/MSFT_SPProjectServerUserSyncSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerUserSyncSettings/MSFT_SPProjectServerUserSyncSettings.psm1 index 218ba7526..36582be58 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerUserSyncSettings/MSFT_SPProjectServerUserSyncSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerUserSyncSettings/MSFT_SPProjectServerUserSyncSettings.psm1 @@ -185,8 +185,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPProjectServerWssSettings/MSFT_SPProjectServerWssSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPProjectServerWssSettings/MSFT_SPProjectServerWssSettings.psm1 index d9474d1c1..9a40a8ce6 100644 --- a/SharePointDsc/DSCResources/MSFT_SPProjectServerWssSettings/MSFT_SPProjectServerWssSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPProjectServerWssSettings/MSFT_SPProjectServerWssSettings.psm1 @@ -172,8 +172,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 b/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 index 00e144a4f..4850e1472 100644 --- a/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPPublishServiceApplication/MSFT_SPPublishServiceApplication.psm1 @@ -146,9 +146,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPQuotaTemplate/MSFT_SPQuotaTemplate.psm1 b/SharePointDsc/DSCResources/MSFT_SPQuotaTemplate/MSFT_SPQuotaTemplate.psm1 index 7e23440f9..25a12d3ba 100644 --- a/SharePointDsc/DSCResources/MSFT_SPQuotaTemplate/MSFT_SPQuotaTemplate.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPQuotaTemplate/MSFT_SPQuotaTemplate.psm1 @@ -330,9 +330,18 @@ function Test-TargetResource { if ($CurrentValues.Ensure -eq "Absent") { - return $false + $message = "Ensure {$($CurrentValues.Ensure)} does not match the desired state {$Ensure}" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + $result = $false + } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters } - return Test-SPDscParameterState -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters } "Absent" { @@ -349,15 +358,23 @@ function Test-TargetResource if ($CurrentValues.Ensure -eq "Present") { # Error occured in Get method or template exists, which is not supposed to be. Return false - return $false + $message = "Ensure {$($CurrentValues.Ensure)} does not match the desired state {$Ensure}" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + $result = $false } else { # Template does not exists, which is supposed to be. Return true - return $true + $result = $true } } } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPRemoteFarmTrust/MSFT_SPRemoteFarmTrust.psm1 b/SharePointDsc/DSCResources/MSFT_SPRemoteFarmTrust/MSFT_SPRemoteFarmTrust.psm1 index 407f531d2..268761e3d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPRemoteFarmTrust/MSFT_SPRemoteFarmTrust.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPRemoteFarmTrust/MSFT_SPRemoteFarmTrust.psm1 @@ -219,9 +219,14 @@ function Test-TargetResource() Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 index fb0256d0c..8c11fba5c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchAuthoritativePage/MSFT_SPSearchAuthoritativePage.psm1 @@ -283,32 +283,39 @@ function Test-TargetResource { if ($Action -eq "Authoratative") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", - "Path", - "Level", - "Action", - "Ensure") + "Path", + "Level", + "Action", + "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", - "Path", - "Action", - "Ensure") + "Path", + "Action", + "Ensure") } } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", - "Action", - "Ensure") + "Action", + "Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 index e6134201e..2afe1be74 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchContentSource/MSFT_SPSearchContentSource.psm1 @@ -318,10 +318,10 @@ function Set-TargetResource $CrawlSetting -ne "CrawlEverything" -and # Phaseout Major Release $CrawlSetting -ne "CrawlFirstOnly" -and # Phaseout Major Release $CrawlSetting -ne $null # Phaseout Major Release - ) + ) { throw ("Parameter CrawlSetting can only be set to CrawlVirtualServers or CrawlSites " + ` - "for SharePoint content sources") + "for SharePoint content sources") } } "Website" @@ -820,10 +820,10 @@ function Test-TargetResource $CrawlSetting -ne "CrawlEverything" -and # Phaseout Major Release $CrawlSetting -ne "CrawlFirstOnly" -and # Phaseout Major Release $CrawlSetting -ne $null # Phaseout Major Release - ) + ) { throw ("Parameter CrawlSetting can only be set to CrawlVirtualServers or CrawlSites " + ` - "for SharePoint content sources") + "for SharePoint content sources") } } "Website" @@ -876,9 +876,14 @@ function Test-TargetResource if ($Ensure -eq "Absent" -or $CurrentValues.Ensure -eq "Absent") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } $relativePath = "..\..\Modules\SharePointDsc.Search\SPSearchContentSource.Schedules.psm1" @@ -890,9 +895,14 @@ function Test-TargetResource if (($PSBoundParameters.ContainsKey("IncrementalSchedule") -eq $true) -and ($null -ne $IncrementalSchedule)) { $propertyTest = Test-SPDscSearchCrawlSchedule -CurrentSchedule $CurrentValues.IncrementalSchedule ` - -DesiredSchedule $IncrementalSchedule + -DesiredSchedule $IncrementalSchedule if ($propertyTest -eq $false) { + $message = ("Specified IncrementalSchedule does not match desired state.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -900,9 +910,14 @@ function Test-TargetResource if (($PSBoundParameters.ContainsKey("FullSchedule") -eq $true) -and ($null -ne $FullSchedule)) { $propertyTest = Test-SPDscSearchCrawlSchedule -CurrentSchedule $CurrentValues.FullSchedule ` - -DesiredSchedule $FullSchedule + -DesiredSchedule $FullSchedule if ($propertyTest -eq $false) { + $message = ("Specified FullSchedule does not match desired state.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -922,19 +937,33 @@ function Test-TargetResource if ($null -ne (Compare-Object -ReferenceObject $currentAddresses ` -DifferenceObject $desiredAddresses)) { + $message = ("Specified addresses do not match desired state: " + ` + "Actual: $($currentAddresses -join ", ") Desired: " + ` + "$($desiredAddresses -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("ContentSourceType", + "CrawlSetting", + "ContinuousCrawl", + "Priority", + "LimitPageDepth", + "LimitServerHops", + "LOBSystemSet", + "Ensure") + } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("ContentSourceType", - "CrawlSetting", - "ContinuousCrawl", - "Priority", - "LimitPageDepth", - "LimitServerHops", - "LOBSystemSet", - "Ensure") + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlMapping/MSFT_SPSearchCrawlMapping.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlMapping/MSFT_SPSearchCrawlMapping.psm1 index b819b7ec4..d4a3511f0 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlMapping/MSFT_SPSearchCrawlMapping.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlMapping/MSFT_SPSearchCrawlMapping.psm1 @@ -219,16 +219,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", "Url", "Target", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 index dc947f26d..20ec8e818 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlRule/MSFT_SPSearchCrawlRule.psm1 @@ -534,11 +534,21 @@ function Test-TargetResource -DifferenceObject $CurrentValues.CrawlConfigurationRules if ($null -ne $compareObject) { + $message = ("Specified CrawlConfigurationRules does not match the actual value." + ` + "Actual: $($CurrentValues.CrawlConfigurationRules -join ", ") Desired: " + ` + "$($CrawlConfigurationRules -join ", ")") + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } else { + $message = "No CrawlConfigurationRules are currently configured" + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -547,23 +557,35 @@ function Test-TargetResource { if ($AuthenticationCredentials.UserName -ne $CurrentValues.AuthenticationCredentials) { + $message = ("Specified AuthenticationCredentials does not match the actual value." + ` + "Actual: $($CurrentValues.AuthenticationCredentials) Desired: " + ` + "$($AuthenticationCredentials.UserName)") + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "AuthenticationType", - "RuleType", - "CertificateName") + "AuthenticationType", + "RuleType", + "CertificateName") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlerImpactRule/MSFT_SPSearchCrawlerImpactRule.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlerImpactRule/MSFT_SPSearchCrawlerImpactRule.psm1 index dbc13c78a..6c5436754 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchCrawlerImpactRule/MSFT_SPSearchCrawlerImpactRule.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchCrawlerImpactRule/MSFT_SPSearchCrawlerImpactRule.psm1 @@ -286,7 +286,8 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", "Name", @@ -294,12 +295,17 @@ function Test-TargetResource } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAppName", "Name", "Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 index 7d3b69411..425073b3c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchFileType/MSFT_SPSearchFileType.psm1 @@ -329,22 +329,34 @@ function Test-TargetResource { if ($Enabled -ne $CurrentValues.Enabled) { + $message = ("Specified Enabled does not match the actual value." + ` + "Actual: $($CurrentValues.Enabled) Desired: " + ` + "$($Enabled)") + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "Description", - "MimeType") + "Description", + "MimeType") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 index 5060ca28a..1fe50a5a4 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1 @@ -271,9 +271,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Servers") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchManagedProperty/MSFT_SPSearchManagedProperty.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchManagedProperty/MSFT_SPSearchManagedProperty.psm1 index 61340078b..11449abf2 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchManagedProperty/MSFT_SPSearchManagedProperty.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchManagedProperty/MSFT_SPSearchManagedProperty.psm1 @@ -447,21 +447,26 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", - "PropertyType", - "Ensure", - "HasMultipleValues", - "Retrievable", - "Searchable", - "Refinable", - "Searchable", - "NoWordBreaker", - "IncludeAllCrawledProperties", - "Aliases", - "Sortable", - "SafeForAnonymous") + "PropertyType", + "Ensure", + "HasMultipleValues", + "Retrievable", + "Searchable", + "Refinable", + "Searchable", + "NoWordBreaker", + "IncludeAllCrawledProperties", + "Aliases", + "Sortable", + "SafeForAnonymous") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchMetadataCategory/MSFT_SPSearchMetadataCategory.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchMetadataCategory/MSFT_SPSearchMetadataCategory.psm1 index d765c15fb..11df30fc5 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchMetadataCategory/MSFT_SPSearchMetadataCategory.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchMetadataCategory/MSFT_SPSearchMetadataCategory.psm1 @@ -209,14 +209,19 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", - "PropertyType", - "Ensure", - "AutoCreateNewManagedProperties", - "DiscoverNewProperties", - "MapToContents") + "PropertyType", + "Ensure", + "AutoCreateNewManagedProperties", + "DiscoverNewProperties", + "MapToContents") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 index faa8a0fc2..fd3775bef 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchResultSource/MSFT_SPSearchResultSource.psm1 @@ -318,9 +318,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 index fc83f3ede..b6b89bc3e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchServiceApp/MSFT_SPSearchServiceApp.psm1 @@ -535,7 +535,11 @@ function Test-TargetResource if ($desired -ne $current) { - Write-Verbose -Message "Default content access account is different, returning false" + $message = ("Specified Default content access account is not in the desired state" + ` + "Actual: $current Desired: $desired") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + Write-Verbose -Message "Desired: $desired. Current: $current." return $false } @@ -543,20 +547,26 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "ApplicationPool", - "SearchCenterUrl", - "ProxyName", - "AlertsEnabled") + "ApplicationPool", + "SearchCenterUrl", + "ProxyName", + "AlertsEnabled") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchServiceSettings/MSFT_SPSearchServiceSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchServiceSettings/MSFT_SPSearchServiceSettings.psm1 index e6b35aef6..539cc0856 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchServiceSettings/MSFT_SPSearchServiceSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchServiceSettings/MSFT_SPSearchServiceSettings.psm1 @@ -214,7 +214,7 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey("PerformanceLevel") -eq $false -and $PSBoundParameters.ContainsKey("ContactEmail") -eq $false -and ` - $PSBoundParameters.ContainsKey("WindowsServiceAccount") -eq $false) + $PSBoundParameters.ContainsKey("WindowsServiceAccount") -eq $false) { Write-Verbose -Message ("You have to specify at least one of the following parameters: " + ` "PerformanceLevel, ContactEmail or WindowsServiceAccount") @@ -233,16 +233,25 @@ function Test-TargetResource if ($desired -ne $current) { - Write-Verbose -Message "Windows service account is different, returning false" + $message = ("Specified Windows service account is not in the desired state" + ` + "Actual: $current Desired: $desired") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + Write-Verbose -Message "Desired: $desired. Current: $current." return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("PerformanceLevel", "ContactEmail") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSearchTopology/MSFT_SPSearchTopology.psm1 b/SharePointDsc/DSCResources/MSFT_SPSearchTopology/MSFT_SPSearchTopology.psm1 index 13a17c845..4e4c5cddf 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSearchTopology/MSFT_SPSearchTopology.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSearchTopology/MSFT_SPSearchTopology.psm1 @@ -534,16 +534,21 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @( - "Admin", - "Crawler", - "ContentProcessing", - "AnalyticsProcessing", - "QueryProcessing", - "IndexPartition" - ) + "Admin", + "Crawler", + "ContentProcessing", + "AnalyticsProcessing", + "QueryProcessing", + "IndexPartition" + ) + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 index 386002846..90e34bf4b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSecureStoreServiceApp/MSFT_SPSecureStoreServiceApp.psm1 @@ -401,9 +401,13 @@ function Test-TargetResource ($null -ne $CurrentValues.DatabaseServer) -and ` ($CurrentValues.DatabaseServer -ne $DatabaseServer)) { - Write-Verbose -Message ("Specified database server does not match the actual " + ` - "database server. This resource cannot move the database " + ` - "to a different SQL instance.") + $message = ("Specified database server {$DatabaseServer} does not match the actual " + ` + "database server {$($CurrentValues.DatabaseServer)}. This resource " + ` + "cannot move the database to a different SQL instance.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -411,14 +415,24 @@ function Test-TargetResource ($null -ne $CurrentValues.DatabaseName) -and ` ($CurrentValues.DatabaseName -ne $DatabaseName)) { - Write-Verbose -Message ("Specified database name does not match the actual " + ` - "database name. This resource cannot rename the database.") + $message = ("Specified database name {$DatabaseName} does not match the " + ` + "actual database name {$($($CurrentValues.DatabaseName))}. This " + ` + "resource cannot rename the database.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSecurityTokenServiceConfig/MSFT_SPSecurityTokenServiceConfig.psm1 b/SharePointDsc/DSCResources/MSFT_SPSecurityTokenServiceConfig/MSFT_SPSecurityTokenServiceConfig.psm1 index b72cbc404..d509c8ec0 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSecurityTokenServiceConfig/MSFT_SPSecurityTokenServiceConfig.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSecurityTokenServiceConfig/MSFT_SPSecurityTokenServiceConfig.psm1 @@ -210,13 +210,18 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", - "NameIdentifier", - "UseSessionCookies", - "AllowOAuthOverHttp", - "AllowMetadataOverHttp") + "NameIdentifier", + "UseSessionCookies", + "AllowOAuthOverHttp", + "AllowMetadataOverHttp") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSelfServiceSiteCreation/MSFT_SPSelfServiceSiteCreation.psm1 b/SharePointDsc/DSCResources/MSFT_SPSelfServiceSiteCreation/MSFT_SPSelfServiceSiteCreation.psm1 index 6a4538256..28d5c9504 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSelfServiceSiteCreation/MSFT_SPSelfServiceSiteCreation.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSelfServiceSiteCreation/MSFT_SPSelfServiceSiteCreation.psm1 @@ -519,7 +519,8 @@ function Test-TargetResource if ($Enabled) { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("WebAppUrl", ` "Enabled", ` @@ -536,10 +537,15 @@ function Test-TargetResource } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("WebAppUrl", ` "Enabled", ` "ShowStartASiteMenuItem") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceAppPool/MSFT_SPServiceAppPool.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceAppPool/MSFT_SPServiceAppPool.psm1 index 8f53a675e..84dfab59e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceAppPool/MSFT_SPServiceAppPool.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceAppPool/MSFT_SPServiceAppPool.psm1 @@ -169,16 +169,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ServiceAccount", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 index 3deec421b..6969f342f 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceAppProxyGroup/MSFT_SPServiceAppProxyGroup.psm1 @@ -391,6 +391,11 @@ function Test-TargetResource if ($CurrentValues.Ensure -ne $Ensure) { + $message = "Ensure {$($CurrentValues.Ensure)} does not match the desired value {$Ensure}" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -400,6 +405,11 @@ function Test-TargetResource if (-not $CurrentValues.ServiceAppProxies) { + $message = "Proxy Group $Name does not contain any proxies" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -412,7 +422,13 @@ function Test-TargetResource } else { - Write-Verbose -Message "ServiceAppProxies do not match" + $message = ("Proxies in proxy Group $Name does not match. Actual: " + ` + "$($CurrentValues.$ServiceAppProxies -join ", "). Desired: " + ` + "$($ServiceAppProxies -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -423,6 +439,11 @@ function Test-TargetResource if (-not $CurrentValues.ServiceAppProxies) { + $message = "Proxy Group $Name does not contain any proxies" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -435,7 +456,13 @@ function Test-TargetResource } elseif ($differences.sideindicator -contains "=>") { - Write-Verbose -Message "ServiceAppProxiesToInclude does not match" + $message = ("Included proxies in proxy Group $Name does not match. Actual: " + ` + "$($CurrentValues.ServiceAppProxies -join ", "). Desired: " + ` + "$($ServiceAppProxiesToInclude -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -446,6 +473,7 @@ function Test-TargetResource if (-not $CurrentValues.ServiceAppProxies) { + Write-Verbose -Message "Test-TargetResource returned true" return $true } @@ -455,14 +483,22 @@ function Test-TargetResource if ($null -eq $differences) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } elseif ($differences.sideindicator -contains "==") { - Write-Verbose -Message "ServiceAppProxiesToExclude does not match" + $message = ("Excluded proxies in proxy Group $Name does not match. Actual: " + ` + "$($CurrentValues.ServiceAppProxies -join ", "). Desired: " + ` + "$($ServiceAppProxiesToExclude -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } + Write-Verbose -Message "Test-TargetResource returned true" return $true } diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 index 937d72cd8..ca038f890 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceAppSecurity/MSFT_SPServiceAppSecurity.psm1 @@ -532,15 +532,21 @@ function Test-TargetResource if ([System.String]::IsNullOrEmpty($CurrentValues.ServiceAppName) -eq $true) { + $message = "ServiceAppName is currently not configured in the environment." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } $result = Invoke-SPDscCommand -Credential $InstallAccount ` - -Arguments @($PSBoundParameters, $CurrentValues, $PSScriptRoot) ` + -Arguments @($PSBoundParameters, $CurrentValues, $PSScriptRoot, $MyInvocation.MyCommand.Source) ` -ScriptBlock { $params = $args[0] $CurrentValues = $args[1] $ScriptRoot = $args[2] + $Source = $args[3] $relPath = "..\..\Modules\SharePointDsc.ServiceAppSecurity\SPServiceAppSecurity.psm1" Import-Module (Join-Path -Path $ScriptRoot -ChildPath $relPath -Resolve) @@ -566,7 +572,11 @@ function Test-TargetResource { if ($params.Members.Count -gt 0) { - Write-Verbose -Message "Security list does not match" + $message = ("Security list does not match. Actual: $($CurrentValues.Members.Username -join ", "). " + ` + "Desired: $($params.Members.Username -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } else @@ -577,7 +587,11 @@ function Test-TargetResource } elseif ($params.Members.Count -eq 0) { - Write-Verbose -Message "Security list does not match" + $message = ("Security list does not match. Actual: $($CurrentValues.Members.Username -join ", "). " + ` + "Desired: $($params.Members.Username -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } @@ -594,7 +608,10 @@ function Test-TargetResource } | Select-Object -First 1).AccessLevels if ($null -ne (Compare-Object -DifferenceObject $currentMember.AccessLevels -ReferenceObject $expandedAccessLevels)) { - Write-Verbose -Message "$($currentMember.Username) has incorrect permission level. Test failed." + $message = "$($currentMember.Username) has incorrect permission level. Test failed." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } @@ -602,7 +619,11 @@ function Test-TargetResource } else { - Write-Verbose -Message "Security list does not match" + $message = ("Security list does not match. Actual: $($CurrentValues.Members.Username -join ", "). " + ` + "Desired: $($params.Members.Username -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } @@ -615,7 +636,10 @@ function Test-TargetResource { if (-not($CurrentValues.Members.Username -contains $member.Username)) { - Write-Verbose -Message "$($member.Username) does not have access. Set result to false" + $message = "$($member.Username) does not have access. Test failed." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + $result = $false } else @@ -628,7 +652,10 @@ function Test-TargetResource } | Select-Object -First 1).AccessLevels if ($null -ne $compare) { - Write-Verbose -Message "$($member.Username) has incorrect permission level. Test failed." + $message = "$($member.Username) has incorrect permission level. Test failed." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } @@ -642,7 +669,10 @@ function Test-TargetResource { if ($CurrentValues.Members.Username -contains $member) { - Write-Verbose -Message "$member already has access. Set result to false" + $message = "$member already has access. Set result to false" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + $result = $false } else @@ -655,6 +685,8 @@ function Test-TargetResource return $result } + Write-Verbose -Message "Test-TargetResource returned $result" + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.psm1 index cb7c071c6..669ce8401 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.psm1 @@ -165,5 +165,17 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return ($CurrentValues.ManagedAccount -eq $ManagedAccount) + $result = ($CurrentValues.ManagedAccount -eq $ManagedAccount) + + if ($result -eq $false) + { + $message = ("Specfied ManagedAccount {$($CurrentValues.ManagedAccount)} is not in the " + ` + "desired state {$ManagedAccount}.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } diff --git a/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 b/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 index 3fdccaab2..86a1dc7b9 100644 --- a/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPServiceInstance/MSFT_SPServiceInstance.psm1 @@ -198,9 +198,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Get-SPDscServiceTypeName diff --git a/SharePointDsc/DSCResources/MSFT_SPSessionStateService/MSFT_SPSessionStateService.psm1 b/SharePointDsc/DSCResources/MSFT_SPSessionStateService/MSFT_SPSessionStateService.psm1 index ee2951f07..e3037a75b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSessionStateService/MSFT_SPSessionStateService.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSessionStateService/MSFT_SPSessionStateService.psm1 @@ -169,16 +169,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "SessionTimeout") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 b/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 index 2f788b2f0..054201883 100644 --- a/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPShellAdmins/MSFT_SPShellAdmins.psm1 @@ -778,6 +778,11 @@ function Test-TargetResource $null -eq $CurrentValues.MembersToInclude -and ` $null -eq $CurrentValues.MembersToExclude) { + $message = "Members, MembersToInclude or MembersToExclude not specified." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -786,6 +791,11 @@ function Test-TargetResource Write-Verbose -Message "Processing Members parameter" if (-not $CurrentValues.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -798,7 +808,12 @@ function Test-TargetResource } else { - Write-Verbose -Message "Shell Admins group does not match" + $message = ("Shell Admins group does not match. Actual: $($CurrentValues.Members -join ", "). " + ` + "Desired: $($Members -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -808,6 +823,11 @@ function Test-TargetResource Write-Verbose -Message "Processing MembersToInclude parameter" if (-not $CurrentValues.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -815,7 +835,11 @@ function Test-TargetResource { if (-not($CurrentValues.Members.Contains($member))) { - Write-Verbose -Message "$member is not a Shell Admin. Set result to false" + $message = "$member is not a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -834,7 +858,11 @@ function Test-TargetResource { if ($CurrentValues.Members.Contains($member)) { - Write-Verbose -Message "$member is a Shell Admin. Set result to false" + $message = "$member is a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -860,6 +888,11 @@ function Test-TargetResource { if (-not $database.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -872,7 +905,12 @@ function Test-TargetResource } else { - Write-Verbose -Message "Shell Admins group does not match" + $message = ("Shell Admins group does not match. Actual: $($database.Members -join ", "). " + ` + "Desired: $($Members -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -881,6 +919,11 @@ function Test-TargetResource { if (-not $database.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -888,7 +931,11 @@ function Test-TargetResource { if (-not($database.Members.Contains($member))) { - Write-Verbose -Message "$member is not a Shell Admin. Set result to false" + $message = "$member is not a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -906,7 +953,11 @@ function Test-TargetResource { if ($database.Members.Contains($member)) { - Write-Verbose -Message "$member is a Shell Admin. Set result to false" + $message = "$member is a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -941,6 +992,11 @@ function Test-TargetResource Write-Verbose -Message "Processing Members parameter" if (-not $currentCDB.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -953,7 +1009,12 @@ function Test-TargetResource } else { - Write-Verbose -Message "Shell Admins group does not match" + $message = ("Shell Admins group does not match. Actual: $($currentCDB.Members -join ", "). " + ` + "Desired: $($database.Members -join ", ")") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -963,6 +1024,11 @@ function Test-TargetResource Write-Verbose -Message "Processing MembersToInclude parameter" if (-not $currentCDB.Members) { + $message = "No members currently configured." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -970,7 +1036,11 @@ function Test-TargetResource { if (-not($currentCDB.Members.Contains($member))) { - Write-Verbose -Message "$member is not a Shell Admin. Set result to false" + $message = "$member is not a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -989,7 +1059,11 @@ function Test-TargetResource { if ($currentCDB.Members.Contains($member)) { - Write-Verbose -Message "$member is a Shell Admin. Set result to false" + $message = "$member is a Shell Admin." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -1007,6 +1081,7 @@ function Test-TargetResource } } + Write-Verbose -Message "Test-TargetResource returned true" return $true } diff --git a/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 b/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 index 7c306b3d8..d32f8c418 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSite/MSFT_SPSite.psm1 @@ -488,17 +488,27 @@ function Test-TargetResource { if ($CurrentValues.CreateDefaultGroups -ne $true) { + $message = "The default site groups are not configured as desired." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Url", - "QuotaTemplate", - "OwnerAlias", - "SecondaryOwnerAlias", - "AdministrationSiteType") + "QuotaTemplate", + "OwnerAlias", + "SecondaryOwnerAlias", + "AdministrationSiteType") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSitePropertyBag/MSFT_SPSitePropertyBag.psm1 b/SharePointDsc/DSCResources/MSFT_SPSitePropertyBag/MSFT_SPSitePropertyBag.psm1 index 83aae3ca2..4c7433754 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSitePropertyBag/MSFT_SPSitePropertyBag.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSitePropertyBag/MSFT_SPSitePropertyBag.psm1 @@ -170,18 +170,23 @@ function Test-TargetResource() if ($Ensure -eq 'Present') { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @('Ensure', 'Key', 'Value') } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @('Ensure', 'Key') } + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSiteUrl/MSFT_SPSiteUrl.psm1 b/SharePointDsc/DSCResources/MSFT_SPSiteUrl/MSFT_SPSiteUrl.psm1 index 83fcf0af9..df686f4a7 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSiteUrl/MSFT_SPSiteUrl.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSiteUrl/MSFT_SPSiteUrl.psm1 @@ -320,29 +320,55 @@ function Test-TargetResource $null -eq $CurrentValues.Extranet -and $null -eq $CurrentValues.Custom) { + $message = "All zones do not have a SiteUrl configured" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } if ([String]$CurrentValues.Intranet -ne $Intranet) { + $message = "The Intranet zone {$($CurrentValues.Intranet)} is not configured as desired $Intranet" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } if ([String]$CurrentValues.Internet -ne $Internet) { + $message = "The Internet zone {$($CurrentValues.Internet)} is not configured as desired $Internet" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } if ([String]$CurrentValues.Extranet -ne $Extranet) { + $message = "The Extranet zone {$($CurrentValues.Extranet)} is not configured as desired $Extranet" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } if ([String]$CurrentValues.Custom -ne $Custom) { + $message = "The Custom zone {$($CurrentValues.Custom)} is not configured as desired $Custom" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } + Write-Verbose -Message "Test-TargetResource returned true" return $true } diff --git a/SharePointDsc/DSCResources/MSFT_SPStateServiceApp/MSFT_SPStateServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPStateServiceApp/MSFT_SPStateServiceApp.psm1 index 0f74a8ee2..151a31b3d 100644 --- a/SharePointDsc/DSCResources/MSFT_SPStateServiceApp/MSFT_SPStateServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPStateServiceApp/MSFT_SPStateServiceApp.psm1 @@ -231,9 +231,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 index 94d130df1..c2ea2912e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPSubscriptionSettingsServiceApp/MSFT_SPSubscriptionSettingsServiceApp.psm1 @@ -283,20 +283,31 @@ function Test-TargetResource if ($result -eq $false) { + $message = "The service application is not configured to a proxy" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPTimerJobState/MSFT_SPTimerJobState.psm1 b/SharePointDsc/DSCResources/MSFT_SPTimerJobState/MSFT_SPTimerJobState.psm1 index 58f20337a..cf2b2da3a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPTimerJobState/MSFT_SPTimerJobState.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPTimerJobState/MSFT_SPTimerJobState.psm1 @@ -348,8 +348,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 b/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 index c6c4c2fce..5e51bc14b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuer/MSFT_SPTrustedIdentityTokenIssuer.psm1 @@ -428,7 +428,6 @@ function Test-TargetResource $PSBoundParameters.ContainsKey("SigningCertificateFilePath")) { throw ("Cannot use both parameters SigningCertificateThumbprint and SigningCertificateFilePath at the same time.") - return } if ($PSBoundParameters.ContainsKey("SigningCertificateThumbprint") -eq $false -and ` @@ -436,7 +435,6 @@ function Test-TargetResource { throw ("At least one of the following parameters must be specified: " + ` "SigningCertificateThumbprint, SigningCertificateFilePath.") - return } $CurrentValues = Get-TargetResource @PSBoundParameters @@ -444,9 +442,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 b/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 index 05c15034b..b314898fb 100644 --- a/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPTrustedIdentityTokenIssuerProviderRealms/MSFT_SPTrustedIdentityTokenIssuerProviderRealms.psm1 @@ -226,9 +226,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPTrustedRootAuthority/MSFT_SPTrustedRootAuthority.psm1 b/SharePointDsc/DSCResources/MSFT_SPTrustedRootAuthority/MSFT_SPTrustedRootAuthority.psm1 index 278604d1d..6c69da152 100644 --- a/SharePointDsc/DSCResources/MSFT_SPTrustedRootAuthority/MSFT_SPTrustedRootAuthority.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPTrustedRootAuthority/MSFT_SPTrustedRootAuthority.psm1 @@ -320,16 +320,22 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "CertificateThumbprint", "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPTrustedSecurityTokenIssuer/MSFT_SPTrustedSecurityTokenIssuer.psm1 b/SharePointDsc/DSCResources/MSFT_SPTrustedSecurityTokenIssuer/MSFT_SPTrustedSecurityTokenIssuer.psm1 index 468b4d65d..001a18809 100644 --- a/SharePointDsc/DSCResources/MSFT_SPTrustedSecurityTokenIssuer/MSFT_SPTrustedSecurityTokenIssuer.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPTrustedSecurityTokenIssuer/MSFT_SPTrustedSecurityTokenIssuer.psm1 @@ -480,9 +480,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 b/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 index 955610855..334a0d447 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUsageApplication/MSFT_SPUsageApplication.psm1 @@ -317,20 +317,26 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("UsageLogCutTime", - "UsageLogLocation", - "UsageLogMaxFileSizeKB", - "UsageLogMaxSpaceGB", - "Ensure") + "UsageLogLocation", + "UsageLogMaxFileSizeKB", + "UsageLogMaxSpaceGB", + "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 index e7bdcfbbf..9ea9f0dfe 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileProperty/MSFT_SPUserProfileProperty.psm1 @@ -825,36 +825,42 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", - "DisplayName", - "Type", - "Description", - "PolicySetting", - "PrivacySetting", - "PropertyMappings", - "Length", - "DisplayOrder", - "IsEventLog", - "IsVisibleOnEditor", - "IsVisibleOnViewer", - "IsUserEditable", - "IsAlias", - "IsSearchable", - "IsReplicable", - "UserOverridePrivacy", - "TermGroup", - "TermStore", - "TermSet", - "Ensure") + "DisplayName", + "Type", + "Description", + "PolicySetting", + "PrivacySetting", + "PropertyMappings", + "Length", + "DisplayOrder", + "IsEventLog", + "IsVisibleOnEditor", + "IsVisibleOnViewer", + "IsUserEditable", + "IsAlias", + "IsSearchable", + "IsReplicable", + "UserOverridePrivacy", + "TermGroup", + "TermStore", + "TermSet", + "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 index ba1a18a4e..ddcafab5c 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSection/MSFT_SPUserProfileSection.psm1 @@ -226,19 +226,25 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", - "DisplayName", - "DisplayOrder", - "Ensure") + "DisplayName", + "DisplayOrder", + "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 index f4c3cc651..427c92dea 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceApp/MSFT_SPUserProfileServiceApp.psm1 @@ -682,23 +682,35 @@ function Test-TargetResource if ($UpdateProxyGroup -eq $true -and ` $CurrentValues.UpdateProxyGroup -eq $true) { - return $false - } + $message = "ProxyGroup fix is not implemented" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source - return Test-SPDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck @("Name", - "EnableNetBIOS", - "NoILMUsed", - "SiteNamingConflictResolution", - "Ensure") + $result = $false + } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("Name", + "EnableNetBIOS", + "NoILMUsed", + "SiteNamingConflictResolution", + "Ensure") + } } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Name", "Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceAppPermissions/MSFT_SPUserProfileServiceAppPermissions.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceAppPermissions/MSFT_SPUserProfileServiceAppPermissions.psm1 index 22cceee1b..945e1d122 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceAppPermissions/MSFT_SPUserProfileServiceAppPermissions.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileServiceAppPermissions/MSFT_SPUserProfileServiceAppPermissions.psm1 @@ -341,11 +341,16 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("CreatePersonalSite", ` "FollowAndEditProfile", ` "UseTagsAndNotes") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Confirm-SPDscUpaPermissionsConfig() diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 index bed1da896..541806df9 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncConnection/MSFT_SPUserProfileSyncConnection.psm1 @@ -617,6 +617,7 @@ function Test-TargetResource { if ($Force -eq $true) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -624,9 +625,14 @@ function Test-TargetResource $valuesToCheck += "Server" } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } <# diff --git a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 index 47978e799..4f0eb12ba 100644 --- a/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPUserProfileSyncService/MSFT_SPUserProfileSyncService.psm1 @@ -415,9 +415,14 @@ function Test-TargetResource } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Test-SPDscUserProfileDBReadOnly() diff --git a/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 index 7f60ce20c..472079f01 100644 --- a/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPVisioServiceApp/MSFT_SPVisioServiceApp.psm1 @@ -226,9 +226,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", "Ensure") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 b/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 index c5854c6cb..b74231218 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWeb/MSFT_SPWeb.psm1 @@ -336,9 +336,14 @@ function Test-TargetResource "Ensure") } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 index 6a9586ffe..bd69e2a99 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppAuthentication/MSFT_SPWebAppAuthentication.psm1 @@ -501,16 +501,19 @@ function Test-TargetResource $null -eq $CurrentValues.Extranet -and ` $null -eq $CurrentValues.Custom) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } if ($PSBoundParameters.ContainsKey("Default")) { $result = Test-ZoneConfiguration -DesiredConfig $Default ` - -CurrentConfig $CurrentValues.Default + -CurrentConfig $CurrentValues.Default ` + -ZoneName "Default" if ($result -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -523,10 +526,12 @@ function Test-TargetResource } $result = Test-ZoneConfiguration -DesiredConfig $Intranet ` - -CurrentConfig $CurrentValues.Intranet + -CurrentConfig $CurrentValues.Intranet ` + -ZoneName "Intranet" if ($result -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -539,10 +544,12 @@ function Test-TargetResource } $result = Test-ZoneConfiguration -DesiredConfig $Internet ` - -CurrentConfig $CurrentValues.Internet + -CurrentConfig $CurrentValues.Internet ` + -ZoneName "Internet" if ($result -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -555,10 +562,12 @@ function Test-TargetResource } $result = Test-ZoneConfiguration -DesiredConfig $Extranet ` - -CurrentConfig $CurrentValues.Extranet + -CurrentConfig $CurrentValues.Extranet ` + -ZoneName "Extranet" if ($result -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -567,18 +576,22 @@ function Test-TargetResource { if ($CurrentValues.ContainsKey("Custom") -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" throw "Specified zone Custom does not exist" } $result = Test-ZoneConfiguration -DesiredConfig $Custom ` - -CurrentConfig $CurrentValues.Custom + -CurrentConfig $CurrentValues.Custom ` + -ZoneName "Custom" if ($result -eq $false) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } } + Write-Verbose -Message "Test-TargetResource returned true" return $true } @@ -848,7 +861,11 @@ function Test-ZoneConfiguration() [Parameter(Mandatory = $true)] [System.Collections.Hashtable[]] - $CurrentConfig + $CurrentConfig, + + [Parameter()] + [System.String] + $ZoneName ) # Testing specified configuration against configured values @@ -884,6 +901,48 @@ function Test-ZoneConfiguration() if ($null -eq $configuredMethod) { + if ($PSBoundParameters.ContainsKey('ZoneName') -eq $true) + { + $source = $MyInvocation.MyCommand.Source + + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + foreach ($item in $CurrentConfig) + { + $EventMessage += " `r`n" + foreach ($key in $item.Keys) + { + if (-not ([String]::IsNullOrEmpty($item.$key))) + { + $EventMessage += " " + $item.$key + "`r`n" + } + } + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $ZoneName`r`n" + foreach ($desired in $DesiredConfig) + { + $EventMessage += " `r`n" + foreach ($prop in $desired.CimInstanceProperties) + { + $EventMessage += " " + $prop.Value + "`r`n" + + } + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + } + return $false } } @@ -921,6 +980,48 @@ function Test-ZoneConfiguration() if ($null -eq $specifiedMethod) { + if ($PSBoundParameters.ContainsKey('ZoneName') -eq $true) + { + $source = $MyInvocation.MyCommand.Source + + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + foreach ($item in $CurrentConfig) + { + $EventMessage += " `r`n" + foreach ($key in $item.Keys) + { + if (-not ([String]::IsNullOrEmpty($item.$key))) + { + $EventMessage += " " + $item.$key + "`r`n" + } + } + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $ZoneName`r`n" + foreach ($desired in $DesiredConfig) + { + $EventMessage += " `r`n" + foreach ($prop in $desired.CimInstanceProperties) + { + $EventMessage += " " + $prop.Value + "`r`n" + + } + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + } + return $false } } diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppBlockedFileTypes/MSFT_SPWebAppBlockedFileTypes.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppBlockedFileTypes/MSFT_SPWebAppBlockedFileTypes.psm1 index f8201508e..dc0ab4fcf 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppBlockedFileTypes/MSFT_SPWebAppBlockedFileTypes.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppBlockedFileTypes/MSFT_SPWebAppBlockedFileTypes.psm1 @@ -147,8 +147,13 @@ function Test-TargetResource $modulePath = "..\..\Modules\SharePointDsc.WebApplication\SPWebApplication.BlockedFileTypes.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $modulePath -Resolve) - return Test-SPDscWebApplicationBlockedFileTypeConfig -CurrentSettings $CurrentValues ` + $result = Test-SPDscWebApplicationBlockedFileTypeConfig -CurrentSettings $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredSettings $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 index 3ae2b3b64..cd33eca64 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppClientCallableSettings/MSFT_SPWebAppClientCallableSettings.psm1 @@ -476,6 +476,7 @@ function Test-TargetResource if ($null -eq $CurrentValues.ProxyLibraries) { Write-Verbose -Message "Proxy library list does not have a valid value" + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -488,6 +489,7 @@ function Test-TargetResource if ($ProxyLibraries.Count -gt 0) { Write-Verbose -Message "Proxy library list does not match" + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -496,6 +498,7 @@ function Test-TargetResource if ($ProxyLibraries.Count -eq 0) { Write-Verbose -Message "Proxy library list does not match" + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -512,7 +515,8 @@ function Test-TargetResource } | Select-Object -First 1).SupportAppAuthentication if ($currentProxyLibrary.SupportAppAuthentication -ne $supportAppAuth) { - Write-Verbose -Message "$($currentProxyLibrary.AssemblyName) has incorrect SupportAppAuthentication. Test failed." + Write-Verbose -Message "$($currentProxyLibrary.AssemblyName) has incorrect SupportAppAuthentication." + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -520,6 +524,7 @@ function Test-TargetResource else { Write-Verbose -Message "Proxy library list does not match" + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -534,6 +539,7 @@ function Test-TargetResource if ($ProxyLibrariesToInclude.Count -gt 0) { Write-Verbose -Message "Proxy library list to include does not match" + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -543,7 +549,8 @@ function Test-TargetResource { if (-not($CurrentValues.ProxyLibraries.AssemblyName -contains $proxyLibrary.AssemblyName)) { - Write-Verbose -Message "$($proxyLibrary.AssemblyName) is not registered as a proxy library. Set result to false" + Write-Verbose -Message "$($proxyLibrary.AssemblyName) is not registered as a proxy library." + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -554,7 +561,8 @@ function Test-TargetResource } | Select-Object -First 1).SupportAppAuthentication if ($proxyLibrary.SupportAppAuthentication -ne $supportAppAuth) { - Write-Verbose -Message "$($proxyLibrary.AssemblyName) has incorrect SupportAppAuthentication. Test failed." + Write-Verbose -Message "$($proxyLibrary.AssemblyName) has incorrect SupportAppAuthentication." + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -571,7 +579,8 @@ function Test-TargetResource { if ($CurrentValues.ProxyLibraries.AssemblyName -contains $proxyLibrary) { - Write-Verbose -Message "$proxyLibrary is already registered as proxy library. Set result to false" + Write-Verbose -Message "$proxyLibrary is already registered as proxy library." + Write-Verbose -Message "Test-TargetResource returned false" return $false } else @@ -582,18 +591,23 @@ function Test-TargetResource } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("WebAppUrl", - "MaxResourcesPerRequest", - "MaxObjectPaths", - "ExecutionTimeout", - "RequestXmlMaxDepth", - "EnableXsdValidation", - "EnableStackTrace", - "RequestUsageExecutionTimeThreshold", - "LogActionsIfHasRequestException", - "EnableRequestUsage") + "MaxResourcesPerRequest", + "MaxObjectPaths", + "ExecutionTimeout", + "RequestXmlMaxDepth", + "EnableXsdValidation", + "EnableStackTrace", + "RequestUsageExecutionTimeThreshold", + "LogActionsIfHasRequestException", + "EnableRequestUsage") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppGeneralSettings/MSFT_SPWebAppGeneralSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppGeneralSettings/MSFT_SPWebAppGeneralSettings.psm1 index dc2d0f3fc..2e8feb521 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppGeneralSettings/MSFT_SPWebAppGeneralSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppGeneralSettings/MSFT_SPWebAppGeneralSettings.psm1 @@ -380,7 +380,12 @@ function Test-TargetResource $modulePath = "..\..\Modules\SharePointDsc.WebApplication\SPWebApplication.GeneralSettings.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $modulePath -Resolve) - return Test-SPDscWebApplicationGeneralConfig -CurrentSettings $CurrentValues -DesiredSettings $PSBoundParameters + $result = Test-SPDscWebApplicationGeneralConfig -CurrentSettings $CurrentValues ` + -DesiredSettings $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 index 2305b6b10..08b43000b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppPeoplePickerSettings/MSFT_SPWebAppPeoplePickerSettings.psm1 @@ -285,6 +285,11 @@ function Test-TargetResource } if ($null -eq $configuredDomain) { + $message = "Current SearchActiveDirectoryDomains does not match the desired state." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } @@ -299,16 +304,26 @@ function Test-TargetResource if ($null -eq $specifiedDomain) { + $message = "Current SearchActiveDirectoryDomains does not match the desired state." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ActiveDirectoryCustomFilter", ` "ActiveDirectoryCustomQuery", ` "ActiveDirectorySearchTimeout", ` "OnlySearchWithinSiteCollection") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppPermissions/MSFT_SPWebAppPermissions.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppPermissions/MSFT_SPWebAppPermissions.psm1 index b11d7a50a..c6e8dabf7 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppPermissions/MSFT_SPWebAppPermissions.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppPermissions/MSFT_SPWebAppPermissions.psm1 @@ -526,41 +526,66 @@ function Test-TargetResource { if ($CurrentValues.ContainsKey("AllPermissions")) { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("AllPermissions") } else { - return $false + $result = $false } } else { if ($CurrentValues.ContainsKey("AllPermissions")) { - return $false - } - else - { - if ($null -ne (Compare-Object -ReferenceObject $ListPermissions ` - -DifferenceObject $CurrentValues.ListPermissions)) + $source = $MyInvocation.MyCommand.Source + $EventMessage = "`r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " AllPermissions is configured, but Desired State has individual permissions specified.`r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $WebAppUrl`r`n" + if ($PSBoundParameters.ContainsKey('ListPermissions')) { - return $false + $EventMessage += " $($ListPermissions -join ", ")`r`n" + } - if ($null -ne (Compare-Object -ReferenceObject $SitePermissions ` - -DifferenceObject $CurrentValues.SitePermissions)) + if ($PSBoundParameters.ContainsKey('SitePermissions')) { - return $false + $EventMessage += " $($SitePermissions -join ", ")`r`n" + } - if ($null -ne (Compare-Object -ReferenceObject $PersonalPermissions ` - -DifferenceObject $CurrentValues.PersonalPermissions)) + if ($PSBoundParameters.ContainsKey('PersonalPermissions')) { - return $false + $EventMessage += " $($PersonalPermissions -join ", ")`r`n" + } - return $true + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + + $result = $false + } + else + { + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @("ListPermissions", + "SitePermissions", + "PersonalPermissions" + ) } } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } function Test-SPDscInput() diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 index 93118727b..3defb1b8b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppPolicy/MSFT_SPWebAppPolicy.psm1 @@ -649,6 +649,11 @@ function Test-TargetResource if ($null -eq $CurrentValues.WebAppUrl) { + $message = "One of the specified parameters is incorrect. Please check if these are correct." + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -721,7 +726,7 @@ function Test-TargetResource } # Get the list of differences from the current configuration - $differences = Compare-SPDscWebAppPolicy -WAPolicies $CurrentValues.Members ` + [Array]$differences = Compare-SPDscWebAppPolicy -WAPolicies $CurrentValues.Members ` -DSCSettings $allMembers ` -DefaultIdentityType $defaultIdentityType @@ -730,39 +735,111 @@ function Test-TargetResource { if ($differences.Count -eq 0) { - return $true + $result = $true } else { + $source = $MyInvocation.MyCommand.Source + + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + $driftedValue = '' + foreach ($item in $differences) + { + $EventMessage += " " + $item.Username + " is " + $item.Status + "`r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $WebAppUrl`r`n" + $EventMessage += " `r`n" + foreach ($member in $Members) + { + $EventMessage += " `r`n" + $EventMessage += " $($member.UserName)`r`n" + $EventMessage += " $($member.PermissionLevel)`r`n" + $EventMessage += " $($member.IdentityType)`r`n" + $EventMessage += " $($member.ActAsSystemAccount)`r`n" + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + Write-Verbose -Message "Differences in the policy were found, returning false" - return $false + $result = $false } + + Write-Verbose -Message "Test-TargetResource returned $result" + return $result } # If only checking members to include only differences or missing records count as a fail if ($MembersToInclude) { - $diffcount = ($differences | Where-Object -FilterScript { - $_.Status -eq "Different" -or $_.Status -eq "Missing" - }).Count + $diffs = $differences | Where-Object -FilterScript { + $_.Status -eq "Different" -or $_.Status -eq "Missing" + } + $diffcount = $diffs.Count if ($diffcount -eq 0) { - return $true + $result = $true } else { + $source = $MyInvocation.MyCommand.Source + + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + $driftedValue = '' + foreach ($item in $diffs) + { + $EventMessage += " " + $item.Username + " is " + $item.Status + "`r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $WebAppUrl`r`n" + $EventMessage += " `r`n" + foreach ($member in $MembersToInclude) + { + $EventMessage += " `r`n" + $EventMessage += " $($member.UserName)`r`n" + $EventMessage += " $($member.PermissionLevel)`r`n" + $EventMessage += " $($member.IdentityType)`r`n" + $EventMessage += " $($member.ActAsSystemAccount)`r`n" + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + Write-Verbose -Message "Different or Missing policy was found, returning false" - return $false + $result = $false } + + Write-Verbose -Message "Test-TargetResource returned $result" + return $result } } - # If checking members to exlclude, simply compare the list of user names to the current + # If checking members to exclude, simply compare the list of user names to the current # membership list if ($MembersToExclude) { Write-Verbose -Message ("MembersToExclude property is set - checking for permissions " + ` "that need to be removed") + + $result = $true + $presentAccounts = @() foreach ($member in $MembersToExclude) { if (($cacheAccounts.SuperUserAccount -eq $member.Username) -or ` @@ -775,11 +852,44 @@ function Test-TargetResource { if ($policy.Username -eq $member.Username) { - return $false + $presentAccounts += $member.Username + $result = $false } } } - return $true + + if ($result -eq $false) + { + $source = $MyInvocation.MyCommand.Source + + $EventMessage = "`r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " " + ($presentAccounts -join ", ") + " is/are added to the policy`r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " $WebAppUrl`r`n" + $EventMessage += " `r`n" + foreach ($member in $MembersToExclude) + { + $EventMessage += " `r`n" + $EventMessage += " $($member.UserName)`r`n" + $EventMessage += " $($member.PermissionLevel)`r`n" + $EventMessage += " $($member.IdentityType)`r`n" + $EventMessage += " $($member.ActAsSystemAccount)`r`n" + $EventMessage += " `r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $source + } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } } diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppPropertyBag/MSFT_SPWebAppPropertyBag.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppPropertyBag/MSFT_SPWebAppPropertyBag.psm1 index 9bde161d3..6481f32c8 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppPropertyBag/MSFT_SPWebAppPropertyBag.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppPropertyBag/MSFT_SPWebAppPropertyBag.psm1 @@ -160,18 +160,23 @@ function Test-TargetResource() if ($Ensure -eq 'Present') { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @('Ensure', 'Key', 'Value') } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @('Ensure', 'Key') } + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppProxyGroup/MSFT_SPWebAppProxyGroup.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppProxyGroup/MSFT_SPWebAppProxyGroup.psm1 index 6dfa2b7fc..3c76b6a90 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppProxyGroup/MSFT_SPWebAppProxyGroup.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppProxyGroup/MSFT_SPWebAppProxyGroup.psm1 @@ -29,7 +29,7 @@ function Get-TargetResource -ScriptBlock { $params = $args[0] - $WebApp = get-spwebapplication $params.WebAppUrl + $WebApp = Get-SPWebApplication $params.WebAppUrl if (!$WebApp) { return @{ @@ -121,17 +121,31 @@ function Test-TargetResource if (($null -eq $CurrentValues.WebAppUrl) -or ($null -eq $CurrentValues.ServiceAppProxyGroup)) { - return $false - } + $message = "Specified web application {$WebAppUrl} does not exist." + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source - if ($CurrentValues.ServiceAppProxyGroup -eq $ServiceAppProxyGroup) - { - return $true + $result = $false } else { - return $false + if ($CurrentValues.ServiceAppProxyGroup -eq $ServiceAppProxyGroup) + { + $result = $true + } + else + { + $message = ("Current ServiceAppProxyGroup {$($CurrentValues.ServiceAppProxyGroup)} " + ` + "is not in the desired state {$ServiceAppProxyGroup}.") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + $result = $false + } } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppSiteUseAndDeletion/MSFT_SPWebAppSiteUseAndDeletion.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppSiteUseAndDeletion/MSFT_SPWebAppSiteUseAndDeletion.psm1 index 3bc3e33be..47935e8c1 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppSiteUseAndDeletion/MSFT_SPWebAppSiteUseAndDeletion.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppSiteUseAndDeletion/MSFT_SPWebAppSiteUseAndDeletion.psm1 @@ -244,8 +244,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppSuiteBar/MSFT_SPWebAppSuiteBar.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppSuiteBar/MSFT_SPWebAppSuiteBar.psm1 index 1693b3429..63589df37 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppSuiteBar/MSFT_SPWebAppSuiteBar.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppSuiteBar/MSFT_SPWebAppSuiteBar.psm1 @@ -251,6 +251,7 @@ function Test-TargetResource if ($null -eq $CurrentValues.WebAppUrl) { + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -258,20 +259,25 @@ function Test-TargetResource if ($installedVersion.FileMajorPart -eq 15) { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuiteBarBrandingElementHtml"); } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("SuiteBarBrandingElementHtml", - "SuiteNavBrandingLogoNavigationUrl", - "SuiteNavBrandingLogoTitle", - "SuiteNavBrandingLogoUrl", - "SuiteNavBrandingText") + "SuiteNavBrandingLogoNavigationUrl", + "SuiteNavBrandingLogoTitle", + "SuiteNavBrandingLogoUrl", + "SuiteNavBrandingText") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppThrottlingSettings/MSFT_SPWebAppThrottlingSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppThrottlingSettings/MSFT_SPWebAppThrottlingSettings.psm1 index 7361cc580..c2eaef44b 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppThrottlingSettings/MSFT_SPWebAppThrottlingSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppThrottlingSettings/MSFT_SPWebAppThrottlingSettings.psm1 @@ -256,8 +256,13 @@ function Test-TargetResource $relPath = "..\..\Modules\SharePointDsc.WebApplication\SPWebApplication.Throttling.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $relPath -Resolve) - return Test-SPDscWebApplicationThrottlingConfig -CurrentSettings $CurrentValues ` + $result = Test-SPDscWebApplicationThrottlingConfig -CurrentSettings $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredSettings $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebAppWorkflowSettings/MSFT_SPWebAppWorkflowSettings.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebAppWorkflowSettings/MSFT_SPWebAppWorkflowSettings.psm1 index 536cf7e4a..02f366ba1 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebAppWorkflowSettings/MSFT_SPWebAppWorkflowSettings.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebAppWorkflowSettings/MSFT_SPWebAppWorkflowSettings.psm1 @@ -146,8 +146,13 @@ function Test-TargetResource $relPath = "..\..\Modules\SharePointDsc.WebApplication\SPWebApplication.Workflow.psm1" Import-Module (Join-Path $PSScriptRoot $relPath -Resolve) - return Test-SPDscWebApplicationWorkflowConfig -CurrentSettings $CurrentValues ` + $result = Test-SPDscWebApplicationWorkflowConfig -CurrentSettings $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredSettings $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebApplication/MSFT_SPWebApplication.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebApplication/MSFT_SPWebApplication.psm1 index d8946bccc..a02e8e4e3 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebApplication/MSFT_SPWebApplication.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebApplication/MSFT_SPWebApplication.psm1 @@ -351,10 +351,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - $testReturn = Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") - return $testReturn + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebApplicationAppDomain/MSFT_SPWebApplicationAppDomain.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebApplicationAppDomain/MSFT_SPWebApplicationAppDomain.psm1 index 8c90c1dfc..46e392516 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebApplicationAppDomain/MSFT_SPWebApplicationAppDomain.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebApplicationAppDomain/MSFT_SPWebApplicationAppDomain.psm1 @@ -174,9 +174,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("AppDomain", "Port", "SSL") + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWebApplicationExtension/MSFT_SPWebApplicationExtension.psm1 b/SharePointDsc/DSCResources/MSFT_SPWebApplicationExtension/MSFT_SPWebApplicationExtension.psm1 index 1bfb199d4..50c13db3a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWebApplicationExtension/MSFT_SPWebApplicationExtension.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWebApplicationExtension/MSFT_SPWebApplicationExtension.psm1 @@ -327,10 +327,14 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - $testReturn = Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure", "AllowAnonymous") - return $testReturn + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 index 677e4d3d2..45d47672e 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWordAutomationServiceApp/MSFT_SPWordAutomationServiceApp.psm1 @@ -673,8 +673,13 @@ function Test-TargetResource Write-Verbose -Message "Current Values: $(Convert-SPDscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-SPDscHashtableToString -Hashtable $PSBoundParameters)" - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 b/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 index fea67f7cd..363c9203a 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWorkManagementServiceApp/MSFT_SPWorkManagementServiceApp.psm1 @@ -404,24 +404,30 @@ function Test-TargetResource if ($Ensure -eq "Present") { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("ApplicationPool", - "MinimumTimeBetweenEwsSyncSubscriptionSearches", - "MinimumTimeBetweenProviderRefreshes", - "MinimumTimeBetweenSearchQueries", - "Name", - "NumberOfSubscriptionSyncsPerEwsSyncRun", - "NumberOfUsersEwsSyncWillProcessAtOnce", - "NumberOfUsersPerEwsSyncBatch", - "Ensure") + "MinimumTimeBetweenEwsSyncSubscriptionSearches", + "MinimumTimeBetweenProviderRefreshes", + "MinimumTimeBetweenSearchQueries", + "Name", + "NumberOfSubscriptionSyncsPerEwsSyncRun", + "NumberOfUsersEwsSyncWillProcessAtOnce", + "NumberOfUsersPerEwsSyncBatch", + "Ensure") } else { - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck @("Ensure") } + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 b/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 index 66a37596b..1c106cc71 100644 --- a/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPWorkflowService/MSFT_SPWorkflowService.psm1 @@ -164,6 +164,11 @@ function Test-TargetResource if ($null -eq $CurrentValues.WorkflowHostUri) { + $message = "WorkflowHostUri is not configured" + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $MyInvocation.MyCommand.Source + + Write-Verbose -Message "Test-TargetResource returned false" return $false } @@ -175,9 +180,14 @@ function Test-TargetResource $valuesToCheck += "ScopeName" } - return Test-SPDscParameterState -CurrentValues $CurrentValues ` + $result = Test-SPDscParameterState -CurrentValues $CurrentValues ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $PSBoundParameters ` -ValuesToCheck $valuesToCheck + + Write-Verbose -Message "Test-TargetResource returned $result" + + return $result } Export-ModuleMember -Function *-TargetResource diff --git a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index b94ba27aa..88440dfec 100644 --- a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -1,3 +1,52 @@ +function Add-SPDscEvent +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [System.String] + $Message, + + [Parameter(Mandatory = $true)] + [System.String] + $Source = 'Generic', + + [Parameter()] + [ValidateSet('Error', 'Information', 'FailureAudit', 'SuccessAudit', 'Warning')] + [System.String] + $EntryType = 'Information', + + [Parameter()] + [System.UInt32] + $EventID = 1 + ) + + try + { + $CurrentLog = Get-EventLog -LogName 'SharePointDsc' -Source $Source -ErrorAction SilentlyContinue + if ($null -eq $CurrentLog) + { + $CurrentLog = New-EventLog -LogName 'SharePointDsc' -Source $Source -ErrorAction SilentlyContinue + } + [System.Diagnostics.EventLog]::CreateEventSource($Source, "SharePointDsc") + } + catch + { + Write-Verbose $_ + } + + try + { + Write-EventLog -LogName 'SharePointDsc' -Source $Source ` + -EventID $EventID -Message $Message -EntryType $EntryType ` + -ErrorAction SilentlyContinue + } + catch + { + Write-Verbose $_ + } +} + function Add-SPDscUserToLocalAdmin { [CmdletBinding()] @@ -42,6 +91,63 @@ function Clear-SPDscKerberosToken } } +function Compare-PSCustomObjectArrays +{ + [CmdletBinding()] + [OutputType([System.Object[]])] + param + ( + [Parameter(Mandatory = $true)] + [AllowEmptyCollection()] + [System.Object[]] + $DesiredValues, + + [Parameter(Mandatory = $true)] + [AllowEmptyCollection()] + [System.Object[]] + $CurrentValues + ) + + $DriftedProperties = @() + foreach ($DesiredEntry in $DesiredValues) + { + $Properties = $DesiredEntry.PSObject.Properties + $KeyProperty = $Properties.Name[0] + + $EquivalentEntryInCurrent = $CurrentValues | Where-Object -FilterScript { $_.$KeyProperty -eq $DesiredEntry.$KeyProperty } + if ($null -eq $EquivalentEntryInCurrent) + { + $result = @{ + Property = $DesiredEntry + PropertyName = $KeyProperty + Desired = $DesiredEntry.$KeyProperty + Current = $null + } + $DriftedProperties += $DesiredEntry + } + else + { + foreach ($property in $Properties) + { + $propertyName = $property.Name + + if ($DesiredEntry.$PropertyName -ne $EquivalentEntryInCurrent.$PropertyName) + { + $result = @{ + Property = $DesiredEntry + PropertyName = $PropertyName + Desired = $DesiredEntry.$PropertyName + Current = $EquivalentEntryInCurrent.$PropertyName + } + $DriftedProperties += $result + } + } + } + } + + return $DriftedProperties +} + function Convert-SPDscADGroupIDToName { param @@ -801,13 +907,19 @@ function Test-SPDscParameterState [Object] $DesiredValues, - [Parameter(, Position = 3)] + [Parameter(Position = 3)] [Array] - $ValuesToCheck + $ValuesToCheck, + + [Parameter(Position = 4)] + [System.String] + $Source = 'Generic' ) $returnValue = $true + $DriftedParameters = @{ } + if (($DesiredValues.GetType().Name -ne "HashTable") -and ` ($DesiredValues.GetType().Name -ne "CimInstance") -and ` ($DesiredValues.GetType().Name -ne "PSBoundParametersDictionary")) @@ -864,13 +976,47 @@ function Test-SPDscParameterState "values, but it was either not present or " + ` "was null. This has caused the test method " + ` "to return false.") + $DriftedParameters.Add($fieldName, '') $returnValue = $false } + elseif ($desiredType.Name -eq 'ciminstance[]') + { + Write-Verbose "The current property {$_} is a CimInstance[]" + $AllDesiredValuesAsArray = @() + foreach ($item in $DesiredValues.$_) + { + $currentEntry = @{ } + foreach ($prop in $item.CIMInstanceProperties) + { + $value = $prop.Value + if ([System.String]::IsNullOrEmpty($value)) + { + $value = $null + } + $currentEntry.Add($prop.Name, $value) + } + $AllDesiredValuesAsArray += [PSCustomObject]$currentEntry + } + + $arrayCompare = Compare-PSCustomObjectArrays -CurrentValues $CurrentValues.$fieldName ` + -DesiredValues $AllDesiredValuesAsArray + if ($null -ne $arrayCompare) + { + foreach ($item in $arrayCompare) + { + $EventValue = "[$($item.PropertyName)]$($item.CurrentValue)" + $EventValue += "[$($item.PropertyName)]$($item.DesiredValue)" + $DriftedParameters.Add($fieldName, $EventValue) + } + $returnValue = $false + } + } else { $arrayCompare = Compare-Object -ReferenceObject $CurrentValues.$fieldName ` -DifferenceObject $DesiredValues.$fieldName - if ($null -ne $arrayCompare) + if ($null -ne $arrayCompare -and ` + -not [System.String]::IsNullOrEmpty($arrayCompare.InputObject)) { Write-Verbose -Message ("Found an array for property $fieldName " + ` "in the current values, but this array " + ` @@ -879,6 +1025,10 @@ function Test-SPDscParameterState $arrayCompare | ForEach-Object -Process { Write-Verbose -Message "$($_.InputObject) - $($_.SideIndicator)" } + + $EventValue = "$($CurrentValues.$fieldName -join ", ")" + $EventValue += "$($DesiredValues.$fieldName -join ", ")" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -901,6 +1051,9 @@ function Test-SPDscParameterState "'$($CurrentValues.$fieldName)' " + ` "and desired state is " + ` "'$($DesiredValues.$fieldName)'") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -918,6 +1071,9 @@ function Test-SPDscParameterState "'$($CurrentValues.$fieldName)' " + ` "and desired state is " + ` "'$($DesiredValues.$fieldName)'") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -935,6 +1091,9 @@ function Test-SPDscParameterState "'$($CurrentValues.$fieldName)' " + ` "and desired state is " + ` "'$($DesiredValues.$fieldName)'") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -948,6 +1107,9 @@ function Test-SPDscParameterState "'$($CurrentValues.$fieldName)' " + ` "and desired state is " + ` "'$($DesiredValues.$fieldName)'") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -965,8 +1127,65 @@ function Test-SPDscParameterState "'$($CurrentValues.$fieldName)' " + ` "and desired state is " + ` "'$($DesiredValues.$fieldName)'") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) + $returnValue = $false + } + } + "Hashtable" + { + Write-Verbose -Message "The current property {$fieldName} is a Hashtable" + $AllDesiredValuesAsArray = @() + foreach ($item in $DesiredValues.$fieldName) + { + $currentEntry = @{ } + foreach ($key in $item.Keys) + { + $value = $item.$key + if ([System.String]::IsNullOrEmpty($value)) + { + $value = $null + } + $currentEntry.Add($key, $value) + } + $AllDesiredValuesAsArray += [PSCustomObject]$currentEntry + } + + if ($null -ne $DesiredValues.$fieldName -and $null -eq $CurrentValues.$fieldName) + { $returnValue = $false } + else + { + $AllCurrentValuesAsArray = @() + foreach ($item in $CurrentValues.$fieldName) + { + $currentEntry = @{ } + foreach ($key in $item.Keys) + { + $value = $item.$key + if ([System.String]::IsNullOrEmpty($value)) + { + $value = $null + } + $currentEntry.Add($key, $value) + } + $AllCurrentValuesAsArray += [PSCustomObject]$currentEntry + } + $arrayCompare = Compare-PSCustomObjectArrays -CurrentValues $AllCurrentValuesAsArray ` + -DesiredValues $AllCurrentValuesAsArray + if ($null -ne $arrayCompare) + { + foreach ($item in $arrayCompare) + { + $EventValue = "[$($item.PropertyName)]$($item.CurrentValue)" + $EventValue += "[$($item.PropertyName)]$($item.DesiredValue)" + $DriftedParameters.Add($fieldName, $EventValue) + } + $returnValue = $false + } + } } default { @@ -974,6 +1193,9 @@ function Test-SPDscParameterState "as the type ($($desiredType.Name)) is " + ` "not handled by the " + ` "Test-SPDscParameterState cmdlet") + $EventValue = "$($CurrentValues.$fieldName)" + $EventValue += "$($DesiredValues.$fieldName)" + $DriftedParameters.Add($fieldName, $EventValue) $returnValue = $false } } @@ -982,6 +1204,37 @@ function Test-SPDscParameterState } } } + + if ($returnValue -eq $false) + { + $EventMessage = "`r`n" + $EventMessage += " `r`n" + + $EventMessage += " `r`n" + $driftedValue = '' + foreach ($key in $DriftedParameters.Keys) + { + Write-Verbose -Message "Detected Drifted Parameter [$Source]$key" + $EventMessage += " " + $DriftedParameters.$key + "`r`n" + } + $EventMessage += " `r`n" + $EventMessage += " `r`n" + $EventMessage += " `r`n" + foreach ($Key in $DesiredValues.Keys) + { + $Value = $DesiredValues.$Key -join ", " + if ([System.String]::IsNullOrEmpty($Value)) + { + $Value = "`$null" + } + $EventMessage += " $Value`r`n" + } + $EventMessage += " `r`n" + $EventMessage += "" + + Add-SPDscEvent -Message $EventMessage -EntryType 'Error' -EventID 1 -Source $Source + } + return $returnValue } diff --git a/SharePointDsc/Modules/SharePointDsc.WebAppPolicy/SPWebAppPolicy.psm1 b/SharePointDsc/Modules/SharePointDsc.WebAppPolicy/SPWebAppPolicy.psm1 index 745092f58..8b78996bc 100644 --- a/SharePointDsc/Modules/SharePointDsc.WebAppPolicy/SPWebAppPolicy.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.WebAppPolicy/SPWebAppPolicy.psm1 @@ -11,12 +11,10 @@ function Assert-SPDscPolicyUser() $UsernameToCheck ) - foreach ($difference in $CurrentDifferences) + $diffcol = $CurrentDifferences | Where { $_.Username -eq $UsernameToCheck } + if ($diffcol.Count -gt 0) { - if ($difference.ContainsKey($UsernameToCheck)) - { - return $true - } + return $true } return $false } diff --git a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.BlockedFileTypes.psm1 b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.BlockedFileTypes.psm1 index c3b954cfb..aee0d0668 100644 --- a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.BlockedFileTypes.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.BlockedFileTypes.psm1 @@ -85,9 +85,16 @@ function Test-SPDscWebApplicationBlockedFileTypeConfig $CurrentSettings, [Parameter(Mandatory = $true)] - $DesiredSettings + $DesiredSettings, + + [Parameter(Mandatory = $true)] + [System.String] + $Source ) + $relPath = "..\..\Modules\SharePointDsc.Util\SharePointDsc.Util.psm1" + Import-Module (Join-Path $PSScriptRoot $relPath -Resolve) + if (($DesiredSettings.ContainsKey("Blocked") -eq $true) ` -and (($DesiredSettings.ContainsKey("EnsureBlocked") -eq $true) ` -or ($DesiredSettings.ContainsKey("EnsureAllowed") -eq $true))) @@ -114,6 +121,11 @@ function Test-SPDscWebApplicationBlockedFileTypeConfig } else { + $message = ("The parameter Blocked does not match the desired state. " + ` + "Actual: $($CurrentSettings.Blocked). Desired: $($DesiredSettings.Blocked)") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } @@ -126,6 +138,11 @@ function Test-SPDscWebApplicationBlockedFileTypeConfig } if ($null -ne $itemsToAdd) { + $message = ("The parameter EnsureBlocked does not match the desired state. " + ` + "Actual: $($CurrentSettings.Blocked). Desired: $($DesiredSettings.EnsureBlocked)") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } @@ -137,6 +154,11 @@ function Test-SPDscWebApplicationBlockedFileTypeConfig -ExcludeDifferent -IncludeEqual if ($null -ne $itemsToRemove) { + $message = ("The parameter EnsureAllowed does not match the desired state. " + ` + "Actual: $($CurrentSettings.Blocked). Desired: $($DesiredSettings.EnsureAllowed)") + Write-Verbose -Message $message + Add-SPDscEvent -Message $message -EntryType 'Error' -EventID 1 -Source $Source + return $false } } diff --git a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.GeneralSettings.psm1 b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.GeneralSettings.psm1 index 31dc107a7..26decac17 100644 --- a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.GeneralSettings.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.GeneralSettings.psm1 @@ -141,6 +141,7 @@ function Test-SPDscWebApplicationGeneralConfig "DefaultQuotaTemplate" ) $testReturn = Test-SPDscParameterState -CurrentValues $CurrentSettings ` + -Source $($MyInvocation.MyCommand.Source) ` -DesiredValues $DesiredSettings ` -ValuesToCheck $valuesToCheck return $testReturn diff --git a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Throttling.psm1 b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Throttling.psm1 index 1a82ed57f..a89d28c8a 100644 --- a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Throttling.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Throttling.psm1 @@ -120,25 +120,30 @@ function Test-SPDscWebApplicationThrottlingConfig $CurrentSettings, [Parameter(Mandatory = $true)] - $DesiredSettings + $DesiredSettings, + + [Parameter(Mandatory = $true)] + [System.String] + $Source ) $relPath = "..\..\Modules\SharePointDsc.Util\SharePointDsc.Util.psm1" Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $relPath -Resolve) $testReturn = Test-SPDscParameterState -CurrentValues $CurrentSettings ` + -Source $Source ` -DesiredValues $DesiredSettings ` -ValuesToCheck @( - "ListViewThreshold", - "AllowObjectModelOverride", - "AdminThreshold", - "ListViewLookupThreshold", - "HappyHourEnabled", - "UniquePermissionThreshold", - "RequestThrottling", - "ChangeLogEnabled", - "ChangeLogExpiryDays", - "EventHandlersEnabled" - ) + "ListViewThreshold", + "AllowObjectModelOverride", + "AdminThreshold", + "ListViewLookupThreshold", + "HappyHourEnabled", + "UniquePermissionThreshold", + "RequestThrottling", + "ChangeLogEnabled", + "ChangeLogExpiryDays", + "EventHandlersEnabled" + ) if ($testReturn -eq $true) { if ($null -ne $DesiredSettings.HappyHour) @@ -170,6 +175,7 @@ function Test-SPDscWebApplicationThrottlingConfig } $testReturn = Test-SPDscParameterState -CurrentValues $CurrentSettings.HappyHour ` + -Source $Source ` -DesiredValues $DesiredHappyHour ` -ValuesToCheck @("Hour", "Minute", "Duration") } diff --git a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Workflow.psm1 b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Workflow.psm1 index 98d21451d..5b32e8169 100644 --- a/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Workflow.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.WebApplication/SPWebApplication.Workflow.psm1 @@ -56,7 +56,11 @@ function Test-SPDscWebApplicationWorkflowConfig $CurrentSettings, [Parameter(Mandatory = $true)] - $DesiredSettings + $DesiredSettings, + + [Parameter(Mandatory = $true)] + [System.String] + $Source ) $relPath = "..\..\Modules\SharePointDsc.Util\SharePointDsc.Util.psm1" @@ -66,7 +70,8 @@ function Test-SPDscWebApplicationWorkflowConfig "ExternalWorkflowParticipantsEnabled") $testReturn = Test-SPDscParameterState -CurrentValues $CurrentSettings ` -DesiredValues $DesiredSettings ` - -ValuesToCheck $valuesTocheck + -ValuesToCheck $valuesTocheck ` + -Source $Source return $testReturn } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 index 5cb4cee9b..dc89c53df 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPAccessServiceApp.Tests.ps1 @@ -194,6 +194,12 @@ public class SPServiceContext { return $spServiceApp } + Mock -CommandName Get-SPAccessServicesDatabaseServer -MockWith { + return @{ + ServerName = $testParams.DatabaseServer + } + } + It "Should return present from the Get method" { (Get-TargetResource @testParams).Ensure | Should Be "Present" } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPolicy.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPolicy.Tests.ps1 index 5635f8ca2..998e95fe3 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPolicy.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPWebAppPolicy.Tests.ps1 @@ -795,6 +795,12 @@ try IdentityType = "Native" ActAsSystemAccount = $false } -ClientOnly) + (New-CimInstance -ClassName MSFT_SPWebAppPolicy -Property @{ + Username = "contoso\user3" + PermissionLevel = "Full Control" + IdentityType = "Native" + ActAsSystemAccount = $false + } -ClientOnly) ) } Mock -CommandName Get-SPWebapplication -MockWith { diff --git a/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 index d97892f68..40bf04fbb 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 @@ -148,6 +148,7 @@ try It "Should return true for two identical tables" { $desired = @{ Example = "test" } Test-SPDscParameterState -CurrentValues $desired ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired | Should Be $true } @@ -155,6 +156,7 @@ try $current = @{ Example = "something" } $desired = @{ Example = "test" } Test-SPDscParameterState -CurrentValues $current ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired | Should Be $false } @@ -162,6 +164,7 @@ try $current = @{ } $desired = @{ Example = "test" } Test-SPDscParameterState -CurrentValues $current ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired | Should Be $false } @@ -169,6 +172,7 @@ try $current = @{ Example = "test"; SecondExample = "true" } $desired = @{ Example = "test"; SecondExample = "false" } Test-SPDscParameterState -CurrentValues $current ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired ` -ValuesToCheck @("Example") | Should Be $true } @@ -177,6 +181,7 @@ try $current = @{ Example = "test"; SecondExample = "true" } $desired = @{ Example = "test"; SecondExample = "false" } Test-SPDscParameterState -CurrentValues $current ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired ` -ValuesToCheck @("SecondExample") | Should Be $false } @@ -185,6 +190,7 @@ try $current = @{ } $desired = @{ Example = "test"; SecondExample = "false" } Test-SPDscParameterState -CurrentValues $current ` + -Source 'SharePointDsc.Util' ` -DesiredValues $desired | Should Be $false } }