Commands › SharePoint Online
Export-SPOQueryLogs
Export query logs for a user in an Office 365 tenant. > [!NOTE] > Beginning February 2022, we'll be removing the Export-SPOQueryLogs command from SharePoint in Microsoft 365. We encourage users to instead download their Microsoft Search query history logs from the My Account privacy portal.
Quick start script
# Export-SPOQueryLogs — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-SPOService -Url https://$org-admin.sharepoint.com
# 2. Run and inspect
Export-SPOQueryLogs -LoginName <String> | Format-List
# 3. Export for evidence / drift tracking
Export-SPOQueryLogs | Export-Clixml .\SPOQueryLogs-$(Get-Date -Format yyyyMMdd).xml
Syntax
Export-SPOQueryLogs [-StartTime <DateTime>] -LoginName <String> -OutputFolder <String> [<CommonParameters>]
Parameters (3)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.