Skip to content

Instantly share code, notes, and snippets.

@sabique
Created August 20, 2016 08:05
Show Gist options
  • Save sabique/d42eb05cd29e352945c035f31bf80978 to your computer and use it in GitHub Desktop.
Save sabique/d42eb05cd29e352945c035f31bf80978 to your computer and use it in GitHub Desktop.
SharePoint 2010 - Power Shell script to get list of documents from a library
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$sourceWebURL = "http://sp2010/sites/"
$sourceListName = "Library Name"
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
$spSourceItems = $spSourceList.Items | where {$_['Title'] -like "*Lorem*"}
$spSourceItems | ForEach-Object {
Write-Host $_['ID']
Write-Host $_['Name']
}
@sabique
Copy link
Author

sabique commented Aug 20, 2016

Line 6 : Write the URL of your site.
Line 7 : Write the name of your Library
Line 11 : Write the condition for your script.
Line 14 & 15 : Name of the columns you want to fetch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment