Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

AADGRoupsSettings: GeneralGroupSettings reports error

Open jordy-blommaert opened this issue 3 years ago • 10 comments

I used following generalgroupsettings in my deployment:

AADGroupsSettings 'GeneralGroupsSettings' { IsSingleInstance = "Yes" AllowGuestsToAccessGroups = $True AllowGuestsToBeGroupOwner = $False AllowToAddGuests = $True EnableGroupCreation = $True GuestUsageGuidelinesUrl = "https://contoso.com/guestusage" UsageGuidelinesUrl = "https://contoso.com/usage" Ensure = "Present" ApplicationId = $ApplicationId TenantId = $TenantId CertificateThumbprint = $Thumbprint }

I receive underneath error when deploying the policy: GeneralGroupSettingsError

jordy-blommaert avatar Jan 25 '23 07:01 jordy-blommaert

Please share what version of M365DSC you are using. Are there any old version of the module installed and did you update the dependencies?

andikrueger avatar Jan 26 '23 09:01 andikrueger

Hello,

I use the latest version of the DSC: 1.23.118.1 I make use of Azure DevOps based on the document written by Yorick Kuijs

jordy-blommaert avatar Jan 26 '23 09:01 jordy-blommaert

Please review the various scripts to have the proper version string in all scripts.

andikrueger avatar Jan 26 '23 09:01 andikrueger

In the deploy.ps1 script which is used for the deployment towards the environment following is 1 of the first tasks executed in order to check for the required module and if the module differs it updates the modules: image

`Write-Log -Message 'Checking for presence of Microsoft365Dsc module and all required modules' Write-Log -Message ' '

$modules = Import-PowerShellDataFile -Path (Join-Path -Path $workingDirectory -ChildPath 'DscResources.psd1')

if ($modules.ContainsKey("Microsoft365Dsc")) { Write-Log -Message 'Checking Microsoft365Dsc version' -Level 1 $psGalleryVersion = $modules.Microsoft365Dsc $localModule = Get-Module 'Microsoft365Dsc' -ListAvailable

Write-Log -Message "Required version: $psGalleryVersion" -Level 2
Write-Log -Message "Installed version: $($localModule.Version)" -Level 2

if ($localModule.Version -ne $psGalleryVersion)
{
    if ($null -ne $localModule)
    {
        Write-Log -Message 'Incorrect version installed. Removing current module.' -Level 3
        Write-Log -Message 'Removing Microsoft365DSC' -Level 4
        $m365ModulePath = Join-Path -Path 'C:\Program Files\WindowsPowerShell\Modules' -ChildPath 'Microsoft365DSC'
        Remove-Item -Path $m365ModulePath -Force -Recurse -ErrorAction 'SilentlyContinue'
    }

    Write-Log -Message 'Configuring PowerShell Gallery' -Level 4
    Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted'
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    $psGetModule = Get-Module -Name PowerShellGet -ListAvailable | Select-Object -First 1
    if ($null -eq $psGetModule)
    {
        Write-Log -Message '* Installing PowerShellGet' -Level 5
        Install-Module PowerShellGet -Scope AllUsers -SkipPublisherCheck -Force
        Write-Log -Message 'NOTE: If you receive Package Management errors later in this script, please restart the pipeline.' -Level 6
        Write-Log -Message '      This update is not yet being picked up.' -Level 6
    }
    else
    {
        if ($psGetModule.Version -lt [System.Version]"2.2.4.0")
        {
            Write-Log -Message '* Installing PowerShellGet' -Level 5
            Install-Module PowerShellGet -Scope AllUsers -SkipPublisherCheck -Force
            Write-Log -Message 'NOTE: If you receive Package Management errors later in this script, please restart the pipeline.' -Level 6
            Write-Log -Message '      This update is not yet being picked up.' -Level 6
        }
    }

    Write-Log -Message 'Installing Microsoft365Dsc' -Level 4
    $null = Install-Module -Name 'Microsoft365Dsc' -RequiredVersion $psGalleryVersion -Scope AllUsers
}
else
{
    Write-Log -Message 'Correct version installed, continuing.' -Level 3
}

Write-Log -Message 'Checking Module Dependencies' -Level 1
Update-M365DSCDependencies

Write-Log -Message 'Removing Outdated Module Dependencies' -Level 1
Uninstall-M365DSCOutdatedDependencies

Write-Log -Message 'Modules installed successfully!'
Write-Log -Message ' '

} else { Write-Error "[ERROR] Unable to find Microsoft365Dsc in DscResources.psd1. Cancelling!" Write-Host "##vso[task.complete result=Failed;]Failed" exit 10 }`

The DscResources.psd1 contains following content: @{ Microsoft365DSC = '1.23.118.1' }

jordy-blommaert avatar Jan 26 '23 10:01 jordy-blommaert

For the referenced cmdlets to be available, the Graph profile needs to be set to beta. Normally, the resource should take care of the profile switching itself. Any chances you could share your complete configuration (redacted) for us to take a look? Thanks

NikCharlebois avatar Jan 26 '23 19:01 NikCharlebois

Please find the configuration in attachment. I removed the certificate and removed the tenant information in the configuration files. Copied Config.zip

jordy-blommaert avatar Jan 27 '23 14:01 jordy-blommaert

@ykuijs can you have a look at this?

NikCharlebois avatar Jan 27 '23 19:01 NikCharlebois

We have the same issue with Microsoft.Graph.Identity.DirectoryManagement Version: 1.21.0 and dsc release 1.23.201.1 The issue is that the select-mgprofile -name beta command is missing in the current version of AADGroupSettings. v1.0 image

beta image

Probably this change breaks it. https://github.com/microsoft/Microsoft365DSC/commit/79fb08960114ceeee3b0b99334abf0ba96364d93#diff-a24cb935445499a473e031683a8845326a10648d2e6c70c169583d2078334b60

jorisbaiutti avatar Feb 07 '23 10:02 jorisbaiutti

M365DSC doesn't explicitly call the Select-MGProfile cmdlet. Instead, when we initiate the connection via a call to the New-M365DSCConnection cmdlet, we pass in the -ProfileName property to specify v1.0 or beta. The AADGroupSettings does specify the beta profile name and should properly load it.

We have seen some weird behaviors when switching between v1.0 and beta. Out of curiosity are you getting this error if all you configuration file contains is the AADGroupSettings resource?

NikCharlebois avatar Feb 24 '23 20:02 NikCharlebois

Closing due to inactivity

NikCharlebois avatar Mar 17 '23 19:03 NikCharlebois