1

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! :-(

1 Answer 1

1

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()
}
4
  • I am having some 15+ workflows running in my site collection and created the SPD 2013 workflows and created separate tasks and history lists for each workflows. so i dont have the name workflow history in any of these history lists.thats the issue. note: i dont any sub site in my site collec. i have configured root web only in my SPSite.
    – samolpp2
    Commented Jun 23, 2017 at 12:26
  • 1
    can you check the answer now ? Commented Jun 23, 2017 at 12:35
  • i think its $_.BaseTemplate and NOT $_.BaseType. using $_.BaseType in the code , didnt work, but when applied with $_.BaseTemplate, its has worked.
    – samolpp2
    Commented Jun 23, 2017 at 12:51
  • ahh ok, cool glad to know ! Commented Jun 27, 2017 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.