Cli-microsoft365: Enhancement: Extend `spo web set` command with support for setting welcome page

Created on 23 Jul 2020  路  4Comments  路  Source: pnp/cli-microsoft365

Raised from #902

We currently have no option to set the welcome page property of a site, therefore we should introduce a new command called --welcomePage to allow this to be set.

Whilst we do have the ability to now set arbitrary properties on a web using this command following the closure of #1202, setting the WelcomePage property is not possible as it requires an update to the RootFolder resource on the Web object not the Web object directly.

The below PowerShell example shows how this property is set via the REST API.

$headers = @{
  "Authorization" = "Bearer $AccessToken"
  "Accept"        = "application/json;odata=verbose"
  "Content-Type"  = "application/json;odata=verbose"
  "IF-MATCH"      = "*"
  "X-HTTP-METHOD" = "PATCH"
}
$body = @{
  "__metadata"  = @{
      "type" = "SP.Folder"
  }
  "WelcomePage" = "SitePages/MyPage.aspx"
}
$response = Invoke-WebRequest -Method Post -Uri "https://contoso.sharepoint.com/_api/web/rootfolder" -Headers $headers -Body (ConvertTo-Json $body)
enhancement work in progress

Most helpful comment

Hey @garrytrinder - do you mind If I take this up?
Seems like a challenging one than the one I had done before. But I am sure, it is worth it.. 馃憤

All 4 comments

Since the folder belongs to web rather than site, shouldn't we be extending spo web set?

Absolutely, good catch @waldekmastykarz

I have amended the issue title to reflect this.

Hey @garrytrinder - do you mind If I take this up?
Seems like a challenging one than the one I had done before. But I am sure, it is worth it.. 馃憤

It's all yours @arjunumenon.

Thank you for the help 馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waldekmastykarz picture waldekmastykarz  路  3Comments

garrytrinder picture garrytrinder  路  3Comments

VelinGeorgiev picture VelinGeorgiev  路  3Comments

waldekmastykarz picture waldekmastykarz  路  3Comments

joshua-probst picture joshua-probst  路  3Comments