microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.61k stars 501 forks source link

SPOAccessControlSettings DSC Key (CommentsOnSitePagesDisabled,DisplayStartASiteOption,DisallowInfectedFileDownload) can't be set 'Authentication needed, call Connect-MgGraph' #1535

Closed atdheekurteshi closed 2 years ago

atdheekurteshi commented 3 years ago

ISSUE TITLE: SPOAccessControlSettings: DSC Key 'SPOAccessControlSettings' property 'CommentsOnSitePagesDisabled,DisplayStartASiteOption,DisallowInfectedFileDownload' can't be set on class SPOAccessControlSettings

ISSUE DESCRIPTION (this template): SPOAccessControlSettings: DSC Key 'SPOAccessControlSettings' property 'CommentsOnSitePagesDisabled,DisplayStartASiteOption,DisallowInfectedFileDownload' can't be set on class SPOAccessControlSettings

The same issue is happening also for.

SPOSharingSettings: DSC Key 'SPOSharingSettings' property 'PreventExternalUsersFromResharing,RequireAcceptingAccountMatchInvitedAccount,SharingCapability,DefaultSharingLinkType' can't be set on class SPOSharingSettings

Details of the scenario you tried and the problem that is occurring

Verbose logs showing the problem

Authentication needed, call Connect-MgGraph...

2021-11-05 14:09:03,716 INFO    [TenantConfig][T13] - QG successful: MOF files could be found after complilation in C:\Users\xgxtan4\Downloads\m365automationnew\MOFs
2021-11-05 14:09:03,747 DEBUG   [TenantConfig][T13] - DSC Configuration starts for computer: Localhost
2021-11-05 14:13:05,097 INFO    [TenantConfig][T13] - Disconnected successfully !
2021-11-05 14:13:05,114 WARN    [TenantConfig][T13] - Start DSCConfiguration produced no output in the DSC Variable
2021-11-05 14:13:05,176 ERROR   [TenantConfig][T13] - Error occured during DSC Execution in VarErr: Device code terminal timed-out after 120 seconds. Please try again.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
    + PSComputerName        : localhost

Authentication needed, call Connect-MgGraph.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgDomain_List1
    + PSComputerName        : localhost

Ausnahme beim Festlegen von "Connect": "Die Value-Eigenschaft für das PSMemberInfo-Objekt vom Typ "System.Management.Automation.PSMethod" kann nicht festgelegt werden."
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : ExceptionWhenSetting,Connect-MSCloudLoginPnP
    + PSComputerName        : localhost

Die PowerShell DSC-Ressource "[SPOAccessControlSettings]Container-18-2acc1136-e34c-4fa6-81c5-154f9a84ae48" mit SourceInfo "::10::3::SPOAccessControlSettings" hat beim Ausführen der 
Funktion "Test-TargetResource" mindestens einen Fehler ohne Abbruch ausgegeben. Diese Fehler werden im ETW-Kanal namens "Microsoft-Windows-DSC/Operational" protokolliert. Weitere 
Informationen finden Sie in diesem Kanal.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

Mindestens eine der partiellen Konfigurationen konnte nicht angewendet werden. Es konnte keine Konfiguration erstellt werden.  Der lokale Konfigurations-Manager (LCM) konnte Desired 
State Configuration nicht manuell starten.
    + CategoryInfo          : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 6
    + PSComputerName        : localhost

Suggested solution to the issue

The DSC configuration that is used to reproduce the issue (as detailed as possible)

MOF file extract

/*
@TargetNode='localhost'
@GeneratedBy=xxx
@GenerationDate=11/05/2021 14:09:03
@GenerationHost=INHOUSE-WIN7
*/

instance of MSFT_SPOAccessControlSettings as $MSFT_SPOAccessControlSettings1ref
{
ResourceID = "[SPOAccessControlSettings]Container-18-2acc1136-e34c-4fa6-81c5-154f9a84ae48";
 Ensure = "Present";
 Credential = $MSFT_Credential1ref;
 DisplayStartASiteOption = False;
 CommentsOnSitePagesDisabled = True;
 SourceInfo = "::10::3::SPOAccessControlSettings";
 IsSingleInstance = "Yes";
 ModuleName = "Microsoft365DSC";
 DisallowInfectedFileDownload = True;
 ModuleVersion = "1.21.1103.1";

 ConfigurationName = "MainConfig";

};
instance of OMI_ConfigurationDocument

                    {
 Version="2.0.0";

                        MinimumCompatibleVersion = "1.0.0";

                        CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};

                        Author="xxx";

                        GenerationDate="11/05/2021 14:09:03";

                        GenerationHost="INHOUSE-WIN7";

                        ContentType="PasswordEncrypted";

                        Name="MainConfig";

                    };

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2021-11-05 14:08:51,356 INFO    [TenantConfig][T13] - ResName: SPOAccessControlSettings is a valid DSC Res and the AttributeKey ' CommentsOnSitePagesDisabled ' is a valid DSC property
2021-11-05 14:08:51,361 INFO    [TenantConfig][T13] - ResName: SPOAccessControlSettings is a valid DSC Res and the AttributeKey ' DisallowInfectedFileDownload ' is a valid DSC property
2021-11-05 14:08:51,365 INFO    [TenantConfig][T13] - ResName: SPOAccessControlSettings is a valid DSC Res and the AttributeKey ' Ensure ' is a valid DSC property
2021-11-05 14:08:51,404 INFO    [TenantConfig][T13] - ResName: SPOAccessControlSettings is a valid DSC Res and the AttributeKey ' DisplayStartASiteOption ' is a valid DSC property
2021-11-05 14:08:51,434 INFO    [TenantConfig][T13] - Resource SPOAccessControlSettings only supports global Admin Auth. Mapping parameter
2021-11-05 14:08:51,782 INFO    [TenantConfig][T13] - Used DSC config for MainConfig Configuration MainConfig
{
     param
     (
           [Parameter(Mandatory = $true,Position=0)][ValidateNotNull()][System.Management.Automation.PSCredential]$AdminCred
     )
     Import-DscResource -ModuleName "Microsoft365DSC"
     Node localhost
     {
        SPOAccessControlSettings Container-18-2acc1136-e34c-4fa6-81c5-154f9a84ae48
        {
            IsSingleInstance = "Yes";
            CommentsOnSitePagesDisabled = $True;
            DisallowInfectedFileDownload = $True;
            Ensure = "Present";
            DisplayStartASiteOption = $False;
            Credential = $AdminCred;
        }
      }
}
2021-11-05 14:09:03,716 INFO    [TenantConfig][T13] - QG successful: MOF files could be found after complilation in C:\Users\xgxtan4\Downloads\m365automationnew\MOFs
2021-11-05 14:13:05,097 INFO    [TenantConfig][T13] - Disconnected successfully !
2021-11-05 14:13:05,114 WARN    [TenantConfig][T13] - Start DSCConfiguration produced no output in the DSC Variable
2021-11-05 14:13:05,176 ERROR   [TenantConfig][T13] - Error occured during DSC Execution in VarErr: Device code terminal timed-out after 120 seconds. Please try again.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
    + PSComputerName        : localhost

Authentication needed, call Connect-MgGraph.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgDomain_List1
    + PSComputerName        : localhost

Ausnahme beim Festlegen von "Connect": "Die Value-Eigenschaft für das PSMemberInfo-Objekt vom Typ "System.Management.Automation.PSMethod" kann nicht festgelegt werden."
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : ExceptionWhenSetting,Connect-MSCloudLoginPnP
    + PSComputerName        : localhost

Die PowerShell DSC-Ressource "[SPOAccessControlSettings]Container-18-2acc1136-e34c-4fa6-81c5-154f9a84ae48" mit SourceInfo "::10::3::SPOAccessControlSettings" hat beim Ausführen der 
Funktion "Test-TargetResource" mindestens einen Fehler ohne Abbruch ausgegeben. Diese Fehler werden im ETW-Kanal namens "Microsoft-Windows-DSC/Operational" protokolliert. Weitere 
Informationen finden Sie in diesem Kanal.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

Mindestens eine der partiellen Konfigurationen konnte nicht angewendet werden. Es konnte keine Konfiguration erstellt werden.  Der lokale Konfigurations-Manager (LCM) konnte Desired 
State Configuration nicht manuell starten.
    + CategoryInfo          : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 6
    + PSComputerName        : localhost
#### 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.21.1103.1
desmay commented 3 years ago

I'll look to add this property on next release

desmay commented 2 years ago

This error is coming from our authentication module. We use the Get-MgDomain in order to derive admin url from user name and password. You must grant Graph PowerShell permission in your tenant. You can run the following: Connect-MgGraph -Scopes "Domain.Read.All". https://docs.microsoft.com/en-us/graph/powershell/get-started#sign-in

atdheekurteshi commented 2 years ago

Issue is closed its working with a newer version of DSC.