Domanda

Nel mio semplice script PowerShell, continuo a ricevere un errore "Eccezione chiamata" RESETROLEINILITANZA ": vi sono modifiche non combinate sull'oggetto SPWEB, chiamare SPWeb.Update () per commettere i cahnges prima di chiamare questo metodo."

Sto tentando di ripristinare tutte le sovvenzioni con autorizzazioni ereditarie in preparazione della pulizia delle autorizzazioni per i nostri teamsiti.Dove dovrei posizionare SPWEB.UPDATE () nel seguente codice?

$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()
.

È stato utile?

Soluzione

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()

Altri suggerimenti

Ero stanco di affrontare questo problema, quindi ho avuto attorno ad esso accompagnando ogni spweb individualmente, utilizzando un elenco di URL come un array string.Qualcosa del genere:

$urls = (Get-SPWeb "http://<site collection>/<subsite>/").webs | select -exp url
.

(Copia e incolla gli URL da / dal file di testo alla nuova sessione PowerShell)

# 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() }
.

Probabilmente non è una grande soluzione per gli script automatizzati ma mi ha preso sulla linea.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top