PowerShell to Search SharePoint and Export Results to CSV using Keyword Query
Requirement: Search SharePoint site and export the search results to CSV file using PowerShell.
PowerShell to Export SharePoint Search Results to CSV:
Here is the PowerShell to search all documents in a SharePoint Online site collection and export search results to CSV.
Here is how to search SharePoint Online using Keyword query: PowerShell to Search SharePoint Online Site using Keyword Query
PowerShell to Export SharePoint Search Results to CSV:
Here is the PowerShell to search all documents in a SharePoint Online site collection and export search results to CSV.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set Parameters $SiteURL = "http://intranet.crescent.com/" $CSVFile = "C:\Temp\SearchResults.csv" #Get the site collection $Site = Get-SPSite $SiteURL #Frame Query to search: Get all documents sorted by Last modified $keywordQuery = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($Site) $SearchQuery = "site:http://intranet.crescent.com ContentType:document NOT FileExtension:aspx" $keywordQuery.QueryText = $SearchQuery $keywordQuery.SortList.Add("LastModifiedTime","Asc") #Execute Search $SearchExecutor = New-Object Microsoft.Office.Server.Search.Query.SearchExecutor $searchResults = $SearchExecutor.ExecuteQuery($keywordQuery) #Get Search Results $Table = $SearchResults.Table $Table | select Title, Path, Author, LastModifiedTime #Export Search results to Excel $Table | Export-Csv $CSVFile -NoTypeInformation Write-Host -f Green "Search Results Exported to CSV File!"and the result CSV:
Here is how to search SharePoint Online using Keyword query: PowerShell to Search SharePoint Online Site using Keyword Query
PowerShell to Search SharePoint and Export Results to CSV using Keyword Query
Reviewed by Salaudeen Rajack
on
February 03, 2018
Rating:

No comments:
Please Login and comment to get your questions answered!