вторник, 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 августа.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#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 = "<view><query><where><gt><fieldref name="Modified"><value includetimevalue="TRUE" type="DateTime">2020-07-31T14:48:24Z</value></fieldref></gt></where></query></view>"
 
            $addItems = $List.GetItems($camlQuery)
                     
 
            $camlQuery = [Microsoft.SharePoint.Client.CamlQuery]::new(); 
            $camlQuery.ViewXml =  "<view><query><where><gt><fieldref name="Created"><value includetimevalue="TRUE" type="DateTime">2020-07-31T14:48:24Z</value></fieldref></gt></where></query></view>"
 
            $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


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

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