是否通过powershell删除每项权限?
我有一个SharePoint列表。在此列表中,每个项目都有自己的用户权限。由于设计更改,我希望删除项目权限,并从列表中返回标准继承权限是否通过powershell删除每项权限?,powershell,sharepoint,Powershell,Sharepoint,我有一个SharePoint列表。在此列表中,每个项目都有自己的用户权限。由于设计更改,我希望删除项目权限,并从列表中返回标准继承权限 因为该列表中有数百项:这可以通过powershell脚本完成吗?你能举个例子吗?在technet找到了解决我问题的方法: ############################################################################### ## ADD IN SHAREPOINT SNAP IN IF NOT A
因为该列表中有数百项:这可以通过powershell脚本完成吗?你能举个例子吗?在technet找到了解决我问题的方法:
###############################################################################
## ADD IN SHAREPOINT SNAP IN IF NOT ALREADY LOADED ##
###############################################################################
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
###############################################################################
## SET VARIABLES FROM ARGUMENTS ##
###############################################################################
$webUrl = $args[0]
$listName = $args[1]
$listInherits = $args[2]
# Varibale to hold document count
$count = 0
###############################################################################
## OPEN OBJECTS & RESTORE INHERITANCE ##
###############################################################################
try {
# Open the web and list objects
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]
# If the list should inherit, reset the role inheritance
if ($listInherits -eq $true) {
$list.ResetRoleInheritance()
Write-Host "Updated permissions on list." -foregroundcolor Green
}
# Get all items with unique permissions
$itemsWithUniquePermissions = $list.GetItemsWithUniquePermissions()
Write-Host $itemsWithUniquePermissions.Count "number of items with unique permissions found."
# Only update items if some exist
if ($itemsWithUniquePermissions.Count -gt 0) {
foreach ($itemInfo in $itemsWithUniquePermissions) {
$item = $list.GetItemById($itemInfo.Id)
$item.ResetRoleInheritance()
$count++
}
# Display number of items updated
Write-Host "Updated permissions on $count items." -foregroundcolor Green
}
else {
Write-Host "No items with unique permissions exist, nothing to update."
}
# Dispose of web object
$web.Dispose()
}
catch [Exception] {
Write-Host "Exception encountered. Please ensure all arguments are valid." -foregroundcolor Red
Write-Host $_.Exception.Message -foregroundcolor Red
}