Home

PowerShell script to export SharePoint Usage in CSV format used to Audit an Office 365 Tenant

%3CLINGO-SUB%20id%3D%22lingo-sub-357535%22%20slang%3D%22en-US%22%3EPowerShell%20script%20to%20export%20SharePoint%20Usage%20in%20CSV%20format%20used%20to%20Audit%20an%20Office%20365%20Tenant%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-357535%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20I%20published%20the%20Exchange%20Audit%20script%20last%20time%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20title%3D%22PowerShell%20script%20to%20export%20Exchange%20Usage%20in%20CSV%20format%20used%20to%20Audit%20an%20Office%20365%20Tenant%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FExchange%2FPowerShell-script-to-export-Exchange-Usage-in-CSV-format-used-to%2Fm-p%2F356287%23M3063%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EPowerShell%20script%20to%20export%20Exchange%20Usage%20in%20CSV%20format%20used%20to%20Audit%20an%20Office%20365%20Tenant%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20question%20is%20similar%20for%20SharePoint%20part%20of%20Office%20365%20tenant.%3C%2FP%3E%0A%3CP%3ESo%20I%20wrote%20that%20script%20to%20export%20in%20CSV%20format%20a%20figure%20about%20SharePoint%20usage%20into%20an%20Office%20365%20Tenant.%3C%2FP%3E%0A%3CP%3EIt%20will%20loop%20by%20Site%20collection%20and%2C%20depending%20of%20the%20permission%2C%20subsites%20to%20extract%20size%2C%20volume%2C%20customization%20(for%20the%20old%20SP%20versions).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%5Bboolean%5D%24DebugGlobalMode%20%3D%20%24True%20%23%24False%0A%5Bstring%5D%24username%20%3D%20%22Admin%40yourtenant.onmicrosoft.com%22%0A%0A%5Bstring%5D%24PwdTXTPath%20%3D%20%22C%3A%5CSECUREDPWD%5CExportedPWD-%24(%24username).txt%22%0A%5Bstring%5D%24CSVFolderReport%20%3D%20%22C%3A%5CSHAREPOINT%5CReports%5C%22%0A%5Bstring%5D%24AdminTenantURL%20%3D%20%22https%3A%2F%2FYourTenant-admin.sharepoint.com%22%0A%0Afunction%20Load-DLLandAssemblies%0A%7B%0A%20%5Bstring%5D%24defaultDLLPath%20%3D%20%22%22%0A%0A%20%23%20Load%20assemblies%20to%20PowerShell%20session%20%0A%0A%20%24defaultDLLPath%20%3D%20%22C%3A%5CProgram%20Files%5CSharePoint%20Online%20Management%20Shell%5CMicrosoft.Online.SharePoint.PowerShell%5CMicrosoft.SharePoint.Client.dll%22%0A%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadFile(%24defaultDLLPath)%0A%0A%20%24defaultDLLPath%20%3D%20%22C%3A%5CProgram%20Files%5CSharePoint%20Online%20Management%20Shell%5CMicrosoft.Online.SharePoint.PowerShell%5CMicrosoft.SharePoint.Client.Runtime.dll%22%0A%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadFile(%24defaultDLLPath)%0A%0A%20%24defaultDLLPath%20%3D%20%22C%3A%5CProgram%20Files%5CSharePoint%20Online%20Management%20Shell%5CMicrosoft.Online.SharePoint.PowerShell%5CMicrosoft.Online.SharePoint.Client.Tenant.dll%22%0A%20%5BSystem.Reflection.Assembly%5D%3A%3ALoadFile(%24defaultDLLPath)%0A%7D%0A%0Afunction%20Get-SPOWebs()%7B%0Aparam(%0A%20%24Url%20%3D%20%24(throw%20%22Please%20provide%20a%20Site%20Collection%20Url%22)%2C%0A%20%24Credential%20%3D%20%24(throw%20%22Please%20provide%20a%20Credentials%22)%0A)%0A%0A%20%24context%20%3D%20New-Object%20Microsoft.SharePoint.Client.ClientContext(%24Url)%0A%20%24context.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24Credential.UserName%2C%24Credential.Password)%0A%20%24context.RequestTimeout%20%3D%201000000%20%23%20milliseconds%0A%20%24web%20%3D%20%24context.Web%0A%20%24context.Load(%24web)%0A%20%24context.Load(%24web.Webs)%0A%20%24context.ExecuteQuery()%0A%20foreach(%24myweb%20in%20%24web.Webs)%0A%20%7B%0A%20%20Get-SPOWebs%20-Url%20%24myweb.Url%20-Credential%20%24Credential%0A%20%20%24myweb%0A%20%7D%0A%7D%0A%0Afunction%20Check-InfoPath-Usage(%24myspoWebSite%2C%20%24myspcontext)%0A%7B%0A%20%5Bstring%5D%24InfotpathStatus%20%3D%20%22%22%0A%20%5Bboolean%5D%24DebugMode%20%3D%20%24false%20%23%24DebugGlobalMode%0A%20%24AllspwebLists%20%3D%20%24myspoWebSite.lists%0A%20%24myspcontext.Load(%24AllspwebLists)%0A%20%24myspcontext.ExecuteQuery()%0A%20Write-Host%20%22%20----------------------------------------------%20%22%0A%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3BInfoPath%3A%22%2C%24(%24myspoWebSite.Id)%2C%20%22-%22%2C%24(%24myspoWebSite.Url)%2C%20%22-%22%2C%24(%24myspoWebSite.Title)%20-ForegroundColor%20Yellow%7D%0A%20foreach(%24myList%20in%20%24AllspwebLists)%0A%20%7B%0A%20%20%24myspcontext.Load(%24myList)%0A%20%20%24myspcontext.ExecuteQuery()%0A%20%20%24listTitle%20%3D%20%24myList.Title%0A%20%20%24listType%20%3D%20%24myList.BaseTemplate%0A%20%20%24listUrl%20%3D%20%24myList.DefaultViewUrl%0A%20%20try%0A%20%20%7B%0A%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20List%20Check%22%2C%20%24listTitle%2C%20%22(%22%2C%20%24listType%2C%20%22)%20at%20WebURL%22%2C%20%24myspoWebSite.url%20-ForegroundColor%20Green%7D%0A%20%20%20if(%24listType%20-eq%20100%20-or%20%24listType%20-eq%20101)%0A%20%20%20%7B%0A%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2070%20-%20listType%3A%22%2C%20%24listType%7D%0A%20%20%20%20%24isSysList%20%3D%20%24myList.IsSystemList%0A%20%20%20%20%24IswebCatalog%20%3D%20%20%24myList.IsCatalog%0A%20%20%20%20%24IsAppList%20%3D%20%20%24myList.IsApplicationList%0A%20%20%20%20%24listForms%20%3D%20%24myList.Forms%0A%20%20%20%20%24myspcontext.Load(%24listForms)%0A%20%20%20%20%24myspcontext.ExecuteQuery()%0A%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2077%20-%20isSysList%3A%22%2C%20%24isSysList%7D%0A%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2078%20-%20IsCatalog%3A%22%2C%20%24IswebCatalog%7D%0A%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2079%20-%20IsApplicationList%3A%22%2C%20%24IsAppList%7D%0A%20%20%20%20if(%24isSysList%20-or%20%24IswebCatalog%20-or%20%24IsAppList)%0A%20%20%20%20%7B%0A%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20System%2C%20Application%20or%20Catalog%20List%20Ignore%22%2C%20%24listTitle%2C%20%22at%20URL%22%2C%20%24myspoWebSite.url%20-ForegroundColor%20Yellow%7D%0A%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%7B%0A%20%20%20%20%20if(%24listType%20-eq%20101)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2088%20-%20listType%3A%22%2C%20%20%24listType%7D%0A%20%20%20%20%20%20if(%24myList.AllowContentTypes)%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2089%20-%20AllowContentTypes%3A%22%2C%20%24myList.AllowContentTypes%7D%0A%20%20%20%20%20%20%20%24contentTyps%20%3D%20%24myList.ContentTypes%0A%20%20%20%20%20%20%20%24myspcontext.Load(%24contentTyps)%0A%20%20%20%20%20%20%20%24myspcontext.ExecuteQuery()%0A%20%20%20%20%20%20%20forEach(%24contType%20in%20%24contentTyps)%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%2097%20-%20contType.Name%3A%22%2C%20%24contType.Name%7D%0A%20%20%20%20%20%20%20%20if(%24contType.Name%20-eq%20%22Form%22)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfoPath%3A%20Found%20in%20Library%22%2C%20%24listTitle%2C%20%22at%20URL%22%2C%20%24myspoWebSite.url%20-ForegroundColor%20Magenta%0A%20%20%20%20%20%20%20%20%20%24InfotpathStatus%20%2B%3D%20%22Infopath%3A%22%2B%20%24myspoWebSite.url%20%2B%22%3B%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%20105%20-%20listType%3A%22%2C%20%24listType%7D%0A%20%20%20%20%20%7D%0A%20%20%20%20%20else%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20forEach(%24listFm%20in%20%24listForms)%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%24listPath%20%3D%20%24listFm.ServerRelativeUrl%0A%20%20%20%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Line%20112%20-%20listPath%3A%22%2C%20%24listPath%7D%0A%20%20%20%20%20%20%20if%20(%24listPath%20-like%20'*displayifs.aspx')%0A%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BInfoPath%3A%20Found%20in%20List%22%2C%20%24listTitle%2C%20%22at%20URL%22%2C%20%24myspoWebSite.url%20-ForegroundColor%20Magenta%0A%20%20%20%20%20%20%20%20%24InfotpathStatus%20%2B%3D%20%22Infopath%3A%22%2B%20%24myspoWebSite.url%20%2B%22%3B%22%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%7D%0A%20%20%7D%0A%20%20catch%0A%20%20%7B%0A%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3BInfopath%3A%20Error%20Check%20for%20list%3A%22%2C%20%20%24listTitle%20-ForegroundColor%20Red%0A%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20%20ErrorMessage%3A%22%2C%20%24_.Exception%20-ForegroundColor%20Red%0A%20%20%7D%0A%20%20%20%20%7D%0A%0A%20return%20%24InfotpathStatus%0A%7D%0A%0Afunction%20Check-SPWorkflow(%24myspoWebSite%2C%20%24myspcontext)%0A%7B%0A%20%5Bstring%5D%24WorkflowStatus%20%3D%20%22%22%0A%20%5Bboolean%5D%24DebugMode%20%3D%20%24false%20%23%24DebugGlobalMode%0A%20%24AllspwebLists%20%3D%20%24myspoWebSite.lists%0A%20%24myspcontext.Load(%24AllspwebLists)%0A%20%24myspcontext.ExecuteQuery()%0A%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3B%20WorkFlow%3A%20%22%2C%24(%24myspoWebSite.Id)%2C%20%22-%22%2C%24(%24myspoWebSite.Url)%2C%20%22-%22%2C%24(%24myspoWebSite.Title)%20-ForegroundColor%20Yellow%7D%0A%20foreach(%24list%20in%20%24AllspwebLists)%0A%20%7B%0A%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3BSPWorkflow%3A%20List%20Check%22%2C%20%24list.Title%2C%20%22%20at%20WebURL%22%2C%20%24myspoWebSite.url%20-ForegroundColor%20Green%7D%0A%20%20try%0A%20%20%7B%0A%20%20%20%24myspcontext.Load(%24list.WorkflowAssociations)%0A%20%20%20%24myspcontext.ExecuteQuery()%0A%20%20%20foreach(%24wfAssociation%20in%20%24list.WorkflowAssociations)%0A%20%20%20%7B%0A%20%20%20%20if(%24DebugMode)%20%7BWrite-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20--%26gt%3BSPWorkflow%3A%20List%20%22%2C%20%24list.Title%2C%20%22-%20Wokflow%3A%22%2C%20%24wfAssociation.Name%20-ForegroundColor%20Magenta%7D%0A%20%20%20%20%24WorkflowStatus%20%2B%3D%20%22%60%22%24(%24list.Title)%60%22%2C%60%22%24(%24wfAssociation.Name)%60%22%2C%60%22%24(%24wfAssociation.TaskListTitle)%60%22%2C%22%0A%20%20%20%20%23%24WorkflowStatus%20%2B%3D%20%22%60%22%24(%24wfAssociation.HistoryListTitle)%60%22%2C%24(%24wfAssociation.Created)%2C%24(%24wfAssociation.Modified)%22%0A%20%20%20%7D%20%20%0A%20%20%7D%0A%20%20catch%0A%20%20%7B%0A%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20--%26gt%3BWorkFlowCHeck%3A%20Error%20Check%20for%20list%3A%22%2C%20%20%24list.Title%20-ForegroundColor%20Red%0A%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%20%20%20%20ErrorMessage%3A%22%2C%20%24_.Exception%20-ForegroundColor%20Red%0A%20%20%7D%0A%20%7D%0A%20return%20%24WorkflowStatus%0A%7D%0A%0Acls%0AWrite-Host%20%22%20----------------------------------------------%20%22%0ALoad-DLLandAssemblies%0AWrite-Host%20%22%20----------------------------------------------%20%22%0A%0A%24secureStringPwd%20%3D%20ConvertTo-SecureString%20-string%20(Get-Content%20%24PwdTXTPath)%0A%24adminCreds%20%3D%20New-Object%20System.Management.Automation.PSCredential%20%24username%2C%20%24secureStringPwd%0A%23%24adminCreds%20%3D%20get-credential%0A%0AConnect-SPOService%20-Url%20%24AdminTenantURL%20-credential%20%24adminCreds%20-ErrorAction%20SilentlyContinue%20-ErrorVariable%20Err%0A%0A%24data%20%3D%20%40()%0A%0A%23Retrieve%20all%20site%20collection%20infos%0A%23%24sitesInfo%20%3D%20Get-SPOSite%20-Limit%2010%20%7C%20Sort-Object%20-Property%20url%20%7C%20Select%20*%0A%23%24sitesInfo%20%3D%20Get-SPOSite%20-Template%20%22STS%230%22%20-Limit%2010%20%7C%20Sort-Object%20-Property%20url%20%7C%20Select%20*%0A%24sitesInfo%20%3D%20Get-SPOSite%20-Limit%20ALL%20%7C%20Sort-Object%20-Property%20url%20%7C%20Select%20*%0A%0A%5Bint%5D%24i%20%3D%201%3B%0A%5Bstring%5D%24CheckInfoPathStatus%20%3D%20%22%22%0A%5Bstring%5D%24CheckWorkFlowStatus%20%3D%20%22%22%0A%24data%20%3D%20%40()%0A%0AWrite-Host%20%22--------------------------------------------------------------------------------------------%22%0A%23Retrieve%20and%20print%20all%20sites%0Aforeach%20(%24site%20in%20%24sitesInfo)%0A%7B%0A%20Write-Host%20%22SiteColl%20Number%3A%22%2C%20%24i%2C%20%22-%20of%3A%22%2C%20%24sitesInfo.Count%3B%0A%20%20%20%20%24i%20%2B%3D%201%3B%0A%20%24RootSiteCreatedDate%20%3D%20get-date%20%221900-01-01%22%0A%20try%0A%20%7B%0A%20%20%24Rootcontext%20%3D%20New-Object%20Microsoft.SharePoint.Client.ClientContext(%24site.Url)%0A%20%20%24Rootcontext.Credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24adminCreds.UserName%2C%24adminCreds.Password)%0A%20%20%24Rootcontext.RequestTimeout%20%3D%201000000%20%23%20milliseconds%0A%20%20%24RootWeb%20%3D%20%24Rootcontext.web%0A%20%20%24Rootcontext.Load(%24RootWeb)%0A%20%20%24Rootcontext.ExecuteQuery()%0A%20%20%24RootSiteCreatedDate%20%3D%20%24RootWeb.Created%0A%20%20%24CheckInfoPathStatus%20%3D%20Check-InfoPath-Usage%20%24RootWeb%20%24Rootcontext%0A%20%20%24CheckWorkFlowStatus%20%3D%20Check-SPWorkflow%20%24RootWeb%20%24Rootcontext%0A%20%7D%0A%20catch%0A%20%7B%0A%20%20Write-host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20Impossible%20to%20get%20the%20RootSite%20%22%20-ForegroundColor%20Red%0A%20%20Write-host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20RootSite%3A%22%2C%20%24site.Url%20-ForegroundColor%20Yellow%0A%20%7D%0A%20%20%0A%20Write-Host%20%22SPO%20Site%20collection%3A%22%2C%20%24site.Url%2C%20%22-%20Title%3A%22%2C%20%24site.Title%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Creation%20Date%3A%22%2C%20%24RootSiteCreatedDate%2C%20%22-%20LastItemModifiedDate%22%2C%20%24site.LastContentModifiedDate%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20External%20Sharing%3A%22%2C%20%24site.SharingCapability%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Site%20Template%20Used%3A%22%2C%20%24site.Template%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Storage%20Quota%3A%22%2C%20%24site.StorageQuota%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Storage%20used%3A%22%2C%20%24site.StorageUsageCurrent%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Storage%20Warning%20Level%3A%22%2C%20%24site.StorageQuotaWarningLevel%0A%20Write-Host%20%22%20%20%20%3D%26gt%3B%20Resource%20Quota%3A%22%2C%20%24site.ResourceQuota%2C%20%22-%20Resource%20used%3A%22%2C%20%24site.ResourceUsageCurrent%0A%0A%20%24SuborRootSite%20%3D%20%22RootSite%22%0A%20%24data%20%2B%3D%20%40(%0A%20%20%5Bpscustomobject%5D%40%7B%0A%20%20SiteCollectionURL%20%3D%20%24site.Url%0A%20%20SiteCollectionTitle%20%3D%20%24site.Title%0A%20%20SPType%20%3D%20%24site.Template%0A%20%20SubsiteURL%20%3D%20%24site.Url%0A%20%20SuborRootSite%20%3D%20%24SuborRootSite%0A%20%20WebTemplate%20%3D%20%24site.Template%0A%20%20WebCreationDate%20%3D%20%24RootSiteCreatedDate%0A%20%20LastItemModifiedDate%20%3D%20%24site.LastContentModifiedDate%0A%20%20ExternalSharingCapability%20%3D%20%24site.SharingCapability%0A%20%20StorageQuotaMB%20%3D%20%24site.StorageQuota%0A%20%20StorageUsageCurrentMB%20%3D%20%24site.StorageUsageCurrent%0A%20%20StorageQuotaWarningLevelMB%20%3D%20%24site.StorageQuotaWarningLevel%0A%20%20ResourceQuota%20%3D%20%24site.ResourceQuota%0A%20%20ResourceUsageCurrent%20%3D%20%24site.ResourceUsageCurrent%0A%20%20DevCustomCreated%20%3D%20%22%22%0A%20%20DevCustomSPWorkflow%20%3D%20%24CheckWorkFlowStatus%0A%20%20DevSPFxCreated%20%3D%20%22%22%0A%20%20DevMSFloworPowerAppsCreated%20%3D%20%22%22%0A%20%20DevInforpathForm%20%3D%20%24CheckInfoPathStatus%0A%20%20%7D%0A%20)%0A%20try%0A%20%7B%0A%20%20%24AllWebs%20%3D%20Get-SPOWebs%20-Url%20%24site.Url%20-Credential%20%24adminCreds%0A%20%20if(%24DebugMode)%20%7B%24AllWebs%20%7C%20%25%7B%20Write-Host%20%22%20%20%20%26gt%3B%26gt%3B%22%2C%20%24_.Title%2C%20%22-%22%2C%20%24_.Url%7D%7D%0A%20%20Write-Host%20%22--------------------------------------------------------------------------------------------%22%0A%0A%20%20foreach(%24mySPWeb%20in%20%24AllWebs)%0A%20%20%7B%0A%20%20%20Write-Host%20%22%20%20%20%20%20%20%20%20%20%26gt%3B%26gt%3B%20Subsite%3A%22%2C%20%24mySPWeb.Url%20-ForegroundColor%20magenta%0A%20%20%20%24CheckInfoPathStatus%20%3D%20Check-InfoPath-Usage%20%24RootWeb%20%24Rootcontext%0A%20%20%20%24CheckWorkFlowStatus%20%3D%20Check-SPWorkflow%20%24RootWeb%20%24Rootcontext%0A%20%20%20%24SuborRootSite%20%3D%20%22SubSite%22%0A%20%20%20%24data%20%2B%3D%20%40(%0A%20%20%20%20%5Bpscustomobject%5D%40%7B%0A%20%20%20%20SiteCollectionURL%20%3D%20%24site.Url%0A%20%20%20%20SiteCollectionTitle%20%3D%20%24site.Title%0A%20%20%20%20SPType%20%3D%20%24site.Template%0A%20%20%20%20SubsiteURL%20%3D%20%24mySPWeb.Url%0A%20%20%20%20SuborRootSite%20%3D%20%24SuborRootSite%0A%20%20%20%20WebTemplate%20%3D%20%24mySPWeb.WebTemplate%0A%20%20%20%20WebCreationDate%20%3D%20%24mySPWeb.Created%0A%20%20%20%20LastItemModifiedDate%20%3D%20%24mySPWeb.LastItemModifiedDate%0A%20%20%20%20ExternalSharingCapability%20%3D%20%24site.SharingCapability%0A%20%20%20%20StorageQuotaMB%20%3D%20%24site.StorageQuota%0A%20%20%20%20StorageUsageCurrentMB%20%3D%20%24site.StorageUsageCurrent%0A%20%20%20%20StorageQuotaWarningLevelMB%20%3D%20%24site.StorageQuotaWarningLevel%0A%20%20%20%20ResourceQuota%20%3D%20%24site.ResourceQuota%0A%20%20%20%20ResourceUsageCurrent%20%3D%20%24site.ResourceUsageCurrent%0A%20%20%20%20DevCustomCreated%20%3D%20%22%22%0A%20%20%20%20DevCustomSPWorkflow%20%3D%20%24CheckWorkFlowStatus%0A%20%20%20%20DevSPFxCreated%20%3D%20%22%22%0A%20%20%20%20DevMSFloworPowerAppsCreated%20%3D%20%22%22%0A%20%20%20%20DevInforpathForm%20%3D%20%24CheckInfoPathStatus%0A%20%20%20%20%7D%0A%20%20%20)%0A%20%20%7D%0A%20%7D%0A%20catch%0A%20%7B%0A%20%20Write-host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20Impossible%20to%20get%20the%20Subsites%20%22%20-ForegroundColor%20Red%0A%20%20Write-host%20%22%20%20%3D%3D%3D%3D%3D%26gt%3B%26gt%3B%26gt%3B%26gt%3B%20RootSite%3A%22%2C%20%24site.Url%20-ForegroundColor%20Yellow%0A%20%7D%0A%0A%7D%20%0A%0A%23Write-Host%20%24data%0A%0A%24datestring%20%3D%20(get-date).ToString(%22yyyyMMdd-hhmm%22)%0A%24CSVFileToExport%20%3D%20Join-Path%20-Path%20%24CSVFolderReport%20%20-ChildPath%20%24(%22SharePoint_%22%2B%20%24datestring%20%2B%20%22.csv%22)%0A%20%0AWrite-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0AWrite-Host%20(%22%20%26gt%3B%26gt%3B%26gt%3B%20writing%20to%20file%20%7B0%7D%22%20-f%20%24CSVFileToExport)%20-ForegroundColor%20Green%0A%24data%20%7C%20Export-csv%20%24CSVFileToExport%20-NoTypeInformation%20-enc%20utf8%20%0AWrite-host%20%22%20-----------------------------------------%22%20-ForegroundColor%20Green%0A%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20transparent%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EYou%20can%20adapt%20that%20script%20as%20you%20need%2C%20based%20on%20your%20own%20requirements%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3EFabrice%20Romelard%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22background-color%3A%20transparent%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3E%3CEM%20style%3D%22box-sizing%3A%20border-box%3B%22%3EFrench%20version%3A%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20white-space%3A%20normal%3B%20box-sizing%3A%20border-box%3B%20orphans%3A%202%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20transparent%3B%22%3E%3CEM%3E%3CA%20title%3D%22http%3A%2F%2Fblogs.developpeur.org%2Ffabrice69%2Farchive%2F2019%2F02%2F27%2Foffice-365-script-powershell-pour-auditer-l-usage-de-sharepoint-online-de-votre-tenant.aspx%22%20href%3D%22http%3A%2F%2Fblogs.developpeur.org%2Ffabrice69%2Farchive%2F2019%2F02%2F27%2Foffice-365-script-powershell-pour-auditer-l-usage-de-sharepoint-online-de-votre-tenant.aspx%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fblogs.developpeur.org%2Ffabrice69%2Farchive%2F2019%2F02%2F27%2Foffice-365-script-powershell-pour-auditer-l-usage-de-sharepoint-online-de-votre-tenant.aspx%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20transparent%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20italic%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20bold%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ESource%20used%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3E%3CSPAN%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-variant%3A%20normal%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20display%3A%20inline%20!important%3B%20white-space%3A%20normal%3B%20orphans%3A%202%3B%20float%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20transparent%3B%22%3E%3CA%20href%3D%22http%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F86842%2Fextract-all-list-names-from-sharepoint-site-to-csv%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F86842%2Fextract-all-list-names-from-sharepoint-site-to-csv%3C%2FA%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CSPAN%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-variant%3A%20normal%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20display%3A%20inline%20!important%3B%20white-space%3A%20normal%3B%20orphans%3A%202%3B%20float%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20transparent%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fcollab365.community%2Fforum%2Ftopics%2Ffind-all-sharepoint-online-sites-with-an-infopath-form-and-determine-if-still-being-used%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcollab365.community%2Fforum%2Ftopics%2Ffind-all-sharepoint-online-sites-with-an-infopath-form-and-determine-if-still-being-used%2F%3C%2FA%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CSPAN%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-variant%3A%20normal%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20display%3A%20inline%20!important%3B%20white-space%3A%20normal%3B%20orphans%3A%202%3B%20float%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20transparent%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F240149%2Fget-the-list-of-all-available-infopath-forms-in-a-sharepoint-site-collection-s%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F240149%2Fget-the-list-of-all-available-infopath-forms-in-a-sharepoint-site-collection-s%3C%2FA%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E%3CSPAN%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-variant%3A%20normal%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20display%3A%20inline%20!important%3B%20white-space%3A%20normal%3B%20orphans%3A%202%3B%20float%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20transparent%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FSharePoint-Online-Get-all-40d76baa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2Foffice%2FSharePoint-Online-Get-all-40d76baa%3C%2FA%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-357535%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAudit%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESites%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUsage%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Frequent Contributor

As I published the Exchange Audit script last time:

The question is similar for SharePoint part of Office 365 tenant.

So I wrote that script to export in CSV format a figure about SharePoint usage into an Office 365 Tenant.

It will loop by Site collection and, depending of the permission, subsites to extract size, volume, customization (for the old SP versions).

 

[boolean]$DebugGlobalMode = $True #$False
[string]$username = "Admin@yourtenant.onmicrosoft.com"

[string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt"
[string]$CSVFolderReport = "C:\SHAREPOINT\Reports\"
[string]$AdminTenantURL = "https://YourTenant-admin.sharepoint.com"

function Load-DLLandAssemblies
{
	[string]$defaultDLLPath = ""

	# Load assemblies to PowerShell session 

	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)

	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)

	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)
}

function Get-SPOWebs(){
param(
	$Url = $(throw "Please provide a Site Collection Url"),
	$Credential = $(throw "Please provide a Credentials")
)

	$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
	$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credential.UserName,$Credential.Password)
	$context.RequestTimeout = 1000000 # milliseconds
	$web = $context.Web
	$context.Load($web)
	$context.Load($web.Webs)
	$context.ExecuteQuery()
	foreach($myweb in $web.Webs)
	{
		Get-SPOWebs -Url $myweb.Url -Credential $Credential
		$myweb
	}
}

function Check-InfoPath-Usage($myspoWebSite, $myspcontext)
{
	[string]$InfotpathStatus = ""
	[boolean]$DebugMode = $false #$DebugGlobalMode
	$AllspwebLists = $myspoWebSite.lists
	$myspcontext.Load($AllspwebLists)
	$myspcontext.ExecuteQuery()
	Write-Host " ---------------------------------------------- "
	if($DebugMode) {Write-Host "         -->InfoPath:",$($myspoWebSite.Id), "-",$($myspoWebSite.Url), "-",$($myspoWebSite.Title) -ForegroundColor Yellow}
	foreach($myList in $AllspwebLists)
	{
		$myspcontext.Load($myList)
		$myspcontext.ExecuteQuery()
		$listTitle = $myList.Title
		$listType = $myList.BaseTemplate
		$listUrl = $myList.DefaultViewUrl
		try
		{
			if($DebugMode) {Write-Host "         -->Infopath: List Check", $listTitle, "(", $listType, ") at WebURL", $myspoWebSite.url -ForegroundColor Green}
			if($listType -eq 100 -or $listType -eq 101)
			{
				if($DebugMode) {Write-Host "            -->Infopath: Line 70 - listType:", $listType}
				$isSysList = $myList.IsSystemList
				$IswebCatalog =  $myList.IsCatalog
				$IsAppList =  $myList.IsApplicationList
				$listForms = $myList.Forms
				$myspcontext.Load($listForms)
				$myspcontext.ExecuteQuery()
				if($DebugMode) {Write-Host "            -->Infopath: Line 77 - isSysList:", $isSysList}
				if($DebugMode) {Write-Host "            -->Infopath: Line 78 - IsCatalog:", $IswebCatalog}
				if($DebugMode) {Write-Host "            -->Infopath: Line 79 - IsApplicationList:", $IsAppList}
				if($isSysList -or $IswebCatalog -or $IsAppList)
				{
					if($DebugMode) {Write-Host "            -->Infopath: System, Application or Catalog List Ignore", $listTitle, "at URL", $myspoWebSite.url -ForegroundColor Yellow}
				}
				else
				{
					if($listType -eq 101)
					{
						if($DebugMode) {Write-Host "            -->Infopath: Line 88 - listType:",  $listType}
						if($myList.AllowContentTypes)
						{
							if($DebugMode) {Write-Host "            -->Infopath: Line 89 - AllowContentTypes:", $myList.AllowContentTypes}
							$contentTyps = $myList.ContentTypes
							$myspcontext.Load($contentTyps)
							$myspcontext.ExecuteQuery()
							forEach($contType in $contentTyps)
							{
								if($DebugMode) {Write-Host "            -->Infopath: Line 97 - contType.Name:", $contType.Name}
								if($contType.Name -eq "Form")
								{
									Write-Host "            -->InfoPath: Found in Library", $listTitle, "at URL", $myspoWebSite.url -ForegroundColor Magenta
									$InfotpathStatus += "Infopath:"+ $myspoWebSite.url +";"
								}
							}
						}
						if($DebugMode) {Write-Host "            -->Infopath: Line 105 - listType:", $listType}
					}
					else
					{
						forEach($listFm in $listForms)
						{
							$listPath = $listFm.ServerRelativeUrl
							if($DebugMode) {Write-Host "            -->Infopath: Line 112 - listPath:", $listPath}
							if ($listPath -like '*displayifs.aspx')
							{
								Write-Host "            -->InfoPath: Found in List", $listTitle, "at URL", $myspoWebSite.url -ForegroundColor Magenta
								$InfotpathStatus += "Infopath:"+ $myspoWebSite.url +";"
							}
						}
					}
				}

			}
		}
		catch
		{
			Write-Host "         -->Infopath: Error Check for list:",  $listTitle -ForegroundColor Red
			Write-Host "             ErrorMessage:", $_.Exception -ForegroundColor Red
		}
    }

	return $InfotpathStatus
}

function Check-SPWorkflow($myspoWebSite, $myspcontext)
{
	[string]$WorkflowStatus = ""
	[boolean]$DebugMode = $false #$DebugGlobalMode
	$AllspwebLists = $myspoWebSite.lists
	$myspcontext.Load($AllspwebLists)
	$myspcontext.ExecuteQuery()
	if($DebugMode) {Write-Host "         --> WorkFlow: ",$($myspoWebSite.Id), "-",$($myspoWebSite.Url), "-",$($myspoWebSite.Title) -ForegroundColor Yellow}
	foreach($list in $AllspwebLists)
	{
		if($DebugMode) {Write-Host "         -->SPWorkflow: List Check", $list.Title, " at WebURL", $myspoWebSite.url -ForegroundColor Green}
		try
		{
			$myspcontext.Load($list.WorkflowAssociations)
			$myspcontext.ExecuteQuery()
			foreach($wfAssociation in $list.WorkflowAssociations)
			{
				if($DebugMode) {Write-Host "                 -->SPWorkflow: List ", $list.Title, "- Wokflow:", $wfAssociation.Name -ForegroundColor Magenta}
				$WorkflowStatus += "`"$($list.Title)`",`"$($wfAssociation.Name)`",`"$($wfAssociation.TaskListTitle)`","
				#$WorkflowStatus += "`"$($wfAssociation.HistoryListTitle)`",$($wfAssociation.Created),$($wfAssociation.Modified)"
			}  
		}
		catch
		{
			Write-Host "         -->WorkFlowCHeck: Error Check for list:",  $list.Title -ForegroundColor Red
			Write-Host "             ErrorMessage:", $_.Exception -ForegroundColor Red
		}
	}
	return $WorkflowStatus
}

cls
Write-Host " ---------------------------------------------- "
Load-DLLandAssemblies
Write-Host " ---------------------------------------------- "

$secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath)
$adminCreds = New-Object System.Management.Automation.PSCredential $username, $secureStringPwd
#$adminCreds = get-credential

Connect-SPOService -Url $AdminTenantURL -credential $adminCreds -ErrorAction SilentlyContinue -ErrorVariable Err

$data = @()

#Retrieve all site collection infos
#$sitesInfo = Get-SPOSite -Limit 10 | Sort-Object -Property url | Select *
#$sitesInfo = Get-SPOSite -Template "STS#0" -Limit 10 | Sort-Object -Property url | Select *
$sitesInfo = Get-SPOSite -Limit ALL | Sort-Object -Property url | Select *

[int]$i = 1;
[string]$CheckInfoPathStatus = ""
[string]$CheckWorkFlowStatus = ""
$data = @()

Write-Host "--------------------------------------------------------------------------------------------"
#Retrieve and print all sites
foreach ($site in $sitesInfo)
{
	Write-Host "SiteColl Number:", $i, "- of:", $sitesInfo.Count;
    $i += 1;
	$RootSiteCreatedDate = get-date "1900-01-01"
	try
	{
		$Rootcontext = New-Object Microsoft.SharePoint.Client.ClientContext($site.Url)
		$Rootcontext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($adminCreds.UserName,$adminCreds.Password)
		$Rootcontext.RequestTimeout = 1000000 # milliseconds
		$RootWeb = $Rootcontext.web
		$Rootcontext.Load($RootWeb)
		$Rootcontext.ExecuteQuery()
		$RootSiteCreatedDate = $RootWeb.Created
		$CheckInfoPathStatus = Check-InfoPath-Usage $RootWeb $Rootcontext
		$CheckWorkFlowStatus = Check-SPWorkflow $RootWeb $Rootcontext
	}
	catch
	{
		Write-host "  =====>>>> Impossible to get the RootSite " -ForegroundColor Red
		Write-host "  =====>>>> RootSite:", $site.Url -ForegroundColor Yellow
	}
		
	Write-Host "SPO Site collection:", $site.Url, "- Title:", $site.Title
	Write-Host "   => Creation Date:", $RootSiteCreatedDate, "- LastItemModifiedDate", $site.LastContentModifiedDate
	Write-Host "   => External Sharing:", $site.SharingCapability
	Write-Host "   => Site Template Used:", $site.Template
	Write-Host "   => Storage Quota:", $site.StorageQuota
	Write-Host "   => Storage used:", $site.StorageUsageCurrent
	Write-Host "   => Storage Warning Level:", $site.StorageQuotaWarningLevel
	Write-Host "   => Resource Quota:", $site.ResourceQuota, "- Resource used:", $site.ResourceUsageCurrent

	$SuborRootSite = "RootSite"
	$data += @(
		[pscustomobject]@{
		SiteCollectionURL = $site.Url
		SiteCollectionTitle = $site.Title
		SPType = $site.Template
		SubsiteURL = $site.Url
		SuborRootSite = $SuborRootSite
		WebTemplate = $site.Template
		WebCreationDate = $RootSiteCreatedDate
		LastItemModifiedDate = $site.LastContentModifiedDate
		ExternalSharingCapability = $site.SharingCapability
		StorageQuotaMB = $site.StorageQuota
		StorageUsageCurrentMB = $site.StorageUsageCurrent
		StorageQuotaWarningLevelMB = $site.StorageQuotaWarningLevel
		ResourceQuota = $site.ResourceQuota
		ResourceUsageCurrent = $site.ResourceUsageCurrent
		DevCustomCreated = ""
		DevCustomSPWorkflow = $CheckWorkFlowStatus
		DevSPFxCreated = ""
		DevMSFloworPowerAppsCreated = ""
		DevInforpathForm = $CheckInfoPathStatus
		}
	)
	try
	{
		$AllWebs = Get-SPOWebs -Url $site.Url -Credential $adminCreds
		if($DebugMode) {$AllWebs | %{ Write-Host "   >>", $_.Title, "-", $_.Url}}
		Write-Host "--------------------------------------------------------------------------------------------"

		foreach($mySPWeb in $AllWebs)
		{
			Write-Host "         >> Subsite:", $mySPWeb.Url -ForegroundColor magenta
			$CheckInfoPathStatus = Check-InfoPath-Usage $RootWeb $Rootcontext
			$CheckWorkFlowStatus = Check-SPWorkflow $RootWeb $Rootcontext
			$SuborRootSite = "SubSite"
			$data += @(
				[pscustomobject]@{
				SiteCollectionURL = $site.Url
				SiteCollectionTitle = $site.Title
				SPType = $site.Template
				SubsiteURL = $mySPWeb.Url
				SuborRootSite = $SuborRootSite
				WebTemplate = $mySPWeb.WebTemplate
				WebCreationDate = $mySPWeb.Created
				LastItemModifiedDate = $mySPWeb.LastItemModifiedDate
				ExternalSharingCapability = $site.SharingCapability
				StorageQuotaMB = $site.StorageQuota
				StorageUsageCurrentMB = $site.StorageUsageCurrent
				StorageQuotaWarningLevelMB = $site.StorageQuotaWarningLevel
				ResourceQuota = $site.ResourceQuota
				ResourceUsageCurrent = $site.ResourceUsageCurrent
				DevCustomCreated = ""
				DevCustomSPWorkflow = $CheckWorkFlowStatus
				DevSPFxCreated = ""
				DevMSFloworPowerAppsCreated = ""
				DevInforpathForm = $CheckInfoPathStatus
				}
			)
		}
	}
	catch
	{
		Write-host "  =====>>>> Impossible to get the Subsites " -ForegroundColor Red
		Write-host "  =====>>>> RootSite:", $site.Url -ForegroundColor Yellow
	}

} 

#Write-Host $data

$datestring = (get-date).ToString("yyyyMMdd-hhmm")
$CSVFileToExport = Join-Path -Path $CSVFolderReport  -ChildPath $("SharePoint_"+ $datestring + ".csv")
	
Write-host " -----------------------------------------" -ForegroundColor Green
Write-Host (" >>> writing to file {0}" -f $CSVFileToExport) -ForegroundColor Green
$data | Export-csv $CSVFileToExport -NoTypeInformation -enc utf8 
Write-host " -----------------------------------------" -ForegroundColor Green

You can adapt that script as you need, based on your own requirements

 

Fabrice Romelard

 

French version:

Source used:

 

Related Conversations
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Edge insider Dev bypasses IE mode website list
HotCakeX in Enterprise on
4 Replies