Find file in SharePoint list by Powershell

11/05/2015 11:20

#Find file / document in sharepoint list by document name

Add-PSSnapin microsoft.sharepoint.powershell
$web = get-spweb 'https://yoursitecollection'
$list = $web.Lists.TryGetList('Your Doc library');

$query = new-object microsoft.sharepoint.spquery;
$query.Query = "<Where><Eq><FieldRef Name='FileLeafRef' /><Value Type='Text'>yourFileName.aspx</Value></Eq></Where>";
$items = $list.GetItems($query)

$item = $items[0];