Pergunta

I want to retrieve all the Workflow History lists from my site collection and break its role inheritance and apply Contribute permissions for a particular custom group and 2 individual users.

I know how to get the normal list using powershell, but the WFHistoy is hidden, i am stuck at accessing through PowerShell.

 Add-PSSnapin Microsoft.SharePoint.PowerShell

 $SiteURL = "http://srvr001:28516"
 $site = Get-SPSite $SiteURL

  #$groups = $site.RootWeb.sitegroups     $COUNGRP= $groups.COUNT

 $w = Get-SPWeb $SiteURL

$mdate=  get-date -f yyyy_MM_dd_HHmm

$w = Get-SPWeb $SiteURL
$list = $w.Lists[$ListName]

$ct = @()

   foreach($singlelist in $w.Lists)
 {
 if($singlelist.BaseTemplate -ne "DocumentLibrary" -and
          $singlelist.Title -contains "History")
  {
   $ctObject = New-Object -TypeName PSObject

   $ctObject | Add-Member -Name 'ListTitle' -MemberType 
    Noteproperty -Value $list.Title                                

  $ct += $ctObject

   Write-Host  $singlelist.Title   + " is the name of the History"
         #" list in qa "
}    }        } 
    $w.dispose()

the above code didnt work for me! :-(

Foi útil?

Solução

Try it as below.

The list template type is WorkflowHistory

# get the site collection

$SiteURL = "http://srvr001:28516"
$site = Get-SPSite $SiteURL

$spSourceWeb = Get-SPWeb $SiteURL

$spSourceLists =  $spSourceWeb.Lists | Where { $_.BaseTemplate -eq "WorkflowHistory" }

$spSourceLists | ForEach-Object {
    #code to break inheritance
    $_.BreakRoleInheritance($true,$true)
    $_.Update()
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top