Monday 28 March 2016

SharePoint2013: PowerShell Script to find data based on column value in list/Library


cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$weburl = "http://YourSite"

$listname = "Your SharePoint List/Library"

$Column = "List/Library Column"

$web = get-spweb $weburl

$list = $web.lists[$listname]

$listItems = $list.Items| where {$_['Your List/Library Column Name'] -eq 'Your List/Library Column value'}

$listItems | ForEach-Object {
   
    Write-Host $_.name
}