0

i am currently wanting to update the "ShowSortOptions" & "ShowLanguageOptions" via Powershell l have filter with the correct web part using

$Webpart = $WebPartManager.WebParts | Where { $_.Title -eq $TitleofWebPart}

I then use the following :

$Webpart.ShowSortOptions = "False"

$Webpart.ShowLanguageOptions = "False"

But the property doesn't change when l save the changes, but when l go manually to the web part and change it via that route it changes and when l view the property in PS it shows the updated one.

1

You have to call the SaveChanges method of the WebPartManager. For example:

$Webpart = $WebPartManager.WebParts | Where { $_.Title -eq $TitleofWebPart}
$Webpart.ShowSortOptions = "False"
$Webpart.ShowLanguageOptions = "False"
$WebPartManager.SaveChanges($Webpart)
9
  • Hi Sorry yes l am doing that – John Smith Jan 29 '20 at 17:57
  • Are you logging into the UI with a different account that you are executing powershell under? If so, make sure the powershell account doesn't still have the page checked out. – willman Jan 29 '20 at 17:58
  • Hi same account, l check out the page in PS $page.CheckOut() make the change then check back in and publish – John Smith Jan 29 '20 at 18:02
  • Are there potentially "closed" webparts on the page with the same Title? – willman Jan 29 '20 at 18:04
  • 1
    $webpart.ShowSortOptions = $false – willman Jan 29 '20 at 18:28

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.