Changing Web Part properties via powershell
-
08-02-2021 - |
Domanda
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.
Soluzione
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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange