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

[BUG]Rename-PnPTenantSite are not working as expected in Tenants with vanity url. #3520

Closed
SouptakRoy opened this issue Oct 19, 2023 · 8 comments · Fixed by #3533
Closed
Labels
bug Something isn't working more info needed Further information is requested by user

Comments

@SouptakRoy
Copy link

Reporting an Issue or Missing Feature
Issue:
Rename-PnPTenantSite are not working as expected in Tenants with vanity url.
Site URL – https://contoso-xyz.sharepoint.com/
Admin URL - https://contosoadmin-xyz.sharepoint.com/
The error message shows wrong tenant url if we connect to Site URL only. If we connect using Tenant Admin URL it shows below error –
Rename-PnPTenantSite : An error occurred while sending the request.
Expected behavior
Expected behavior is to Rename SPO Site URL without any error.
Actual behavior
If we connect using SPO Site URL only, we get wrong tenant error as it tries to form Tenant Admin url dynamically and goes to wrong url. Same like #137 and #2567

Connect-PnPOnline -Url "https://contoso-xyz.sharepoint.com/sites/Test" -Interactive

Rename-PnPTenantSite : Unable to connect to the SharePoint Online Admin Center at ‘https://contoso-xyz-admin.sharepoint.com/' to run this cmdlet. Please ensure you pass in the
correct Admin Center URL using Connect-PnPOnline -TenantAdminUrl and you have access to it. Error message: AADSTS500011: The resource principal named
https://contoso-xyz-admin.sharepoint.com/' was not found in the tenant named XYZ. This can happen if the application has not been installed by the administrator of the tenant or
consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.

Timestamp: 2023-10-18 21:37:26Z.
At line:1 char:1

Rename-PnPTenantSite -Identity $currentSiteUrl -NewSiteUrl $updatedSi ...

  • CategoryInfo : InvalidOperation: (:) [Rename-PnPTenantSite], PSInvalidOperationException
  • FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Admin.RenameTenantSite

If we try to connect with Tenant Admin url, it shows “An error occurred while sending the request.”

Connect-PnPOnline -TenantAdminUrl "https://contosoadmin-xyz.sharepoint.com” -Url "https://contoso-xyz.sharepoint.com/sites/Test" -Interactive
Rename-PnPTenantSite -Identity $currentSiteUrl -NewSiteUrl $updatedSiteUrl

Rename-PnPTenantSite : An error occurred while sending the request.
At line:1 char:1

Rename-PnPTenantSite -Identity $currentSiteUrl -NewSiteUrl $updatedSi ...

  • CategoryInfo : WriteError: (:) [Rename-PnPTenantSite], HttpRequestException
  • FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Admin.RenameTenantSite
    Steps to reproduce behavior
    Connect-PnPOnline -TenantAdminUrl "https://contosoadmin-xyz.sharepoint.com” -Url "https://contoso-xyz.sharepoint.com/sites/Test" -Interactive
    Rename-PnPTenantSite -Identity $currentSiteUrl -NewSiteUrl $updatedSiteUrl
    What is the version of the Cmdlet module you are running?
    ModuleType Version Name ExportedCommands

Manifest 1.12.0 PnP.PowerShell {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder...}
Which operating system/environment are you running PnP PowerShell on?
• [ x] Windows
• Linux
• MacOS
• Azure Cloud Shell
• Azure Functions
• Other : please specify

@gautamdsheth
Copy link
Collaborator

hi @SouptakRoy , did you specify the TenantAdminUrl parameter when connecting using Connect-PnPOnline and try ?

https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#-tenantadminurl

You will need it since vanity URLs are kinda special tenants

@gautamdsheth gautamdsheth added the more info needed Further information is requested by user label Oct 22, 2023
@SouptakRoy
Copy link
Author

@gautamdsheth - Thanks for your response. I did, as you can see here -
Connect-PnPOnline -TenantAdminUrl "https://contosoadmin-xyz.sharepoint.com” -Url "https://contoso-xyz.sharepoint.com/sites/Test" -Interactive
Rename-PnPTenantSite -Identity $currentSiteUrl -NewSiteUrl $updatedSiteUrl

Rename operation still fails, however Get-PNPTenantSite works with Tenantadminurl. If some code changes which were done in Get-PNPTenantSite to get it working for Vanity url tenants work, can be synced with Rename-PNPTenantSite too - that might fix the issue.

@koskila
Copy link
Contributor

koskila commented Oct 24, 2023

Took a look into the code for this one - this might be caused by the commandlet using this method in UrlUtilities class for ensuring the URL, that blatantly ignores the possibility of a vanity URL existing:
image

This is done despite the AdminContext already having, well, tenant admin url (it supports vanity domains).

image

There's probably a reason this is done this way, but I wonder if we can just remove the extra validation in this case? Or alternatively, somehow verify if the passed url is in fact a "vanity admin url"...

@koskila
Copy link
Contributor

koskila commented Oct 24, 2023

I guess a fix could be as simple as this:
dev...koskila:pnppowershell:bugfix/3520

@koskila koskila mentioned this issue Oct 25, 2023
3 tasks
@SouptakRoy
Copy link
Author

Thanks a lot @koskila , will wait and test it once available for our vanity tenant. Is this included in today's 2.2.110-nightly release?

@koskila
Copy link
Contributor

koskila commented Oct 26, 2023

Appreciate it @SouptakRoy, I don't have a tenant like that myself so my testing has been very theoretical... :D

The change is not merged yet, I believe after merging (if accepted) it'll be available in the next nightly... Right, @gautamdsheth?

@veronicageek
Copy link
Collaborator

Yes, once merged, it will be available in the nightly the day after indeed 🙂

gautamdsheth added a commit that referenced this issue Oct 29, 2023
* Add a switch to override "validating" tenant admin url

* How did that get there? 😶

* Revert "How did that get there? 😶"

This reverts commit 00f899f.

* Revert "Add a switch to override "validating" tenant admin url"

This reverts commit 802a519.

* Implement @gautamdsheth's feedback :)

* Update RenameTenantSite.cs

* Update RenameTenantSite.cs

---------

Co-authored-by: Gautam Sheth <[email protected]>
@gautamdsheth gautamdsheth reopened this Oct 29, 2023
@gautamdsheth
Copy link
Collaborator

@SouptakRoy - has been fixed in the latest nightly builds by @koskila .

Closing this now.

gautamdsheth added a commit that referenced this issue Dec 12, 2023
* Update index.md

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update index.md

* Update Build-Site.ps1

* Update Build-Site.ps1

* Update index.md

* Fixing documentation build warnings

* Fixing documentation build warnings

* Fixing documentation build warnings

* Fixing documentation build warning

* Added changed entry for PR 3455

* Adding required permissions

* Adding newline

* Adding alias template file

* Removing deprecation notice

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Added silent authentication

* Feature: added output types to page cmdlets

* Feature: added output types for Principals cmdlets

* Update authentication.md added documentation for MFA enabled

* Feature: add support for RAC in site cmdlets

* Feature: added output types for site scripts and designs

* Nightly publish to PowerShell Gallery

* Fix #3447 : issue with page scheduling feature.
Refactor some code

* [FileVersion] Get-PnPSite change for VersionPolicy

* Nightly publish to PowerShell Gallery

* Add new command get-pnpretentionlabel (#3459)

* Add new command get-pnpretentionlabel

* Added the Identity parameter and graph permissions

* Added    [RequiredMinimalApiPermissions("RecordsManagement.Read.All")] attribute

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Update Set-PnPSearchExternalItem.md

Updating sample text from Dutch to English

* Resolve comment

* Nightly publish to PowerShell Gallery

* Feature #1346 - Improved Remove-PnPFlow cmdlet to throw error and add verbose logging

* Update authentication.md added images as suggested by the reviewer

Update authentication.md added images as suggested by the reviewer

* Nightly publish to PowerShell Gallery

* Created a new folder for authentication images

* Added screenshots for authentication article

* Update authentication.md added images references as suggested by the reviewer

* Nightly publish to PowerShell Gallery

* Adding PR reference

* Added PR reference

* Resolve comment

* Added PR reference

* Nightly publish to PowerShell Gallery

* Add a new command Get-PnPSiteVersionPolicy, revert the change in Get-PnPSite

* Added entry for PnP Core PR 1290

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Feature: add GCC support for some cmdlets

* Nightly publish to PowerShell Gallery

* Clarified the error message when running a PnPAdminCmdlet so it also includes a hint towards checking for PIM activation as many customers are using that nowadays and forget to enable it (#3492)

* Fix retrieving error detail in Get-UPABulkImportStatus (#3494)

* Fix retrieving error detail in Get-UPABulkImportStatus

* Handle exceptions when setting the error message

* Update CHANGELOG.md

* Additional cmdlet support for GCC

* Added changelog entry

* Fix  Bug 3495

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Update Set-PnPTenantSite.md (#3501)

Added -DisableSharingForNonOwners to documentation

* Update CHANGELOG.md

* Nightly publish to PowerShell Gallery

* Fixes #3504 Add message "Team Not found" if team is not returned  (#3502)

* Throw Error If Team Not found

* Update GetTeamsTeam.cs

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Add an optional Retry-loop around executing the search query

* Feature #2683 : added support for containers (#3497)

* Feature #2683 : added support for containers

* Improved container image

* Added gitlens

* Improve image

* Improve container process

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Allow to specify additional properties to include in Get-PnPSiteCollectionAdmin (#3521)

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Changed GetContentType to inherit from PnPWebRetrievalsCmdlet (#3518)

* Changed GetContentType to inherit from PnPWebRetrievalsCmdlet

* Added PR reference

* Adding extra spacing for readability and consistency

* Updated documentation to include the -Includes parameter

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Antti/update submitsearchquery docs (#3527)

* Update documentation for Submit-PnPSearchQuery

* Changes sentence ending to be consistent 😅

* Document LCIDs used by -Culture switch

* Update Submit-PnPSearchQuery.md

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Fix #3503 : fix return type for field (#3510)

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Remove the logic to look into the exception specifics with Reflection and just simply always retry

* Update wait time to match documentation.

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Fix #3404 - Update main.css

* Add AllowExternalSenders, AutoSubscribeNewMembers and MailNickname

* Add property mailNickname

* Add mailnickname

* Update documentation

* correct case of mailnickname

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Fixes #3163 (#3530)

* Fixes the bug where all -UseWebLogin auth requests go to the root site collection and implements an override for site-relative auth URI

* Remove unused using

* Update ConnectOnline.cs

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Fix #3520 (#3533)

* Add a switch to override "validating" tenant admin url

* How did that get there? 😶

* Revert "How did that get there? 😶"

This reverts commit 00f899f.

* Revert "Add a switch to override "validating" tenant admin url"

This reverts commit 802a519.

* Implement @gautamdsheth's feedback :)

* Update RenameTenantSite.cs

* Update RenameTenantSite.cs

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Nightly publish to PowerShell Gallery

* Fixed namespaces

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Fixed typos Microsft

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Adding contributors entry

* Adding changelog entry

* Changing exceptions not to be swallowed but shown in verbose and the exception to be thrown if it still happens on the last attempt

* Added changelog entry

* Adding modern list template Ids

* Adding notice with the -Delta parameter

Adding notice with the -Delta parameter that using it in combination with -Select and -Filter has limitations

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Added `-BusinessConnectivityServiceDisabled` to `Set-PnPTenant` (#3562)

* Added BusinessConnectivityServiceDisabled to Set-PnPTenant

* Added PR reference

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Adding request file links properties to site and tenant output (#3557)

* Cleanup of the file. Removing separate private properties and replacing by get/set properties to simplify.

* Adding CoreRequestFilesLinkEnabled, CoreRequestFilesLinkExpirationInDays, OneDriveRequestFilesLinkEnabled and OneDriveRequestFilesLinkExpirationInDays

* Adding RequestFilesLinkEnabled and RequestFilesLinkExpirationInDays

* Adding changelog entry

* Added BusinessConnectivityServiceDisabled

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Added Information Barriers information to the output of `Get-PnPTenantSite` (#3556)

* Added Information Barriers information to the output of `Get-PnPTenantSite`

* Added PR reference

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Adding possibility to set SAN when using `New-PnPAzureCertificate` (#3555)

* Adding possibility to set the Subject Alternative Names on the self signed certificate

* Adding changelog entry

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Renaming Get-PnPWebhooksubscriptions to singular notation to align with the other cmdlets. Added an alias for backwards compatibility. (#3551)

Co-authored-by: Gautam Sheth <[email protected]>

* Rename and bugfixes in `Get-PnPFolder`, `Get-PnPFolderFolder` and `Get-PnPFolderFile` cmdlets (#3421)

* Bugfixes in Get-PnPFolder

* Renaming Get-PnPFolderFile and Get-PnPFolderFolder as discussed

* Updating documentation

* Updated changelog to new cmdlet names

* Added example on combinging Get-PnPFolder with Get-PnPFileInFolder

* Updated example 7 to use the ExcludeSystemFolders parameter

* Bugfix

* Changing recursive parameter to recurse to align with get-pnpfileinfolder and get-childitem

* Applying feedback to keep the cmdlet backwards compatible

* Bugfix

* Adding ignore for obsolete warning

* Changing code to be backwards compatible

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Adding `-Detailed` option to `Get-PnPTenantDeletedSite` (#3550)

* Adding -Detailed option to Get-PnPTenantDeletedSite to optionally fetch more information on the deleted sites

* Adding changelog entry

* Adding PR reference

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Changes as per review comments

* [FileVersion] Add command to get progress for set version policy

* Feature #1644 : Add support for batch requests in
Invoke-PnPSPRestMethod

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Adding changelog entry

* Added changelog entry

* Nightly publish to PowerShell Gallery

* Fixed fetching user with apostrophe in UPN

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Adding documentation on -BusinessConnectivityServiceDisabled

* Changes to move this fix to a lower level so it also fixes it for 2 other cmdlets

* Adding changelog entry

* Updating notice on PnP PowerShell support for Azure Functions

* Add files via upload

* Add files via upload

* Updated steps on adding a custom certificate to reflect the updated webUI

* Add files via upload

* Add files via upload

* Nightly publish to PowerShell Gallery

* Adding .NET 8

* Update buildpr.yml

Adding .NET 8 build for Core SDK

* Changing to Core SDK 8.0 reference

* Adding missing quotes

* Check fix with slash

* Fix path for .NET 8

* Update PnP.PowerShell.csproj

* Update PnP.PowerShell.csproj

* Update buildpr.yml

* Implementation

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Update documentation

* Added changelog entry

* Nightly publish to PowerShell Gallery

* fix for bug 3589

* Nightly publish to PowerShell Gallery

* Cleanup

* Added changelog entry

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Update builddocsite.yml

* Fix docs site navigation

* Fix docs site nav again

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Typo fix

* Destination path resolved wrongly on MacOs

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Update Add-PnPFile.md

Updated examples 4, 5 and 6. 

The date examples used were 1/1/2016

Where mm/dd/yyyy is required. Examples using 12/28/2026 are therefore clearer.

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* New cmdlet remove-pnpmicrosoft365GroupPhoto (#3607)

* New cmdlet remove-pnpmicrosoft365GroupPhoto

* Update SetTeamsTeamPicture.cs

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Update CHANGELOG.md

* Adding to contributors

* Adding extra notice to parameters part

* new cmdlet get-pnpcontainer

* Nightly publish to PowerShell Gallery

* Added `Manage` and `FullControl` to `Grant-PnPAzureADAppSitePermission` (#3617)

* Added Manage and FullControl to Grant-PnPAzureADAppSitePermission

* Adding PR reference

---------

Co-authored-by: Gautam Sheth <[email protected]>

* Cleanup

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Nightly publish to PowerShell Gallery

* Update PnP.PowerShell.Tests.csproj

* Update PnP.PowerShell.csproj

* Create PnP.PowerShell.Suggestions.2.3.0.json

---------

Co-authored-by: erwinvanhunen <[email protected]>
Co-authored-by: Kshitiz Kalra <[email protected]>
Co-authored-by: Gautam Sheth <[email protected]>
Co-authored-by: Jenny Wu <[email protected]>
Co-authored-by: Reshmee Auckloo <[email protected]>
Co-authored-by: Gautam Sheth <[email protected]>
Co-authored-by: Giacomo Pozzoni <[email protected]>
Co-authored-by: Dave Paylor <[email protected]>
Co-authored-by: Antti K. Koskela <[email protected]>
Co-authored-by: Erwin van Hunen <[email protected]>
Co-authored-by: Christian Veenhuis <[email protected]>
Co-authored-by: jennywu <[email protected]_odspmdb>
Co-authored-by: Daniel Cecil <[email protected]>
Co-authored-by: wilecoyotegenius <[email protected]>
Co-authored-by: Pieter Veenstra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more info needed Further information is requested by user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants