Skip to content

[BUG] Add-PnPSiteCollectionAdmin returns user not found #291

@LouFarho

Description

@LouFarho

Expected behavior

Provide a string array of users to add as a site collection administrators after site creation.

Actual behavior

Add-PnPSiteCollectionAdmin -Owners $SiteAdministrators
WARNING: Unable to add user as it wasn't found. User will be skipped.
WARNING: Unable to add user as it wasn't found. User will be skipped.
WARNING: Unable to add user as it wasn't found. User will be skipped.

Steps to reproduce behavior

Performed the following after site is created using PowerShell.

The adim url was connected using the -Interactive prior

New-PnPTenantSite -Url $SiteURL -Owner $username -Title $SiteTitle -Template $Template -TimeZone $TimeZone -RemoveDeletedSite -Wait

Pause to make sure everything is setup and propagated despite the -Wait

Start-Sleep -Seconds 30

$SiteAdministrators = @("user1@contoso.com", "user2@contoso.com", "user3@contoso.com")

Tried this because of the error when using the above just in case.

$SiteAdministrators = @("i:0#.f|membership|user1@contoso.com", "i:0#.f|membership|user2@contoso.com", "i:0#.f|membership|user3@contoso.com")

Connect-PnPOnline -Url $SiteURL -Interactive
Add-PnPSiteCollectionAdmin -Owners $SiteAdministrators

What is the version of the Cmdlet module you are running?

This is a G3 GCC tenant. The login running the script does have MFA. The current user was added as a site collection admin as part of the creation of the site. This script was running without issues using the old PnP module latest release. After updating to PnP.PowerShell various scripts have had to be modified. The users were added manually without issue.

PnP.PowerShell 1.3.0

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions