cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

New command: `spo site unarchive`

Open milanholemans opened this issue 9 months ago โ€ข 8 comments

Usage

m365 spo site unarchive [options]

Description

Unarchives a site collection

Options

Option Description
-u, --url <url> URL of the site collection.
-f, --force Don't prompt for confirmation.

Examples

Unarchive a specific site collection

m365 spo site unarchive --url "https://contoso.sharepoint.com/sites/Marketing"

Unarchive a specific site collection without confirmation prompt

m365 spo site unarchive --url "https://contoso.sharepoint.com/sites/Marketing" --force

Default properties

No response

Additional Info

API request

Since the REST API request is an internal request, we prefer to use the CSOM request.

POST https://contoso-admin.sharepoint.com/_vti_bin/client.svc/ProcessQuery

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="<CLI app name>"
	xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
	<Actions>
		<ObjectPath Id="8" ObjectPathId="7" />
		<ObjectPath Id="10" ObjectPathId="9" />
		<Query Id="11" ObjectPathId="9">
			<Query SelectAllProperties="true">
				<Properties />
			</Query>
		</Query>
	</Actions>
	<ObjectPaths>
		<Constructor Id="7" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
		<Method Id="9" ParentId="7" Name="GetSitePropertiesByUrl">
			<Parameters>
				<Parameter Type="String">https://contoso.sharepoint.com/sites/Marketing</Parameter>
				<Parameter Type="Boolean">false</Parameter>
			</Parameters>
		</Method>
	</ObjectPaths>
</Request>

Remarks

[!NOTE]
Info admonition: To use this command you must be a Global or SharePoint administrator.

[!WARNING]
If a site remains archived for more than seven days, the reactivation fee will be calculated based on the entire storage capacity of the site.

Additional info

  • https://learn.microsoft.com/en-us/microsoft-365/archive/archive-pricing?view=o365-worldwide

milanholemans avatar May 03 '24 23:05 milanholemans

Seems solid ๐Ÿ‘ some ideas I have are:

  • what if we also allow to specify site by name? and we solve to get the URL. if we find more than one site with the same name we show a prompt to pick based on URL?
  • what if we add a --all option which will basically unarchive everything?

Adam-it avatar May 04 '24 21:05 Adam-it

* what if we also allow to specify site by name? and  we solve to get the URL. if we find more than one site with the same name we show a prompt to pick based on URL?

I don't mind, however, as far as I know, we don't do this like this at other places.

* what if we add a `--all` option which will basically unarchive everything?

In that case, I'd opt for a separate command, no? I also don't know if this is something that people want to do because every restored site is billed (unless it's been archived less than 7 days ago).

milanholemans avatar May 04 '24 21:05 milanholemans

also does this need to be an absolute URL? I think we support specifying just the relative path as CLI is aware of the host part of the URL right?

Adam-it avatar May 04 '24 21:05 Adam-it

* what if we also allow to specify site by name? and  we solve to get the URL. if we find more than one site with the same name we show a prompt to pick based on URL?

I don't mind, however, as far as I know, we don't do this like this at other places.

Correct. Lets leave it as is then ๐Ÿ‘

* what if we add a `--all` option which will basically unarchive everything?

In that case, I'd opt for a separate command, no? I also don't know if this is something that people want to do because every restored site is billed (unless it's been archived less than 7 days ago).

Good point. If anything that also could be a script sample rather than a command๐Ÿ‘

Adam-it avatar May 04 '24 21:05 Adam-it

also does this need to be an absolute URL? I think we support specifying just the relative path as CLI is aware of the host part of the URL right?

Technically speaking, yes. But as far as I know, we support this anywhere. That's something we could implement for all commands, like spo list get --webUrl "/sites/project-x" ....

milanholemans avatar May 04 '24 21:05 milanholemans

also does this need to be an absolute URL? I think we support specifying just the relative path as CLI is aware of the host part of the URL right?

Technically speaking, yes. But as far as I know, we support this anywhere. That's something we could implement for all commands, like spo list get --webUrl "/sites/project-x" ....

I am not sure this is something we have to implement as I think it is already done for all SPO commands

https://github.com/pnp/cli-microsoft365/blob/3152fc710914e28624817732724d906de2630df0/src/m365/base/SpoCommand.ts#L78

in the example you gave it also works this way as well image

I think there is just no point stating that it is absolute URL in the spec as it may be either this or that

Adam-it avatar May 04 '24 21:05 Adam-it

Aw yeah, totally forgot spo commands transform all URLs by default ๐Ÿ˜Š

milanholemans avatar May 04 '24 21:05 milanholemans

Can I work on this?

MathijsVerbeeck avatar May 06 '24 14:05 MathijsVerbeeck

@pnp/cli-for-microsoft-365-maintainers since this command is an admin command, shouldn't we move this under the spo tenant umbrella?

milanholemans avatar Jun 12 '24 19:06 milanholemans

That's good for me!

Jwaegebaert avatar Jun 13 '24 08:06 Jwaegebaert

@MathijsVerbeeck sorry for the late turnaround, but could you update the PR accordingly?

milanholemans avatar Jun 13 '24 08:06 milanholemans