SPWEB 객체의 커밋되지 않은 변경 사항이 변경됩니다
-
10-12-2019 - |
문제
간단한 PowerShell 스크립트에서 "예외 호출"ResetRoyoLeHeritance ": SPWEB 개체에 커밋되지 않은 변경 사항이 있으므로이 메소드를 호출하기 전에 CAHNGE를 커밋하려면 SPWEB.Update ()를 호출하십시오."
팀 사이트에 대한 사용 권한을 정리하기 위해 상속 된 사용 권한으로 모든 하위 사이트를 재설정하려고 시도하고 있습니다.다음 코드에 spweb.update ()를 어디에서 배치해야합니까?
$spWeb = Get-SPWeb "http://<sitecollection>/<subsite>/"
Echo "Resetting Permission Inheritance for Site: $spWeb"
$spWeb.ResetRoleInheritance()
$spWeb.Update()
foreach($subSite in $spWeb.Webs)
{
Echo "Resetting Permission Inheritance for SubSite: $subSite"
$subSite.ResetRoleInheritance()
$subSite.Update()
$subSite.Dispose()
}
$spWeb.Dispose()
. 해결책
This works... for some reason. I have no idea why, really. It most definately could be cleaned up i'm sure as well:
$spWeb = Get-SPWeb "http://<site collection>/<subsite>/"
Echo "Resetting Permission Inheritance for Site: $spWeb"
foreach($subSite in $spWeb.Webs)
{
$subSite.Update()
Echo "Resetting Permission Inheritance for SubSite: $subSite"
$subSite.ResetRoleInheritance()
$subSite.Update()
$subSite.Dispose()
}
$spWeb.ResetRoleInheritance()
$spWeb.Update()
$spWeb.Dispose()
다른 팁
나는이 문제를 다루는 것에 지쳤으므로 URL 목록을 string
배열로 사용하여 각 SPWEB를 개별적으로 가져 와서 주변을 둘러 보았습니다.이와 같은 것 :
$urls = (Get-SPWeb "http://<site collection>/<subsite>/").webs | select -exp url
.
(텍스트 파일에서 /에서 새 PowerShell 세션으로 URL 복사 및 붙여 넣기)
# this is now a brand new SPWeb object each time. to be absolutely sure im not causing the afore-mentioned errors
$urls | foreach { $web = get-spweb $_; $web.resetroleinheritance(); $web.dispose() }
.
아마도 자동화 된 스크립트에 대한 훌륭한 해결책이 아니라 줄을 통해 나를 얻었습니다.
제휴하지 않습니다 sharepoint.stackexchange