вторник, 6 октября 2020 г.

Получение всех рабочих процессов WorkFlow 2010 в tenant

 Я упустил новость о том, что WorkFlow 2010 будут отключены и только недавно увидел сообщение

Starting 11/1/2020 6:00:00 AM, SharePoint 2010 workflows will be retired and users will no longer have the ability to run or create 2010 Workflows. 


SharePoint Modernization Scanner  у меня так и не завелся.
возникала аналогичная ошибка https://github.com/pnp/sp-dev-modernization/issues/524 

тогда решил сам найти все активные WorkFlow. Так же выводится информация количестве всех элементов списка, так же созданных и измененых с 1 августа.


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll"


$UserName = "adm@company.com"
$Cred= Get-Credential $UserName


$SiteUrl = "https://contoso.sharepoint.com" #tenant

$array = @()  

function GetSubWebs($sWeb){    
            
    $Ctx.Load($sWeb)

    $WorkflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($Ctx, $sWeb)
    $WorkflowSubscriptionService = $workflowServicesManager.GetWorkflowSubscriptionService()

    $allLists = $sWeb.Lists
    $Ctx.Load($allLists)
    $Ctx.ExecuteQuery()

    $webUrl = $sWeb.Url

    foreach($list in $allLists){
        $list.Title               
       
        $listTitle = $list.Title

        $List = $sWeb.Lists.GetByTitle($listTitle)
        $Ctx.Load($List)
        $WFassociation =  $List.WorkflowAssociations

        $Ctx.Load($WFassociation)
        $Ctx.ExecuteQuery() 

        $wfCount = 0
        foreach($wf in $WFassociation){
            if($wf.Enabled -eq $true){
                $wfCount++

            }
        }


        if($wfCount -gt 0){
            $wfCount

            $allItemCount = $List.ItemCount
            $camlQuery = [Microsoft.SharePoint.Client.CamlQuery]::new();  
            $camlQuery.ViewXml = "2020-07-31T14:48:24Z"

            $addItems = $List.GetItems($camlQuery)
                    

            $camlQuery = [Microsoft.SharePoint.Client.CamlQuery]::new();  
            $camlQuery.ViewXml =  "2020-07-31T14:48:24Z"

            $modyItems = $List.GetItems($camlQuery)                    

                   
            $Ctx.Load($addItems )
            $Ctx.Load($modyItems )


            $Ctx.ExecuteQuery()
                 
            $modyItemsCount = $modyItems.Count
            $addItemsCount = $addItems.Count

            $object = New-Object PSObject

            $object | Add-Member -Name 'Title' -MemberType Noteproperty -Value $listTitle
            $object | Add-Member -Name 'All Items' -MemberType Noteproperty -Value $allItemCount
            $object | Add-Member -Name 'Add Items' -MemberType Noteproperty -Value $addItemsCount 
            $object | Add-Member -Name 'Modified Items' -MemberType NoteProperty -Value  $modyItemsCount
            $object | Add-Member -Name 'WF Count' -MemberType NoteProperty -Value  $wfCount
            $object | Add-Member -Name 'URL' -MemberType NoteProperty -Value $webUrl

                     
            $Global:array += $object
        }
    }

    $webs= $sWeb.Webs
    $Ctx.Load($webs)
    $Ctx.ExecuteQuery()
    if($webs.Count -gt 0)
    {
        Write-Host $aWeb.Url  " - " $aWeb.Webs.Count
         
        foreach($aWeb in $webs)
        {
        
            $Ctx.Load($aWeb)
           
            GetSubWebs $aWeb 
        }
    }

    
}

$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
     

    
$Web = $Ctx.Web
$Ctx.Load($Web)
$webs= $Web.Webs
GetSubWebs($Web)

$array | Format-Table

$array | Export-Csv -NoTypeInformation -Path  C:\Temp\lists.csv  -encoding "utf8" -Delimiter ";"
На выходе таблица и можно экспортировать в csv


Комментариев нет:

Отправить комментарий