Share via

SharePoint Online PowerShell Get-File Sensitivity LabelInfo.csv Extraction and Return Results.

김현태 1 Reputation point
2023-01-09T09:13:38.167+00:00

hi

SharePoint Online PowerShell Get-File Sensitivity LabelInfo.csv Extraction and Return Results.

We would like to ask you about how to extract files with multiple sensitivity labels into a .csv file by proceeding with the current Get-FileSensitivityLabelInfo command, and how to ensure that the results appear together when extracted with .csv.

thank you

Microsoft 365 and Office | SharePoint | For business | Windows

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 51,986 Reputation points Microsoft External Staff
    2023-01-10T10:41:32.107+00:00

    @김현태

    Based on your description, I understand that you want to get file sensitivity label information into csv file.

    Per my research, you could use PowerShell to list any excel and word documents with sensitivity label in a folder copied by SharePoint Online or OneDrive.

    Report = @()
    $Files = (Get-ChildItem -Path "c:\temp\" -Include *.docx, *.xlsx -Recurse)
    ForEach ($F in $Files) {
    $FileName = "C:\Temp\" + $F.Name
    $TemplateName = $Null
    $Status = (Get-AipFileStatus -Path $FileName)
     If ($Status.IsLabeled -ne $False) {
     If ($Status.RmsTemplateId -ne $Null) {
        $TemplateId = [GUID]($Status.RMSTemplateId)
        $TemplateName = (Get-RMSTemplate -Identity $TemplateId.Guid ErrorAction SilentlyContinue ).Name }
        $ReportLine = [PSCustomObject]@{
             File        = $F.Name
             IsLabeled   = $Status.IsLabeled
             LabelId     = $Status.MainLabelId
             Label       = $Status.MainLabelName
             Date        = $Status.LabelDate
             RMSGuid     = $Status.RMSTemplateId
             RMSTemplate = $TemplateName
             Owner       = $Status.RMSOwner }
     $Report += $ReportLine
    }}
    $Report | Export-CSV -NoTypeInformation c:\Temp\LabeledFiles.csv
    

    Reference: https://office365itpros.com/2018/11/19/reporting-protected-files/

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.