Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPOBrowserIdleSignout (and more): Not working #5648

Closed
ricmestre opened this issue Jan 18, 2025 · 6 comments · Fixed by #5651, #5653 or #5662
Closed

SPOBrowserIdleSignout (and more): Not working #5648

ricmestre opened this issue Jan 18, 2025 · 6 comments · Fixed by #5651, #5653 or #5662

Comments

@ricmestre
Copy link
Contributor

ricmestre commented Jan 18, 2025

Description of the issue

If resource in the tenant matches the one in the blueprint there's no problems, but if there's a change then the test will spit out an error message about Method invocation failed because [System.TimeSpan] does not contain a method named 'Replace'

@FabienTschanz This is happening because of your commit 4090f74 to align line breaks, effectively this breaks on any resource that has a time span property of type TimeSpan instead of string which happens more often. Could you please check this?

EDIT: I've just checked and in fact the property is actually of type String, yet somehow when it reaches Test-M365DSCParameterState even with $desiredType.Name being String it interprets it as a TimeSpan and errors out.

Microsoft 365 DSC Version

1.25.115.1

Which workloads are affected

SharePoint Online

The DSC configuration

SPOBrowserIdleSignout "SPOBrowserIdleSignout"
        {
            ApplicationId         = $SPOApplicationId;
            CertificateThumbprint = $SPOCertThumbprint;
            Enabled               = $True;
            IsSingleInstance      = "Yes";
            SignOutAfter          = "02:00:00";
            TenantId              = $OrganizationName;
            WarnAfter             = "01:00:00";
        }

Verbose logs showing the problem

N/A

Environment Information + PowerShell Version

Win11/PS5.1
@ricmestre
Copy link
Contributor Author

ricmestre commented Jan 18, 2025

Found another one, this time was SPOSharingSettings with error message Method invocation failed because [Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities] does not contain a method named 'Replace'

EDIT: TeamsEmergencyCallingPolicy gives [Microsoft.Teams.Policy.Administration.Cmdlets.Core.ExternalLocationLookupMode] does not contain a method named 'Replace'

@ricmestre ricmestre changed the title SPOBrowserIdleSignout: Not working SPOBrowserIdleSignout (and more): Not working Jan 19, 2025
@FabienTschanz
Copy link
Collaborator

I know why that is: The MOF schema defines the property as a String, in which they also get implicitly converted during the export. But when running the Test-TargetResource, there is no direct ToString() method call on the property, thus leaving it in its original type. Because Test-M365DSCParameterState only looks at the desired type (which would be String in all of those cases), it is blissfully unaware that the source type is different from that and this therefore results in an error about the Replace method being unavailable.

Do you want me to update the Get-TargetResource export of those resources so that they call ToString() during the object return? That would be the simplest solution.

New version of SPOBrowserIdleSignout:

return @{
            IsSingleInstance      = 'Yes'
            Enabled               = $BrowserIdleSignout.Enabled
            SignOutAfter          = $BrowserIdleSignout.SignOutAfter.ToString()  # Added ToString()
            WarnAfter             = $BrowserIdleSignout.WarnAfter.ToString()     # Added ToString()
            Credential            = $Credential
            ....
        }

@ricmestre
Copy link
Contributor Author

@FabienTschanz Problem with that solution is that there will always be new resources popping up with the same issue.

I'm currently testing a diff, if it works I'll raise the PR with it.

@ricmestre
Copy link
Contributor Author

It's always an excruciating pain for me trying to run my tests and there's always something else breaking which then takes me several more hours in order to run everything again.

Anyway #5651 fixes this.

@ykuijs
Copy link
Member

ykuijs commented Jan 21, 2025

Agree that the fix proposed by @ricmestre is a more structural solution. However, I also think that making sure the exported value actually matches the schema is important as well. Was already working on a PR that fixes the type conversions for SPOSharingSettings. Will include the SPOBrowserIdleSignout as well.

@ArtemPozharovDNSBelgium

I'm wondering how you can fix small things in SharePoint if exporting it hasn't worked since September 9, 2024. Maybe we are doing something wrong or PnPOnline is no longer working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment