Skip to content

Commit bd0beea

Browse files
Update README.md
1 parent 10bc454 commit bd0beea

File tree

1 file changed

+57
-1
lines changed
  • Lists and Libraries Management/Get the number of files and folders in library

1 file changed

+57
-1
lines changed
Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
.
1+
Powershell script for getting the number of items, folders and files in a given SharePoint Online library.
2+
3+
4+
5+
The script requires SharePoint Online SDK.
6+
7+
8+
9+
In order to use it, download, open and edit the file:
10+
11+
12+
13+
```PowerShell
14+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
15+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
16+
17+
18+
19+
$Username="test@tenant.onmicrosoft.com"
20+
$Url = "https://tenant.sharepoint.com/sites/test"
21+
$ListTitle = "noci"
22+
$Password = Read-Host -Prompt "Enter password" -AsSecureString
23+
```
24+
25+
26+
If you want to see a division between files and folders, uncomment the following part of the code:
27+
28+
29+
30+
```PowerShell
31+
32+
<# Uncomment if you want to see the split between files and folders
33+
34+
$NoOfFiles=0
35+
$NoOfFolders=0
36+
37+
foreach($item in $listItems)
38+
{
39+
if($item.FileSystemObjectType -eq "File")
40+
{
41+
$NoOfFiles++;
42+
}
43+
if($item.FileSystemObjectType -eq "Folder")
44+
{
45+
$NoOfFolders++;
46+
}
47+
}
48+
49+
Write-Host "Total number of items: " $list.ItemCount
50+
Write-Host "Number of files:" $NoOfFiles
51+
Write-Host "Number of folders:" $NoOfFolders
52+
53+
#>
54+
```
55+
Expected results will display the total number of items, number of files, and number of folders:
56+
57+

0 commit comments

Comments
 (0)