I'm using a script for setting an audience group for a navigation node in SharePoint. When I set the group It's no problem, or it sets the group but the settings is never pushed through. But If I edit the node in the GUI and just press OK (on both the node settings and navigation settings) the changes goes through.
Script:
$FindString = "Custom link"
Get-SPSite "http://dev:18792/sites/devsite/" | Get-SPWeb -Limit ALL | ForEach-Object {
$web = $_
$_.Navigation.QuickLaunch | ForEach-Object {
$_.Children | ForEach-Object {
if($_.title -eq $FindString){
$node = $_
$node.Properties["Audience"] = "Custom group"
$node.Update()
}
}
}
$web.Update()
}
Am I using the Updates in the wrong place?
EDIT: "SharePoint Server Publishing Infrastructure" feature is activated on the site collection.
Solved it by adding ;;;; before the group name.
$node.Properties["Audience"] = ";;;;Custom group"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.