4

enter image description hereI am try to set document set welcome page view with powershell csom with out any luck. Does anyone have an idea how to do it

$password=""
$username=""
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Import-Module Sharegate



$siteUrl = "https://sharepoint.com/sites/projects/"

write-host "Connecting to SharePoint "$siteUrl
$pwd =  convertto-securestring $password -asplaintext -force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $pwd)
$ctx.Credentials = $credentials

$web=$ctx.web;
$ctx.Load($web)
$ctx.ExecuteQuery()
write-host $web.title
$list = $web.Lists.GetByTitle("Documents")
$contentypee=$list.ContentTypes
$ctx.Load($contentypee)
$ctx.Load($list)
$ctx.ExecuteQuery()

 Foreach($ct in $contentypee){
  if($ct.name -eq 'Record'){
     $ctrecord=$ct;
     Write-Host  "list title"  $list.title
     Write-Host  "contenttype name is "  $ctrecord.Name
     Write-Host  "content type id "  $ctrecord.ID
   }
 }
 $ctrecord1=$contentypee.GetById($ctrecord.ID)
 $ctx.Load($ctrecord1)
 $ctx.ExecuteQuery()
  • do you get an error? – ova Aug 23 '16 at 8:56
  • No error, but I can't go further ,don't find any cmdlet like Setwelcomepage or something – Waqas Aug 23 '16 at 9:03
1

Here is technet answer I found of someone trying to achieve the same thing.

In case the link ever goes down, here is the answer in question:

You can certainly do this with PowerShell! You need to dive into the object model a little bit to accomplish this. Please keep in mind that the Welcome page is a relative link to your site.

Say your current site collection welcome page is http://yoursitecollection/Pages/Home.aspx and you want to change it to http://yoursitecollection/Pages/NewWelcomePage.aspx.

$assignment = Start-SPAssignment

$web = Get-SPWeb -Identity "http://yoursitecollectionurl" AssignmentCollection $assignment

$rootFolder = $web.RootFolder

$rootFolder.WelcomePage = "Pages/NewWelcomePage.aspx"

$rootFolder.Update()

Stop-SPAssignment $assignment

Another note - if there are spaces in your .aspx page file name, then simply type spaces (i.e. you don't need to include the url encoded %20 for spaces). For example you could change the line above to:

$rootFolder.WelcomePage = "Pages/New Welcome Page.aspx"

I hope this helps,

Craig

  • Thanks but i am looking for Document-set welcome page view – Waqas Aug 23 '16 at 9:28
  • Apologies, I misread your post in my haste. Could the above work if you changed the context of $rootfolder to that of your document set? – Ray Hogan Aug 23 '16 at 9:37
  • My knowlage is limmited but i dont thing document-set has rootfolder property – Waqas Aug 23 '16 at 10:42
0

Try the following:

  • Get welcome page from document set
  • Get webpart manager from welcome page
  • Get the document list Webpart
  • Set the view on the Webpart

No idea, how you can change the default on the document set configuration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.