Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #environment variables
- $username = "user.name@xxx.com"
- $password = Read-Host -Prompt "Enter your password: " -AsSecureString
- $url = "https://xxx.sharepoint.com/sites/xxxxxx"
- $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
- #add SharePoint Online DLL - update the location if required
- $programFiles = [environment]::getfolderpath("programfiles")
- add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
- # connect/authenticate to SharePoint Online and get ClientContext object..
- $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
- $ctx.Credentials = $credentials
- #get all the sub webs
- $Web = $ctx.Web
- $ctx.Load($web)
- $ctx.Load($web.Webs)
- $ctx.executeQuery()
- Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
- #get all the lists
- foreach ($subweb in $web.Webs)
- {
- $lists = $subweb.Lists
- $ctx.Load($lists)
- $ctx.ExecuteQuery()
- #output the list details
- Foreach ($list in $lists)
- {
- if ($list.ItemCount -gt 5000)
- {
- Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
- Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
- }
- }
- }
- #environment variables
- $username = "user.name@xxxx.com"
- $password = Read-Host -Prompt "Enter your password: " -AsSecureString
- $url = get-content "C:Usersuser.nameDocumentsPowershellScriptssites.txt"
- $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
- #add SharePoint Online DLL - update the location if required
- $programFiles = [environment]::getfolderpath("programfiles")
- add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
- # connect/authenticate to SharePoint Online and get ClientContext object..
- $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
- $ctx.Credentials = $credentials
- #get all the sub webs
- $Web = $ctx.Web
- $ctx.Load($web)
- $ctx.Load($web.Webs)
- $ctx.executeQuery()
- foreach($urls in $url)
- {
- Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
- #get all the lists
- foreach ($subweb in $web.Webs)
- {
- $lists = $subweb.Lists
- $ctx.Load($lists)
- $ctx.ExecuteQuery()
- #output the list details
- Foreach ($list in $lists)
- {
- if ($list.ItemCount -gt 5000)
- {
- Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
- Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
- }
- }
- }
- }
- #environment variables
- $username = "user.name@xxx.com"
- $password = Read-Host -Prompt "Enter your password: " -AsSecureString
- $sites = get-content "C:Usersuser.nameDocumentsPowershellScriptssites.txt"
- $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
- #add SharePoint Online DLL - update the location if required
- $programFiles = [environment]::getfolderpath("programfiles")
- add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
- ForEach($site in $sites) {
- # connect/authenticate to SharePoint Online and get ClientContext object..
- $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($site)
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
- $ctx.Credentials = $credentials
- #get all the sub webs
- $Web = $ctx.Web
- $ctx.Load($web)
- $ctx.Load($web.Webs)
- $ctx.executeQuery()
- Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
- #get all the lists
- ForEach ($subweb in $web.Webs) {
- $lists = $subweb.Lists
- $ctx.Load($lists)
- $ctx.ExecuteQuery()
- #output the list details
- ForEach ($list in $lists) {
- if ($list.ItemCount -gt 5000) {
- Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
- Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment