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

# 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


 $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: