社畜の所業

社畜の所業

Microsoft365の機能について解説をしていきたいと思います。このブログの情報をご活用いただければ幸いです。たまに他の情報も取り入れていきたいと思います。

※このサイトはPR記事を含みます。

【Office365参考書】回復可能なアイテム領域のアイテムを抽出するには?

f:id:it-bibouroku:20200305151118j:plain

削除済みアイテムから削除されたアイテムは、回復可能なアイテム領域 (Recoverable Items) に格納され、14 日経過後に完全削除される動作です。 

 

 

it-bibouroku.hateblo.jp

 

  

[コンテンツの検索] にて、回復可能なアイテム領域のアイテムに格納されているアイテムを抽出する方法として、Powershellスクリプトを利用し、FolderId を指定することで可能です。 

  

以下に手順をご案内いたします。 

 

 

 

  

回復可能なアイテム領域 (Recoverable Items) を [コンテンツの検索] にて指定する手順 

  1. ファイル名のサフィックスに .ps1 を使用して、次のテキストを Windows PowerShell スクリプト ファイルに保存します。

※メモ帳に貼り付け、[名前を付けて保存] にて、ファイル名 (例: GetFolderSearchParameters.ps1) と 文字コードを [UTF-8] に変更して、Temp フォルダなどに保存します。 

  

--------------------------------------------------------------------------------------- 

※以下からコピーしてください。 

  

######################################################################################################### 

# This PowerShell script will prompt you for:                                                                # 

#    * Admin credentials for a user who can run the Get-MailboxFolderStatistics cmdlet in Exchange        # 

#      Online and who is an eDiscovery Manager in the Security & Compliance Center.                        # 

# The script will then:                                                                                        # 

#    * If an email address is supplied: list the folders for the target mailbox.                        # 

#    * If a SharePoint or OneDrive for Business site is supplied: list the folder paths for the site.        # 

#    * In both cases, the script supplies the correct search properties (folderid: or path:)                # 

#      appeneded to the folder ID or path ID to use in a Content Search.                                # 

# Notes:                                                                                                # 

#    * For SharePoint and OneDrive for Business, the paths are searched recursively; this means the         # 

#      the current folder and all sub-folders are searched.                                                # 

#    * For Exchange, only the specified folder will be searched; this means sub-folders in the folder        # 

#      will not be searched.  To search sub-folders, you need to use the specify the folder ID for        # 

#      each sub-folder that you want to search.                                                                # 

#    * For Exchange, only folders in the user's primary mailbox will be returned by the script.                # 

######################################################################################################### 

  

# Collect the target email address or SharePoint Url 

$addressOrSite = Read-Host "Enter an email address or a URL for a SharePoint or OneDrive for Business site" 

  

# Authenticate with Exchange Online and the Security & Complaince Center (Exchange Online Protection - EOP) 

if (!$credentials) 

{ 

    $credentials = Get-Credential 

} 

  

if ($addressOrSite.IndexOf("@") -ige 0) 

{ 

    # List the folder Ids for the target mailbox 

    $emailAddress = $addressOrSite 

  

    # Authenticate with Exchange Online 

    if (!$ExoSession) 

    { 

        $ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell-liveid/ -Credential $credentials -Authentication Basic -AllowRedirection 

        Import-PSSession $ExoSession -AllowClobber -DisableNameChecking 

    } 

  

    $folderQueries = @() 

    $folderStatistics = Get-MailboxFolderStatistics $emailAddress 

    foreach ($folderStatistic in $folderStatistics) 

    { 

        $folderId = $folderStatistic.FolderId; 

        $folderPath = $folderStatistic.FolderPath; 

  

        $encoding= [System.Text.Encoding]::GetEncoding("us-ascii") 

        $nibbler= $encoding.GetBytes("0123456789ABCDEF"); 

        $folderIdBytes = [Convert]::FromBase64String($folderId); 

        $indexIdBytes = New-Object byte[] 48; 

        $indexIdIdx=0; 

        $folderIdBytes | select -skip 23 -First 24 | %{$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -shr 4];$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -band 0xF]} 

        $folderQuery = "$($encoding.GetString($indexIdBytes))"; 

  

        $folderStat = New-Object PSObject 

        Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderPath -Value $folderPath 

        Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderQuery -Value $folderQuery 

  

        $folderQueries += $folderStat 

    } 

    Write-Host "-----Exchange Folders-----" 

    $folderQueries |ft 

} 

elseif ($addressOrSite.IndexOf("http") -ige 0) 

{ 

    $searchName = "SPFoldersSearch" 

    $searchActionName = "SPFoldersSearch_Preview" 

  

    # List the folders for the SharePoint or OneDrive for Business Site 

    $siteUrl = $addressOrSite 

  

    # Authenticate with the Security & Complaince Center 

    if (!$SccSession) 

    { 

        $SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $credentials -Authentication Basic -AllowRedirection 

        Import-PSSession $SccSession -AllowClobber -DisableNameChecking 

    } 

  

    # Clean-up, if the the script was aborted, the search we created might not have been deleted.  Try to do so now. 

    Remove-ComplianceSearch $searchName -Confirm:$false -ErrorAction 'SilentlyContinue' 

  

    # Create a Content Search against the SharePoint Site or OneDrive for Business site and only search for folders; wait for the search to complete 

    $complianceSearch = New-ComplianceSearch -Name $searchName -ContentMatchQuery "contenttype:folder" -SharePointLocation $siteUrl 

    Start-ComplianceSearch $searchName 

    do{ 

        Write-host "Waiting for search to complete..." 

        Start-Sleep -s 5 

        $complianceSearch = Get-ComplianceSearch $searchName 

    }while ($complianceSearch.Status -ne 'Completed') 

  

  

    if ($complianceSearch.Items -gt 0) 

    { 

        # Create a Complinace Search Action and wait for it to complete. The folders will be listed in the .Results parameter 

        $complianceSearchAction = New-ComplianceSearchAction -SearchName $searchName -Preview 

        do 

        { 

            Write-host "Waiting for search action to complete..." 

            Start-Sleep -s 5 

            $complianceSearchAction = Get-ComplianceSearchAction $searchActionName 

        }while ($complianceSearchAction.Status -ne 'Completed') 

  

        # Get the results and print out the folders 

        $results = $complianceSearchAction.Results 

        $matches = Select-String "Data Link:.+[,}]" -Input $results -AllMatches 

        foreach ($match in $matches.Matches) 

        { 

            $rawUrl = $match.Value 

            $rawUrl = $rawUrl -replace "Data Link: " -replace "," -replace "}" 

            Write-Host "path:""$rawUrl""" 

        } 

    } 

    else 

    { 

        Write-Host "No folders were found for $siteUrl" 

    } 

  

    Remove-ComplianceSearch $searchName -Confirm:$false -ErrorAction 'SilentlyContinue' 

} 

else 

{ 

    Write-Error "Couldn't recognize $addressOrSite as an email address or a site URL" 

} 

  

※以上となります。 

-------------------------------------------------------------------------- 

 

 上記のテキストは、以下の公開情報からもコピーできます。

 

support.office.com

  

  1. ローカル コンピューターで Windows PowerShell を開き、スクリプトを保存したフォルダーに移動するコマンドレットを入力します。

例: Temp フォルダに保存した場合:\temp\GetFolderSearchParameters.ps1 

  1. [Enter an email address or a URL for a SharePoint or OneDrive for Business site:] と表示されましたら、該当のユーザーのメールアドレスを入力します。
  2. 資格情報の確認が表示されますので、Office 365 の管理者権限のあるログイン ID とパスワードを入力します。
  3. 表示された [Recoverable Items] の [FolderQuery] の値を確認しコピーして控えておきます。

  

上記の手順にて、値を確認したら、以下の手順にてコンテンツの検索を実施します。 

 

 

  

◆1. [検索ルール] を作成する 

管理者へ必要な権限の付与を行った後、検索を行う対象のメールボックスに対して、検索クエリを指定したコンテンツの検索の作成を行い、アイテムの検索や確認を行うといった流れです。 

  

1. 管理者へ必要な権限を付与する 

  1. 管理者にて、Office 365 サービスへサインインします。
  2. Microsoft365 管理センターを開き、画面左ペインの [管理センター] - [Security (セキュリティ)] をクリックします。
  3. セキュリティ/コンプライアンス センターにて、[アクセス許可] をクリックします。
  4. 役割一覧より [eDiscovery Manager] をダブルクリックし、編集画面を表示します。
  5. [電子情報開示管理者] にて、[+] ボタン (追加) より、機能を実行する管理者を追加し [OK] をクリックします。
  6. 画面下の [保存] をクリックします。

  ※反映するまで時間がかかる可能性があります。

  

  

 2. コンテンツの検索の実行手順について 

  1. [eDiscovery Manager] 権限が付与された管理者ユーザーにて、Office 365 にサインインします。
  2. Microsoft365 管理センターを開き、画面左ペインの [管理センター] - [Security (セキュリティ)] をクリックします。

※ 旧 UI をご利用いただく場合には、[切り替え : 以前の UI に戻す] から旧 UI をご利用いただくことも可能です。 

  

  1. [+ 新しい検索] のアイコンをクリックします。
  2. [コンテンツの検索 > 新しい検索] ページで、[検索クエリ] の [キーワード] に [folderid:<確認したFolderQuery>] を入力します。

例 : folderid:4D6DD7F943C29041A65787E30F02AD1F00000000013A0000 

  

  1. [場所 : 選択した場所] 項目にて、[特定の場所] の [変更...] をクリックします。
  2. [場所の変更] 画面より、[ユーザーまたは、グループ、またはチームを選択] をクリックし、検索対象メールボックスを検索し選択します。

※上記の Powershell にて [Enter an email address or a URL for a SharePoint or OneDrive for Business site:] に指定したユーザーを指定します。 

  1. クエリ指定、対象メールボックスの選択後、[保存して実行] をクリックします。
  2. [検索の保存] 画面が表示されますので、[名前] を入力、必要があれば [説明] も入力し [保存] をクリックします。
  3. 手順後、もしくは、対象ルールの [クエリを開く] を選択した場合にプレビューを取得する動作となり、回復可能なアイテム領域 (Recoverable Items) に格納されているメールの一覧が表示されます。
  4. 一覧からメールをクリックすることで内容を閲覧することが可能です。

 

広告

ドメインを購入するならお名前ドットコム

 

高スペックPCが約3万円で購入できます


【楽天年間ランキングでパソコン1位!】初期設定不要!すぐ使える! ノートパソコン 中古 Windows10 Office付き 新品 爆速SSD 中古パソコン Corei5 店長おまかせNECノート 4GB 15インチ 中古ノートパソコン リフレッシュPC