From a8f5081360adb5dde811e712a5f383606b393233 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Fri, 13 Nov 2020 16:24:22 +0100 Subject: [PATCH] Corrected diagnostic logging of credentials --- CHANGELOG.md | 8 ++++++- .../DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 | 23 ++++++++++++++++++- .../SharePointDsc.Util.psm1 | 4 ++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9105ba554..6d7127a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,9 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- SharePointDsc + - Updated Convert-SPDscHashtableToString to output the username when + parameter is a PSCredential - SPFarm - Switched from creating a Lock database to a Lock table in the TempDB. This to allow the use of precreated databases. + - Updated code to properly output used credential parameters to verbose + logging - SPSite - Added more explanation to documentation on which parameters are checked - SPWeb @@ -40,7 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed issue where provisioning the service app requires a second run to update all specified parameters - SPWorkflowService - - Fixed issue configuring workflow service when no workflow service is currently configured. + - Fixed issue configuring workflow service when no workflow service is + currently configured ## [4.3.0] - 2020-09-30 diff --git a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 index 384cf0150..8757cf1b9 100644 --- a/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPFarm/MSFT_SPFarm.psm1 @@ -982,6 +982,20 @@ function Set-TargetResource { try { + Write-Verbose -Message "Connecting to existing Config database" + Write-Verbose -Message "executeArgs is:" + foreach ($arg in $executeArgs.Keys) + { + if ($executeArgs.$arg -is [System.Management.Automation.PSCredential]) + { + Write-Verbose -Message "$arg : $($executeArgs.$arg.UserName)" + } + else + { + Write-Verbose -Message "$arg : $($executeArgs.$arg)" + } + } + Connect-SPConfigurationDatabase @executeArgs | Out-Null $connectedToFarm = $true } @@ -1031,7 +1045,14 @@ function Set-TargetResource Write-Verbose -Message "executeArgs is:" foreach ($arg in $executeArgs.Keys) { - Write-Verbose -Message "$arg $($executeArgs[$arg])" + if ($executeArgs.$arg -is [System.Management.Automation.PSCredential]) + { + Write-Verbose -Message "$arg : $($executeArgs.$arg.UserName)" + } + else + { + Write-Verbose -Message "$arg : $($executeArgs.$arg)" + } } New-SPConfigurationDatabase @executeArgs diff --git a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index 3931a37e5..f8f634ace 100644 --- a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -245,6 +245,10 @@ function Convert-SPDscHashtableToString { $str = "$($pair.Key)=$(Convert-SPDscCIMInstanceToString -CIMInstance $pair.Value)" } + elseif ($pair.Value -is [System.Management.Automation.PSCredential]) + { + $str = "$($pair.Key)=$($pair.Value.UserName)" + } else { $str = "$($pair.Key)=$($pair.Value)"