<#
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 8th Feb - 2017
Description -> This Script will delete all Associated Workflows across site collection level from lists & document libraries.
Site Collection Name --> "https://ms.contoso.net/global/contososs"
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# get site collection name
$Site = Get-SPSite "https://msd.contoso.net/sites/test"
# loop through All subsites at Site Collection Level
foreach($Web in $Site.AllWebs)
{
# Loop through all lists at sites level
foreach($list in $Web.Lists)
{
# Check Associtaed Workflow through all sub sites
foreach($Wf in $list.WorkflowAssociations)
{
Write-Host $wf.id
# Checking the workflow in list
if($Wf -ne "")
{
# Removing the workflow across Site collection level from lists & document library
$list.WorkflowAssociations.Remove($wf.id)
$list.update()
}
}
}
}
******-----------------------------------------------------------------------******
Author -> Shiv Mangal Singh
Date -> 8th Feb - 2017
Description -> This Script will delete all Associated Workflows across site collection level from lists & document libraries.
Site Collection Name --> "https://ms.contoso.net/global/contososs"
******-----------------------------------------------------------------------******
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# get site collection name
$Site = Get-SPSite "https://msd.contoso.net/sites/test"
# loop through All subsites at Site Collection Level
foreach($Web in $Site.AllWebs)
{
# Loop through all lists at sites level
foreach($list in $Web.Lists)
{
# Check Associtaed Workflow through all sub sites
foreach($Wf in $list.WorkflowAssociations)
{
Write-Host $wf.id
# Checking the workflow in list
if($Wf -ne "")
{
# Removing the workflow across Site collection level from lists & document library
$list.WorkflowAssociations.Remove($wf.id)
$list.update()
}
}
}
}
No comments:
Post a Comment