SPOSharingSettings not in desired state output false but the settings where correctly applied/configured in a tenant
Details of the scenario you tried and the problem that is occurring
SPOSharingSettings below settings are correctly applied/configured in our tenant but I don't understand why are they 'NotInDesiredState'.
When I run the following commands in the Power-Shell everything seems to be working fine for SPOSharingSettings:
Publish-DscConfiguration -Path C:\...\MOFs\MainConfig -Force
Start-DscConfiguration -UseExisting -Force -Verbose -Wait
$res=Test-DscConfiguration -ComputerName localhost -Detailed -Verbose
but the following Power-Shell command
PS C:\Windows\system32> $res.ResourcesNotInDesiredState
ConfigurationName : MainConfig
DependsOn :
ModuleName : Microsoft365DSC
ModuleVersion : 1.22.720.1
PsDscRunAsCredential :
ResourceId : [SPOSharingSettings]Container-46-b7272ff0-e466-48ce-9d15-9fe57a4412f3
SourceInfo : ::433::3::SPOSharingSettings
DurationInSeconds : 3.453
Error :
FinalState :
InDesiredState : False
InitialState :
InstanceName : Container-46-b7272ff0-e466-48ce-9d15-9fe57a4412f3
RebootRequested : False
ResourceName : SPOSharingSettings
StartDate : 8/5/2022 11:37:08 AM
StateChanged : False
PSComputerName : localhost
CimClass : root/Microsoft/Windows/DesiredStateConfiguration:MSFT_ResourceNotInDesiredState
CimInstanceProperties : {ConfigurationName, DependsOn, ModuleName, ModuleVersion...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
PS C:\Windows\system32> $res.ResourcesNotInDesiredState | select ResourceId
ResourceId
----------
[SPOSharingSettings]Container-46-b7272ff0-e466-48ce-9d15-9fe57a4412f3
outputs the SPOSharingSettings not in desired state
The DSC configuration that is used to reproduce the issue (as detailed as possible)
MOF file extract:
/*
@TargetNode='localhost'
@GeneratedBy=xxx
@GenerationDate=
@GenerationHost=xxx
*/
instance of MSFT_SPOSharingSettings as $MSFT_SPOSharingSettings1ref
{
SharingCapability = "Disabled";
TenantId = "";
Ensure = "Present";
PreventExternalUsersFromResharing = True;
RequireAcceptingAccountMatchInvitedAccount = True;
ResourceID = "[SPOSharingSettings]Container-46-c3ac0965-e39f-4cde-a750-d7b6923450b4";
DefaultLinkPermission = "Edit";
IsSingleInstance = "Yes";
SourceInfo = "::402::3::SPOSharingSettings";
CertificateThumbprint = "";
ApplicationId = "";
ModuleVersion = "1.22.720.1";
ModuleName = "Microsoft365DSC";
DefaultSharingLinkType = "Direct";
ConfigurationName = "MainConfig";
};
instance of OMI_ConfigurationDocument
{
Version="2.0.0";
MinimumCompatibleVersion = "1.0.0";
CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
Author="";
GenerationDate="";
GenerationHost="xxx";
ContentType="PasswordEncrypted";
Name="MainConfig";
};
#### The operating system the target node is running
<!--
Please provide as much as possible about the target node, for example
edition, version, build and language.
On OS with WMF 5.1 the following command can help get this information.
OsName : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage : en-US
OsMuiLanguages : {en-US, de-DE}
-->
#### Version of the DSC module that was used ('dev' if using current dev branch)
1.22.720.1
Could you share the verbose log of the Test-DSCConfiguration or the Event Log items? Within the Windows Event Log there should be a full overview of which settings are marked as drifted.
@andikrueger
Here it is:
Log Name: M365DSC
Source: MSFT_SPOSharingSettings
Date: 8/5/2022 11:27:33 AM
Event ID: 1
Task Category: (1)
Level: Warning
Keywords: Classic
User: N/A
Computer:
Description:
<M365DSCEvent>
<ConfigurationDrift Source="MSFT_SPOSharingSettings">
<ParametersNotInDesiredState>
<Param Name="Ensure"><CurrentValue></CurrentValue><DesiredValue>Present</DesiredValue></Param>
</ParametersNotInDesiredState>
</ConfigurationDrift>
<DesiredValues>
<Param Name ="IsSingleInstance">Yes</Param>
<Param Name ="SharingCapability">Disabled</Param>
<Param Name ="DefaultSharingLinkType">Direct</Param>
<Param Name ="PreventExternalUsersFromResharing">True</Param>
<Param Name ="DefaultLinkPermission">Edit</Param>
<Param Name ="RequireAcceptingAccountMatchInvitedAccount">True</Param>
<Param Name ="Ensure">Present</Param>
<Param Name ="Verbose">True</Param>
</DesiredValues>
</M365DSCEvent>
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MSFT_SPOSharingSettings" />
<EventID Qualifiers="0">1</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>1</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2022-08-05T09:27:33.9873915Z" />
<EventRecordID>1967</EventRecordID>
<Correlation />
<Execution ProcessID="0" ThreadID="0" />
<Channel>M365DSC</Channel>
<Computer></Computer>
<Security />
</System>
<EventData>
<Data><M365DSCEvent>
<ConfigurationDrift Source="MSFT_SPOSharingSettings">
<ParametersNotInDesiredState>
<Param Name="Ensure"><CurrentValue></CurrentValue><DesiredValue>Present</DesiredValue></Param>
</ParametersNotInDesiredState>
</ConfigurationDrift>
<DesiredValues>
<Param Name ="IsSingleInstance">Yes</Param>
<Param Name ="SharingCapability">Disabled</Param>
<Param Name ="DefaultSharingLinkType">Direct</Param>
<Param Name ="PreventExternalUsersFromResharing">True</Param>
<Param Name ="DefaultLinkPermission">Edit</Param>
<Param Name ="RequireAcceptingAccountMatchInvitedAccount">True</Param>
<Param Name ="Ensure">Present</Param>
<Param Name ="Verbose">True</Param>
</DesiredValues>
</M365DSCEvent></Data>
</EventData>
</Event>
Thanks for the feedback. Your configuration did not specify the Parameter "Ensure". Therefor the default value was used. Which is present. This is kind of a bug, as the Test-Configuration obviously compares the Ensure Property and does not include the default value for that.
@andikrueger If you check the above MOF file extraction you can see that I have specified the Parameter "Ensure"
instance of MSFT_EXOSharingPolicy as $MSFT_EXOSharingPolicy1ref
{
ResourceID = "[EXOSharingPolicy]Container-79-103cb299-3a38-4438-9019-644599a75297";
Ensure = "Present";
...
The resource with the drifted value is MSFT_SPOSharingSettings and within you mof you are having MSFT_EXOSharingPolicy. Could you check the values for SPOSharingSettings?
@andikrueger I have corrected it here you can see that we provide the Ensure 'Present' Parameter
instance of MSFT_SPOSharingSettings as $MSFT_SPOSharingSettings1ref
{
SharingCapability = "Disabled";
TenantId = "M365DSCDemo.onmicrosoft.com";
Ensure = "Present";
PreventExternalUsersFromResharing = True;
RequireAcceptingAccountMatchInvitedAccount = True;
ResourceID = "[SPOSharingSettings]Container-46-c3ac0965-e39f-4cde-a750-d7b6923450b4";
DefaultLinkPermission = "Edit";
IsSingleInstance = "Yes";
SourceInfo = "::402::3::SPOSharingSettings";
CertificateThumbprint = "";
ApplicationId = "";
ModuleVersion = "1.22.720.1";
ModuleName = "Microsoft365DSC";
DefaultSharingLinkType = "Direct";
ConfigurationName = "MainConfig";
};
Thanks for the update. Actually, I think I found the cause of this issue. The Get-Method does not return the Ensure Parameter. Therefor the compare function fails for this one:
https://github.com/microsoft/Microsoft365DSC/blob/17984cf89f4c13c591e1b935564e060f2be81273/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1#L184-L214
hi Andi, would you please tell me in which final DSC Version will this fix be available ? Thank you, Andriy
It was retested and it works in the Microsoft365DSC 1.22.921.1 (21.09.2022)