Guest User

Untitled

a guest
May 4th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. #environment variables
  2. $username = "user.name@xxx.com"
  3. $password = Read-Host -Prompt "Enter your password: " -AsSecureString
  4. $url = "https://xxx.sharepoint.com/sites/xxxxxx"
  5.  
  6. $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
  7.  
  8. #add SharePoint Online DLL - update the location if required
  9. $programFiles = [environment]::getfolderpath("programfiles")
  10. add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
  11.  
  12. # connect/authenticate to SharePoint Online and get ClientContext object..
  13. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
  14. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
  15. $ctx.Credentials = $credentials
  16.  
  17. #get all the sub webs
  18. $Web = $ctx.Web
  19. $ctx.Load($web)
  20. $ctx.Load($web.Webs)
  21. $ctx.executeQuery()
  22.  
  23. Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
  24.  
  25. #get all the lists
  26. foreach ($subweb in $web.Webs)
  27. {
  28. $lists = $subweb.Lists
  29. $ctx.Load($lists)
  30. $ctx.ExecuteQuery()
  31.  
  32.  
  33. #output the list details
  34. Foreach ($list in $lists)
  35. {
  36. if ($list.ItemCount -gt 5000)
  37. {
  38. Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
  39. Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
  40. }
  41.  
  42.  
  43. }
  44. }
  45.  
  46. #environment variables
  47. $username = "user.name@xxxx.com"
  48. $password = Read-Host -Prompt "Enter your password: " -AsSecureString
  49. $url = get-content "C:Usersuser.nameDocumentsPowershellScriptssites.txt"
  50.  
  51. $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
  52.  
  53. #add SharePoint Online DLL - update the location if required
  54. $programFiles = [environment]::getfolderpath("programfiles")
  55. add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
  56.  
  57. # connect/authenticate to SharePoint Online and get ClientContext object..
  58. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
  59. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
  60. $ctx.Credentials = $credentials
  61.  
  62. #get all the sub webs
  63. $Web = $ctx.Web
  64. $ctx.Load($web)
  65. $ctx.Load($web.Webs)
  66. $ctx.executeQuery()
  67.  
  68.  
  69. foreach($urls in $url)
  70. {
  71. Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
  72. #get all the lists
  73. foreach ($subweb in $web.Webs)
  74. {
  75. $lists = $subweb.Lists
  76. $ctx.Load($lists)
  77. $ctx.ExecuteQuery()
  78.  
  79. #output the list details
  80. Foreach ($list in $lists)
  81. {
  82. if ($list.ItemCount -gt 5000)
  83. {
  84. Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
  85. Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
  86. }
  87.  
  88.  
  89. }
  90. }
  91. }
  92.  
  93. #environment variables
  94. $username = "user.name@xxx.com"
  95. $password = Read-Host -Prompt "Enter your password: " -AsSecureString
  96. $sites = get-content "C:Usersuser.nameDocumentsPowershellScriptssites.txt"
  97.  
  98. $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
  99.  
  100. #add SharePoint Online DLL - update the location if required
  101. $programFiles = [environment]::getfolderpath("programfiles")
  102. add-type -Path $programFiles'SharePoint Online Management ShellMicrosoft.Online.SharePoint.PowerShellMicrosoft.SharePoint.Client.dll'
  103.  
  104. ForEach($site in $sites) {
  105. # connect/authenticate to SharePoint Online and get ClientContext object..
  106. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($site)
  107. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
  108. $ctx.Credentials = $credentials
  109.  
  110. #get all the sub webs
  111. $Web = $ctx.Web
  112. $ctx.Load($web)
  113. $ctx.Load($web.Webs)
  114. $ctx.executeQuery()
  115.  
  116. Write-Host -ForegroundColor Yellow "There are:" $web.Webs.Count "sub webs in this site collection"
  117. #get all the lists
  118. ForEach ($subweb in $web.Webs) {
  119. $lists = $subweb.Lists
  120. $ctx.Load($lists)
  121. $ctx.ExecuteQuery()
  122.  
  123. #output the list details
  124. ForEach ($list in $lists) {
  125. if ($list.ItemCount -gt 5000) {
  126. Write-Host -ForegroundColor Yellow "The site URL is" $subweb.Url
  127. Write-Host "List title is: " $list.Title". This list has: " $list.ItemCount " items"
  128. }
  129. }
  130. }
  131. }
Add Comment
Please, Sign In to add comment