Skip to content

[SPO resources] PnP -match filter too greedy #6991

@pangjaa

Description

@pangjaa

Description of the issue

$MySite = Get-PnPTenantSite -Filter "Url -like '-my.sharepoint.'" | Where-Object -FilterScript { $_.Template -notmatch '^RedirectSite#' }

The "Url -like '-my.sharepoint.'" is too greedy. If any user creates a site containing -my.sharepoint.', the cmdlet will return an object. This will cause the subsequent line fail as it expects a string but receives and object. https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSharingSettings/MSFT_SPOSharingSettings.psm1#L183

Microsoft 365 DSC Version

1.26.218.1

Which workloads are affected

SharePoint Online

The DSC configuration

SPOSharingSettings 'SPOSharingSettings' {
        IsSingleInstance                           = 'Yes'
        SharingCapability                          = 'ExistingExternalUserSharingOnly'
        MySiteSharingCapability                    = 'Disabled'
        ShowEveryoneClaim                          = $false
        ShowAllUsersClaim                          = $false
        ShowEveryoneExceptExternalUsersClaim       = $false
        ProvisionSharedWithEveryoneFolder          = $false
        EnableGuestSignInAcceleration              = $false
        BccExternalSharingInvitations              = $false
        # BccExternalSharingInvitationsList          = ''
        # RequireAnonymousLinksExpireInDays          = 60
        # SharingAllowedDomainList                   = @("contoso.com")
        # SharingBlockedDomainList                   = @("contoso.com")
        SharingDomainRestrictionMode               = 'None'
        DefaultSharingLinkType                     = 'Direct'
        PreventExternalUsersFromResharing          = $true
        ShowPeoplePickerSuggestionsForGuestUsers   = $false
        # FileAnonymousLinkType                      = 'View'
        # FolderAnonymousLinkType                    = 'View'
        NotifyOwnersWhenItemsReshared              = $true
        DefaultLinkPermission                      = 'View'
        ExternalUserExpireInDays                   = 30
        ExternalUserExpirationRequired             = $true
        Ensure                                     = 'Present'
        ApplicationId                              = $ApplicationId
        TenantId                                   = $TenantId
        CertificateThumbprint                      = $Thumbprint
    }

Verbose logs showing the problem

Job {7AF43309-22FB-11F1-BB20-060408B76721} :

Message Cannot convert 'System.Object[]' to the type 'PnP.PowerShell.Commands.Base.PipeBinds.SPOSitePipeBind' required by parameter 'Identity'. Specified method is not supported.

HResult -2,146,233,087

StackTrack    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)

   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)

   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)

   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)

   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)

   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)

   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.ResourceProviderAdapter.ExecuteCommand(PowerShell powerShell, ResourceModuleInfo resInfo, String operationCmd, List`1 acceptedProperties, CimInstance nonResourcePropeties, CimInstance resourceConfiguration, LCMDebugMode debugMode, PSInvocationSettings pSInvocationSettings, UInt32& resultStatusHandle, Collection`1& result, ErrorRecord& errorRecord, PSModuleInfo localRunSpaceModuleInfo)

MachineName

DEVOPS-uswest2.

Payload.HResult            

-2146233087

Payload.JobId  

{7AF43309-22FB-11F1-BB20-060408B76721}

Payload.Message          

Cannot convert 'System.Object[]' to the type 'PnP.PowerShell.Commands.Base.PipeBinds.SPOSitePipeBind' required by parameter 'Identity'. Specified method is not supported.

Payload.StackTrace      

at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)

   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)

   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)

   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)

   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)

   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)

   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.ResourceProviderAdapter.ExecuteCommand(PowerShell powerShell, ResourceModuleInfo resInfo, String operationCmd, List`1 acceptedProperties, CimInstance nonResourcePropeties, CimInstance resourceConfiguration, LCMDebugMode debugMode, PSInvocationSettings pSInvocationSettings, UInt32& resultStatusHandle, Collection`1& result, ErrorRecord& errorRecord, PSModuleInfo localRunSpaceModuleInfo)

Environment Information + PowerShell Version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions