pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
621 stars 331 forks source link

[BUG] Set-PnPHomeSite throws an error when you have multiple Viva Connections #3978

Closed ryder-cayden closed 1 month ago

ryder-cayden commented 1 month ago

Reporting an Issue

Running the Set-PnPHomeSite when you have multiple Viva Connections throws the following error: "Set-PnPHomeSite: Operation is not valid due to the current state of the object."

Expected behavior

The Home site should be configured without any error.

Actual behavior

There is an error when running that cmdlet

Steps to reproduce behavior

  1. Go to Office 365 admin center -> Settings -> Viva -> Viva connections
  2. Ensure you have multiple Viva Connections. In my case I have the following:
  3. Open up PowerShell and run the following command: Set-PnpHomeSite -HomeSiteUrl https://tenantName.sharepoint.com/sites/intranet (please change the HomeSiteUrl parameter accordingly)
  4. The following exception will be thrown: Set-PnPHomeSite: Operation is not valid due to the current state of the object.

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

2.3.0 and 2.4.0

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

reshmee011 commented 1 month ago

Hi @ryder-cayden By any chance are you able to use SharePoint Online PowerShell cmdlet Set-SPOHomeSite to set the Home Site? If yes , can please confirm whether you get the same error as using set-pnphomesite?

ryder-cayden commented 1 month ago

Hi @reshmee011... The Set-SPOHomeSite works fine based on my testing. I did not get the same error.

reshmee011 commented 1 month ago

I could reproduce the issue with set-pnphomesite. I checked the code, nothing unusual. It used to work in the past. I will try to find out why it is not working.

gautamdsheth commented 1 month ago

@reshmee011 - found a fix for this , will PR as well shortly. Ran into this while working for a customer project, sorry 😟

gautamdsheth commented 1 month ago

@reshmee011 @ryder-cayden - this issue has been fixed now. Will be available in tomorrow's nightly builds and the next major one when we release it. Thanks for reporting and looking into it.

reshmee011 commented 1 month ago

Thanks so much @gautamdsheth for the fix.