Share via


콘텐츠 검색을 사용하여 사용자 목록에 대 한 사서함 및 비즈니스용 OneDrive 검색

보안 & 규정 준수 PowerShell은 시간이 많이 걸리는 eDiscovery 관련 작업을 자동화할 수 있는 여러 cmdlet을 제공합니다. 현재 Microsoft Purview 규정 준수 포털 콘텐츠 검색을 만들어 많은 수의 보유자 콘텐츠 위치를 검색하려면 시간과 준비가 필요합니다. 검색을 만들기 전에 각 비즈니스용 OneDrive 사이트의 URL을 수집한 다음 각 사서함과 비즈니스용 OneDrive 사이트를 검색에 추가해야 합니다. 향후 릴리스에서는 규정 준수 포털에서 더 쉽게 수행할 수 있습니다. 그때까지 이 문서의 스크립트를 사용하여 이 프로세스를 자동화할 수 있습니다. 이 스크립트는 organization MySite 도메인의 이름(예: URLhttps://contoso-my.sharepoint.comcontoso), 사용자 이메일 주소 목록, 새 콘텐츠 검색의 이름 및 사용할 검색 쿼리를 묻는 메시지를 표시합니다. 스크립트는 목록의 각 사용자에 대한 비즈니스용 OneDrive URL을 가져오고 사용자가 제공한 검색 쿼리를 사용하여 목록의 각 사용자에 대해 사서함 및 비즈니스용 OneDrive 사이트를 검색하는 콘텐츠 검색을 만들고 시작합니다.

E5 고객이 아닌 경우 90일 Microsoft Purview 솔루션 평가판을 사용하여 조직이 데이터 보안 및 규정 준수 요구 사항을 관리하는 데 도움이 되는 추가 Purview 기능을 살펴보세요. Microsoft Purview 규정 준수 포털 평가판 허브에서 지금 시작하세요. 등록 및 평가판 조건에 대한 세부 정보를 알아봅니다.

사용 권한 및 스크립트 정보

  • 3단계에서 스크립트를 실행하려면 규정 준수 포털에서 eDiscovery Manager 역할 그룹의 멤버이고 SharePoint Online 전역 관리자여야 합니다.

  • 2단계에서 만든 사용자 목록과 3단계의 스크립트를 동일한 폴더에 저장해야 합니다. 그러면 스크립트를 더 쉽게 실행할 수 있습니다.

  • 스크립트에는 최소한의 오류 처리가 포함됩니다. 주요 목적은 각 사용자의 사서함 및 비즈니스용 OneDrive 사이트를 빠르고 쉽게 검색하는 것입니다.

  • 이 항목에 제공된 샘플 스크립트는 Microsoft 표준 지원 프로그램 또는 서비스에서 지원되지 않습니다. 샘플 스크립트는 어떠한 보증도 없이 "있는 그대로" 제공됩니다. 또한 Microsoft는 묵시적인 모든 보증(상품성 또는 특정 목적에의 적합성에 대한 묵시적인 보증을 포함하되 이에 제한되지 않음)을 부인합니다. 샘플 스크립트 및 문서의 사용 또는 수행으로 인해 발생하는 모든 위험은 사용자의 책임입니다. 어떠한 경우에도 Microsoft, 스크립트 작성자 또는 그외 스크립트의 작성, 생산 또는 제공과 관련된 사람은 누구나 샘플 스크립트 또는 문서의 사용 또는 사용할 수 없음으로 인해 발생하는 모든 손해(수익 손실, 비즈니스 중단, 비즈니스 정보 손실 또는 기타 금전상의 손실을 포함하되 이에 제한되지 않음)에 대해 책임지지 않습니다. 이는 Microsoft가 이러한 손해가 발생할 가능성에 대해 알았더라도 마찬가지입니다.

1단계: SharePoint Online 관리 셸 설치

첫 번째 단계는 SharePoint Online 관리 셸을 설치하는 것입니다. 이 절차에서는 셸을 사용할 필요가 없지만 3단계에서 실행하는 스크립트에 필요한 필수 구성 요소가 포함되어 있으므로 셸을 설치해야 합니다. 이러한 필수 구성 요소를 사용하면 스크립트가 SharePoint Online과 통신하여 비즈니스용 OneDrive 사이트에 대한 URL을 가져올 수 있습니다.

SharePoint Online 관리 셸 환경 설정으로 이동하고 1단계 및 2단계를 수행하여 SharePoint Online 관리 셸을 설치합니다.

2단계: 사용자 목록 생성

3단계의 스크립트는 사서함 및 OneDrive 계정에서 사용자 목록을 검색하는 콘텐츠 검색을 만듭니다. 텍스트 파일에 전자 메일 주소를 입력하거나 PowerShell에서 명령을 실행하여 전자 메일 주소 목록을 가져와 파일에 저장할 수 있습니다(3단계에서 스크립트를 저장할 폴더와 동일한 폴더에 있음).

다음은 organization 모든 사용자의 전자 메일 주소 목록을 가져와 라는 Users.txt텍스트 파일에 저장할 수 있는 Exchange Online PowerShell 명령입니다.

Get-Mailbox -ResultSize unlimited -Filter { RecipientTypeDetails -eq 'UserMailbox'} | Select-Object PrimarySmtpAddress > Users.txt

이 명령을 실행한 후 파일을 열고 속성 이름 PrimarySmtpAddress가 포함된 헤더를 제거해야 합니다. 텍스트 파일에는 전자 메일 주소 목록이 포함되어야 하며 그 외에는 아무것도 포함되어야 합니다. 전자 메일 주소 목록 앞이나 뒤의 빈 행이 없는지 확인합니다.

이 단계에서 스크립트를 실행하면 다음 정보를 묻는 메시지가 표시됩니다. 스크립트를 실행하기 전에 이 정보를 준비해야 합니다.

  • 사용자 자격 증명 - 스크립트는 자격 증명을 사용하여 SharePoint Online에 액세스하여 비즈니스용 OneDrive URL을 얻고 보안 & 준수 PowerShell에 연결합니다.

  • MySite 도메인의 이름 - MySite 도메인은 organization 모든 비즈니스용 OneDrive 사이트를 포함하는 도메인입니다. 예를 들어 MySite 도메인의 URL이 https://contoso-my.sharepoint.com인 경우 스크립트에서 MySite 도메인의 이름을 묻는 메시지가 표시되면 를 입력 contoso 합니다.

  • 2단계에서 텍스트 파일의 경로 이름 - 2단계에서 만든 텍스트 파일의 경로 이름입니다. 텍스트 파일과 스크립트가 동일한 폴더에 있는 경우 텍스트 파일의 이름을 입력합니다. 그렇지 않으면 텍스트 파일의 전체 경로 이름을 입력합니다.

  • 콘텐츠 검색의 이름 - 스크립트에서 만들 콘텐츠 검색의 이름입니다.

  • 검색 쿼리 - 콘텐츠 검색과 함께 사용할 검색 쿼리가 만들어지고 실행됩니다. 검색 쿼리에 대한 자세한 내용은 eDiscovery에 대한 키워드 쿼리 및 검색 조건을 참조하세요.

스크립트를 실행하려면

  1. .ps1 파일 이름 접미사를 사용하여 다음 텍스트를 Windows PowerShell 스크립트 파일에 저장합니다(예: SearchEXOOD4B.ps1). 2단계에서 사용자 목록을 저장한 동일한 폴더에 파일을 저장합니다.

    # This PowerShell script will prompt you for the following information:
    #    * Your user credentials
    #    * The name of your organization's MySite domain
    #    * The pathname for the text file that contains a list of user email addresses
    #    * The name of the Content Search that will be created
    #    * The search query string
    # The script will then:
    #    * Find the OneDrive for Business site for each user in the text file
    #    * Create and start a Content Search using the above information
    # Get user credentials
    if (!$credentials)
    {
        $credentials = Get-Credential
    }
    # Get the user's MySite domain name.  We use this to create the admin URL and root URL for OneDrive for Business
    $mySiteDomain = Read-Host "What is your organization's MySite domain?  For example,  'contoso' for 'https://contoso-my.sharepoint.com'"
    $AdminUrl = "https://$mySiteDomain-admin.sharepoint.com"
    $mySiteUrlRoot = "https://$mySiteDomain-my.sharepoint.com"
    # Get other required information
    $inputfile = read-host "Enter the file name of the text file that contains the email addresses for the users you want to search"
    $searchName = Read-Host "Enter the name for the new search"
    $searchQuery = Read-Host "Enter the search query you want to use"
    $emailAddresses = Get-Content $inputfile | where {$_ -ne ""}  | foreach{ $_.Trim() }
    # Connect to Security & Compliance PowerShell
    if (!$s -or !$a)
    {
        Import-Module ExchangeOnlineManagement
        Connect-IPPSSession
    }
    
    # Load the SharePoint assemblies from the SharePoint Online Management Shell
    # To install, go to https://go.microsoft.com/fwlink/p/?LinkId=255251
    if (!$SharePointClient -or !$SPRuntime -or !$SPUserProfile)
    {
        $SharePointClient = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
        $SPRuntime = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
        $SPUserProfile = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
        if (!$SharePointClient)
        {
            Write-Error "SharePoint Online Management Shell isn't installed, please install from: https://go.microsoft.com/fwlink/p/?LinkId=255251 and then run this script again"
            return;
        }
    }
    if (!$spCreds)
    {
        $spCreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credentials.UserName, $credentials.Password)
    }
    # Add the path of the User Profile Service to the SPO admin URL, then create a new webservice proxy to access it
    $proxyaddr = "$AdminUrl/_vti_bin/UserProfileService.asmx?wsdl"
    $UserProfileService= New-WebServiceProxy -Uri $proxyaddr -UseDefaultCredential False
    $UserProfileService.Credentials = $credentials
    # Take care of auth cookies
    $strAuthCookie = $spCreds.GetAuthenticationCookie($AdminUrl)
    $uri = New-Object System.Uri($AdminUrl)
    $container = New-Object System.Net.CookieContainer
    $container.SetCookies($uri, $strAuthCookie)
    $UserProfileService.CookieContainer = $container
    Write-Host "Getting each user's OneDrive for Business URL"
    $urls = @()
    foreach($emailAddress in $emailAddresses)
    {
        try
        {
            $prop = $UserProfileService.GetUserProfileByName("i:0#.f|membership|$emailAddress") | Where-Object { $_.Name -eq "PersonalSpace" }
            $url = $prop.values[0].value
            $furl = $mySiteUrlRoot + $url
            $urls += $furl
            Write-Host "-$emailAddress => $furl"
        }
        catch
        {
            Write-Warning "Could not locate OneDrive for $emailAddress"
        }
    }
    Write-Host "Creating and starting the search"
    $search = New-ComplianceSearch -Name $searchName -ExchangeLocation $emailAddresses -SharePointLocation $urls -ContentMatchQuery $searchQuery
    # Finally, start the search and then display the status
    if($search)
    {
        Start-ComplianceSearch $search.Name
        Get-ComplianceSearch $search.Name
    }
    
  2. Windows PowerShell 열고 2단계에서 스크립트 및 사용자 목록을 저장한 폴더로 이동합니다.

  3. 스크립트를 시작합니다. 예를 들어:

    .\SearchEXOOD4B.ps1
    
  4. 자격 증명을 묻는 메시지가 표시되면 전자 메일 주소와 암호를 입력한 다음 확인을 클릭합니다.

  5. 스크립트에서 메시지가 표시되면 다음 정보를 입력합니다. 각 정보를 입력한 다음 Enter 키를 누릅니 .

    • MySite 도메인의 이름입니다.

    • 사용자 목록이 포함된 텍스트 파일의 경로 이름입니다.

    • 콘텐츠 검색의 이름입니다.

    • 검색 쿼리(콘텐츠 위치의 모든 항목을 반환하려면 이 항목을 비워 둡니다).

    스크립트는 각 비즈니스용 OneDrive 사이트에 대한 URL을 가져오고 검색을 만들고 시작합니다. 보안 & 규정 준수 PowerShell에서 Get-ComplianceSearch cmdlet을 실행하여 검색 통계 및 결과를 표시하거나 규정 준수 포털의 콘텐츠 검색 페이지로 이동하여 검색에 대한 정보를 볼 수 있습니다.