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
$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
";"