pnp/cli-microsoft365

New command: `spo tenant site unarchive`

Closed this issue Β· 11 comments

Usage

m365 spo tenant 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 tenant site unarchive --url "https://contoso.sharepoint.com/sites/Marketing"

Unarchive a specific site collection without confirmation prompt

m365 spo tenant 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

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?
* 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).

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?

* 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πŸ‘

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" ....

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

options[optionName] = auth.connection.spoUrl + optionValue;

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

Aw yeah, totally forgot spo commands transform all URLs by default 😊

Can I work on this?

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

That's good for me!

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