diff --git a/CHANGELOG.md b/CHANGELOG.md index 717ef86646..3b914e36fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ * Initial Release; * SPOPropertyBag * Added multithreading; +* SPOSharingSettings + * Added ExistingExternalUserSharingOnly as a supported value + for SharingCapabilities; * SPOTheme * Fixed an issue with the Set-TargetResource still using SPO management shell cmdlets instead of PnP diff --git a/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1 b/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1 index ef6bb10653..04a59790d9 100644 --- a/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1 +++ b/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1 @@ -11,7 +11,7 @@ function Get-TargetResource [Parameter()] [System.String] - [ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] + [ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] $SharingCapability, [Parameter()] @@ -192,7 +192,7 @@ function Set-TargetResource [Parameter()] [System.String] - [ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] + [ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] $SharingCapability, [Parameter()] @@ -353,7 +353,7 @@ function Test-TargetResource [Parameter()] [System.String] - [ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] + [ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")] $SharingCapability, [Parameter()] diff --git a/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.schema.mof b/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.schema.mof index 0871901c62..4e37898d5a 100644 --- a/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.schema.mof +++ b/Modules/Office365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.schema.mof @@ -2,7 +2,7 @@ class MSFT_SPOSharingSettings : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"),ValueMap{"Yes"},Values{"Yes"}] String IsSingleInstance; - [Write, Description("Configures anonymous link types for folders"),ValueMap{"ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"},Values{"ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"}] string SharingCapability; + [Write, Description("Configures anonymous link types for folders"),ValueMap{"ExistingExternalUserSharingOnly","ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"},Values{"ExistingExternalUserSharingOnly","ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"}] string SharingCapability; [Write, Description("Enables the administrator to hide the Everyone claim in the People Picker.")] boolean ShowEveryoneClaim; [Write, Description("Enables the administrator to hide the All Users claim groups in People Picker.")] boolean ShowAllUsersClaim; [Write, Description("Enables the administrator to hide the Everyone except external users claim in the People Picker.")] boolean ShowEveryoneExceptExternalUsersClaim; diff --git a/Modules/Office365DSC/Modules/O365DSCTelemetryEngine.psm1 b/Modules/Office365DSC/Modules/O365DSCTelemetryEngine.psm1 index c38075a6bc..6fc9f25eee 100644 --- a/Modules/Office365DSC/Modules/O365DSCTelemetryEngine.psm1 +++ b/Modules/Office365DSC/Modules/O365DSCTelemetryEngine.psm1 @@ -38,12 +38,21 @@ function Add-O365DSCTelemetryEvent $Metrics ) - if ($null -eq $env:O365DSCTelemetryEnabled -or $env:O365DSCTelemetryEnabled) + $TelemetryEnabled = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryEnabled', ` + [System.EnvironmentVariableTarget]::Machine) + if ($null -eq $TelemetryEnabled -or $TelemetryEnabled) { $TelemetryClient = Get-ApplicationInsightsTelemetryClient try { + $ProjectName = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryProjectName', ` + [System.EnvironmentVariableTarget]::Machine) + + if ($null -ne $ProjectName) + { + $Data.Add("ProjectName", $ProjectName) + } $TelemetryClient.TrackEvent($Type, $Data, $Metrics) $TelemetryClient.Flush() } @@ -64,7 +73,11 @@ function Set-O365DSCTelemetryOption [Parameter()] [System.String] - $InstrumentationKey + $InstrumentationKey, + + [Parameter()] + [System.String] + $ProjectName ) if ($null -ne $Enabled) @@ -78,4 +91,31 @@ function Set-O365DSCTelemetryOption [System.Environment]::SetEnvironmentVariable('O365DSCTelemetryInstrumentationKey', $InstrumentationKey, ` [System.EnvironmentVariableTarget]::Machine) } + + if ($null -ne $ProjectName) + { + [System.Environment]::SetEnvironmentVariable('O365DSCTelemetryProjectName', $ProjectName, ` + [System.EnvironmentVariableTarget]::Machine) + } +} + +function Get-O365DSCTelemetryOption +{ + [CmdletBinding()] + param() + + try + { + return @{ + Enabled = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryEnabled', ` + [System.EnvironmentVariableTarget]::Machine) + InstrumentationKey = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryInstrumentationKey', ` + [System.EnvironmentVariableTarget]::Machine) + ProjectName = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryProjectName', ` + [System.EnvironmentVariableTarget]::Machine) + } + } + catch { + throw $_ + } } diff --git a/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 b/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 index 53f888c2bc..b4e69465cc 100644 --- a/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 +++ b/Modules/Office365DSC/Modules/Office365DSCUtil.psm1 @@ -1373,7 +1373,7 @@ function Test-Office365DSCParameterState [System.String] $Source = 'Generic' ) - $VerbosePreference = "SilentlyContinue" + $VerbosePreference = "Continue" $WarningPreference = "SilentlyContinue" #region Telemetry $data = [System.Collections.Generic.Dictionary[[String], [String]]]::new() @@ -1617,13 +1617,17 @@ function Test-Office365DSCParameterState $driftedValue = '' foreach ($key in $DriftedParameters.Keys) { - $driftedValue += $key + "|" + Write-Verbose -Message "Detected Drifted Parameter [$Source]$key" + #region Telemetry + $driftedData = [System.Collections.Generic.Dictionary[[String], [String]]]::new() + $driftedData.Add("Event", "DriftedParameter") + $driftedData.Add("Parameter", "[$Source]$key") + Add-O365DSCTelemetryEvent -Type "DriftInfo" -Data $driftedData + #endregion $EventMessage += " " + $DriftedParameters.$key + "`r`n" } #region Telemetry - $driftedValue = $driftedValue.Remove($driftedValue.Length -1, 1) $data.Add("Event", "ConfigurationDrift") - $data.Add("Parameters", $driftedValue) #endregion $EventMessage += " `r`n" $EventMessage += " `r`n"