Cli-microsoft365: New command: SharePoint Site Swap

Created on 12 May 2020  路  9Comments  路  Source: pnp/cli-microsoft365

Usage

spo site swap [options]

Description

Swap the location of a site with another site while archiving the original site

Options

| Option | Description |
| ----------------------- | ----------------------------------------- |
| --sourceUrl <sourceUrl> | URL of the source site |
| --targetUrl <targetUrl> | URL of the target site that the source site will be swapped to |
| --archiveUrl <archiveUrl> | URL that the target site will be archived to |
| --disableRedirection | Disables the site redirect from being created at the Source URL location |
| --wait | Wait for the job to complete |

Additional Information

The source and target sites can't be connected to an Office 365 group. They also can't be hub sites or associated with a hub. If a site is a hub site, unregister it as a hub site, swap the root site, and then register the site as a hub site. If a site is associated with a hub, disassociate the site, swap the root site, and then reassociate the site.

Invoke-SPOSiteSwap: https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/invoke-spositeswap?view=sharepoint-ps

Using Invoke-SPOSiteSwap to Swap in a New Root Site in Office 365: https://sympmarc.com/2019/08/22/using-invoke-spositeswap-to-swap-in-a-new-root-site-in-office-365/

good first issue new feature work in progress

Most helpful comment

i would not mind taking a stab at this one if it's not already assigned to anyone.

All 9 comments

Is the swap instantaneous or is it a long-running operation? If the latter, would it make sense to add a --wait option in case you want to use it in a script and subsequent commands depend on the site being swapped?

It is a long running operation, by default, Invoke-SPOSiteSwap waits and actually has a -NoWait switch. Good catch, OP updated 馃憤馃徎

i would not mind taking a stab at this one if it's not already assigned to anyone.

All yours @romanatsogeti thank you for helping 馃憤馃徎

@garrytrinder I got the basic structure of the command and looking at validation and main execution now. Just curious if there are techniques to better capture the CSOM calls in the PS module that we can capture. Through dotPeek i can see that client side CSOM method is Microsoft.Online.SharePoint.TenantAdministration.Tenant.SwapSiteWithSmartGestureOptionForce(). Is the team regularly drops down to fiddler to inspect xml call?

Good work @romanatsogeti 馃憤馃徎

Thanks for reaching out.

Yes, where there is no equivalent REST API endpoint, we revert to implementing CSOM calls, passing XML payloads to client.svc endpoint.

Fiddler is great for inspecting the payloads sent when executing the CSOM commands which can then be recreated.

Below is an example in the CLI showing how you can implement a ClientSvc request.

https://github.com/pnp/cli-microsoft365/blob/7d624f6215d9767cefc01c4233ea517ef95c6e22/src/m365/spo/commands/site/site-set.ts#L263

Hey @romanrozinov, are you still working on this?

I'll post my inflight progress, @waldekmastykarz. Apologies for delays due to crazy work schedule, but I do want to wrap this up.

No problem. Thanks for the quick reply 馃憤

Was this page helpful?
0 / 5 - 0 ratings