Friday, 27 April 2018

Get All items in SharePoint List Using PowerShell


Get All items from List or Library Using Power Shell.

# Add below Reference if your using Power shell ISE  
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

# Web Url
 $WebUrl="https://My web/"
 $Web = Get-SPWeb -Identity $WebUrl

# List Name
 $ListName ="PROJECT MANAGEMENT"

# Try to get List
 $List = $web.Lists.TryGetList($ListName)

#Get Count of Items
 Write-Host "  No of item: " $list.Items.Count 
 foreach($Item in $list.Items)
 {
   # Here you can iterate Item , Such as i required URL for Each item
    Write-Host $Item.Url
 }

or 

 $WebUrl="https://cdms.pr1ma.my/dev1/jhr/P-JHR-2014-00073"
 $Web = Get-SPWeb -Identity $WebUrl
# Get List Name
 $ListItems = $Web.lists["PROJECT MANAGEMENT"]
#Get Formated Resutls

 $ListItems.items | format-table -property title,url

Wednesday, 25 April 2018

Get All Site Collections & all Site in Web application using Powershell

How to Get all site Collections in SharePoint Web Application


Add-PSSnapIn "Microsoft.SharePoint.Powershell"
$SiteCollection= get-spsite -limit all -WebApplication https://Server

foreach($Site in $SiteCollection)
{
    foreach($web in $Site.AllWebs)
       {
        Write-Host $web.url
      }
     
}

More details: https://docs.microsoft.com/en-us/sharepoint/sites/view-all-site-collections