Muokkaa

Jaa


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.

Syntax

Export-SPOQueryLogs
      [-StartTime <DateTime>]
      -LoginName <String>
      -OutputFolder <String>
      [<CommonParameters>]

Description

Export the query logs for a user in an Office 365 tenant. The result of the export is stored in the current working folder or a specified folder, in the two files loginName_queries.csv and loginName_personalQueries.csv.

The output of the queries.csv will be for example:

QueryTime QueryText
5/31/2018 09:16 Querytext1
5/31/2018 08:16 Querytext2

You have to be a tenant admin to run the cmdlet.

For permissions and the most current information about Windows PowerShell for SharePoint Online, see the online documentation at Intro to SharePoint Online Management Shell.

Examples

------------ Example 1 --------------------

Export-SPOQueryLogs -LoginName user1@contoso.sharepoint.com

Example 1 exports the query log for a user who has the e-mail address user1@contoso.sharepoint.com to the two files user1@contoso.sharepoint.com_queries.csv and user1@contoso.sharepoint.com_personalQueries.csv, in the current working folder.

------------ Example 2 --------------------

Export-SPOQueryLogs -LoginName user1@contoso.sharepoint.com -StartTime "2018-10-21" -OutputFolder "c:\users\contosoadmin\Documents"

Example 2 exports the query log from the starting time 21. October 2018, for a user who has the e-mail address user1@contoso.sharepoint.com, to the two files user1@contoso.sharepoint.com_queries.csv and user1@contoso.sharepoint.com_personalQueries.csv, in the folder c:\users\contosoadmin\Documents.

Parameters

-LoginName

Specifies the login name of the user to export.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-OutputFolder

Target folder where the CSV file is generated.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

-StartTime

Specifies from which point of time to export the logs from. Use the date format YYYY-MM-DD.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Online

Inputs

None

Outputs

System.Object