Microsoft OneDrive 환경 설정 내보내기

사용자의 Microsoft OneDrive 환경은 사용자가 관심 있는 콘텐츠를 찾고 탐색하는 데 도움이 되는 정보를 저장합니다. 이 정보의 대부분은 다음 표에 나열된 해당 제품 내 기능을 사용하여 최종 사용자가 액세스할 수 있습니다.

환경 저장된 데이터 사용자 액세스
공유 항목 다른 사용자가 사용자와 공유한 문서 목록입니다. 또한 사용자가 다른 사용자와 공유한 문서의 보기를 표시합니다. 이는 사용자가 OneDrive 계정의 항목에 대해 설정한 사용 권한의 보기입니다. 사용자의 OneDrive 계정에서 공유를 선택합니다.
모바일 푸시 알림 구성된 경우 사용자의 OneDrive 및 SharePoint 모바일 앱에 알림을 푸시합니다. 여기에는 공유된 새 파일과 같은 관련 활동이 포함됩니다.
관리자는 새 SharePoint 관리 센터의 설정 페이지에서 이를 관리할 수 있습니다.
팔로우한 사이트 및 콘텐츠 사용자는 사이트, 문서 또는 사용자를 팔로우할 수 있습니다.
팔로우한 사이트는 제품 환경에서 볼 수 있습니다.
SharePoint Home 환경에서 팔로우한 사이트를 보고 관리할 수 있습니다. 이 환경은 최근 사이트 도 보여줍니다.
사용자의 OneDrive 계정에서 설정 기어 아이콘, 사이트 설정, 뉴스 피드를 차례로 선택할 수 있습니다. 오른쪽의 팔로우 중에 있는 적절한 콘텐츠 유형을 클릭할 수 있습니다.
뉴스 피드 팔로우된 콘텐츠, 멘션 및 프로필 변경 내용을 포함한 사용자 활동 목록입니다. 사용자는 제품 내 환경을 사용하여 액세스할 수 있습니다. 사용자의 OneDrive 계정에서 설정 기어 아이콘, 사이트 설정, 뉴스 피드를 차례로 선택할 수 있습니다.
이전에 설명한 사용자 프로필 환경의 일부로 뉴스 피드를 관리할 수 있습니다.
액세스 요청 콘텐츠에 대해 요청된 액세스 목록입니다. 사용자의 OneDrive 계정에서 설정 기어 아이콘, 사이트 설정, 액세스 요청 및 초대를 차례로 선택할 수 있습니다.

관리자는 이 문서의 PnP PowerShellSharePoint Client-Side CSOM(개체 모델) 명령을 사용하여 이러한 목록을 내보낼 수 있습니다. 필요한 모든 CSOM 어셈블리는 SharePointPnPPowerShellOnline Microsoft PowerShell 모듈에 포함되어 있습니다.

이 스크립트는 샘플 스크립트이며 조직의 요구 사항에 맞게 조정할 수 있습니다. 예를 들어 관리자는 다음 절차를 사용하여 에 대한 user1@contoso.com 정보를 추출할 수 있습니다.

  1. 자기 자신에게 사용자의 OneDrive 계정의 관리자 권한을 할당합니다. 이 작업은 Microsoft 365 관리 센터에서 수행할 수 있습니다.

  2. 필요한 Microsoft PowerShell 모듈을 설치합니다.

    Install-Module SharePointPnPPowerShellOnline

    Install-Module CredentialManager

  3. 아래 ExportODBLists PowerShell 스크립트(또는 이 스크립트의 사용자 지정 버전)를 실행합니다.

    $ODBSite = "https://contoso-my.sharepoint.com/personal/user1_contoso_com"

    ExportODBLists.ps1 -siteUrl $ODBSite

스크립트는 이전 표에 설명된 기능에 대해 저장된 데이터를 여러 CSV 파일로 내보냅니다. 관리자는 최종 사용자에게 제공하기 전에 검토하거나 수정할 수 있습니다.

스크립트는 다음 CSV 파일을 만듭니다(해당 목록이 있는 경우). CSV 파일의 이름은 목록의 제목에 해당합니다.

파일 설명
(참조, <id>).csv. 여기서 <id> 는 문자와 숫자의 시퀀스입니다. 사용자와 공유된 항목의 목록
Links.csv 공유 사용자가 생성한 공유 링크의 목록
userActivityFeedHiddenListF4387007-BE61-432F-8BDB-85E6B9679E4B.csv 관련 활동의 목록
notificationSubscriptionHiddenList6D1E55DA-2564-4A22-A5F9-6C4FCAFF53DE.csv 모바일 맵 및 이러한 장치의 앱 ID에 전송되는 알림의 목록
Social.csv 팔로우한 콘텐츠의 목록
MicroFeed.csv 뉴스 피드 항목의 목록
Requests.csv에 액세스 액세스 요청 목록
SharePointHomeCacheList.csv SharePoint Home으로 탐색하는 사용자의 캐시된 데이터입니다. 사용자가 SharePoint Home으로 이동할 때마다 새로 고쳐집니다.

ExportODBLists 스크립트

아래 내용을 복사하여 텍스트 파일에 붙여넣습니다. 파일을 ExportODBLists.ps1로 저장합니다. 스크립트는 매개 변수를 사용하여 대상 목록에서 모든 필드를 내보낼 exportAllFields 수 있습니다. 스크립트는 모든 목록을 내보내고 다른 사이트도 처리하도록 수정할 수 있습니다.

참고

로드되지 않는 어셈블리에 대한 오류가 표시되면 Add-Type 경로 매개 변수에 정의된 대로 최신 버전의 SharePointPnPPowerShellOnline PowerShell 모듈 경로를 다시 확인합니다. 컴퓨터에서 경로가 다를 수 있거나 다른 버전의 모듈을 사용하고 있을 수 있습니다(모듈 버전은 경로의 일부임).

#ExportODBLists
#Exports OneDrive experience settings, stored in several SharePoint lists

param([string]$siteUrl, [bool]$exportAllFields=$false, [bool]$useStoredCreds=$true, [string]$exportFolder)
Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline\2.26.1805.0\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline\2.26.1805.0\Microsoft.SharePoint.Client.Runtime.dll"

if (!$siteUrl)
{
    Write-Host "Please specify a OneDrive site using -siteUrl."
    return
}

if ($useStoredCreds)
{
    Write-Host "Retrieving stored Windows credentials for $siteUrl."
    $cred = Get-StoredCredential -Target $siteUrl
    if (!$cred)
    {
        Write-Host "Didn't find stored credential for $siteUrl. Please provide credentials to connect."
        $cred = Get-Credential
    }
}
else
{
   $cred = Get-Credential
}

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password)
$webURL = $siteUrl
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webURL)
$ctx.Credentials = $credentials

#root folders of lists to export
$SWMRoot = "Reference " #starts with this string
$notificationsRoot = "notificationSubscriptionHiddenList6D1E55DA25644A22"
$activityFeedRoot = "userActivityFeedHiddenListF4387007BE61432F8BDB85E6"
$accessRequestsRoot = "Access Requests"
$microfeedRoot = "PublishedFeed"
$SPHomeCacheRoot = "SharePointHomeCacheList"
$sharingLinksRoot = "Sharing Links"
$socialRoot = "Social"

#list fields to eexport
$SWMFields = @("ID","Created","Modified","Title","RemoteItemPath","OwnerDisplayName","OwnerSipAddress","RemoteItemFileSystemObjectType",
                "RemoteItemCreatorDisplayName","RemoteItemCreatorSipAddress","RemoteItemCreatedDateTime",
                "RemoteItemModifierDisplayName","RemoteItemModifierSipAddress","RemoteItemModifiedDateTime",
                "SWMSharedByDisplayName","SWMSharedBySipAddress","SWMSharedByDateTime",
                "RemoteItemLastAccessedDateTime","RemoteItemServerRedirectedUrl","RemoteItemServerRedirectedEmbedUrl")
$accessRequestsFields = @("ID","Created","Modified","Title","RequestId","RequestedObjectTitle","RequestedObjectUrl","PermissionType","PermissionLevelRequested","RequestDate",
                            "RequestedByDisplayName","RequestedBy","ReqByUser",
                            "RequestedForDisplayName","RequestedFor","ReqForUser",
                            "ApprovedBy","AcceptedBy","Status","Expires","WelcomeEmailSubject","WelcomeEmailBody","ExtendedWelcomeEmailBody","Conversation")
$microfeedFields = @("ID","Created","Modified","Title","MicroBlogType","PostAuthor","RootPostOwnerID","RootPostUniqueID","ReplyCoungett","Order","ContentData")
$notificationsFields = @("ID","Created","Modified","Title","SubscriptionId","PoolName","SecondaryPoolName","AppType","NotificationHandle",
                            "SecondsToExpiry","DestinationType","SubmissionDateTime","ExpirationDateTime","Locale","DeviceId","HostName","NotificationCounter",
                            "SingleSignOutKey","NotificationScenarios","ComplianceAssetId","AppAuthor","AppEditor")
$SPHomeCacheFields = @("ID","Created","Modified","Author","Editor","Title","Value")
$sharingLinksFields = @("ID","Created","Modified","Title","SharingDocId","ComplianceAssetId","CurrentLink","AvailableLinks")
$socialFields = @("ID","Created","Modified","Author","Editor","Title","Url","Hidden","HasFeed","SocialProperties")
$activityFeedFields = @("ID","Created","Modified","Title","ActivityId","ItemId","PushNotificationsSent","EmailNotificationSent","IsActorActivity","IsRead","Order",
                        "ItemChildCount","FolderChildCount","ActivityEventType","ActivityEvent")


#get lists in the web
try{
    $lists = $ctx.web.Lists
    $ctx.load($lists)
    $ctx.executeQuery()
}
catch{
    write-host "$($_.Exception.Message)" -foregroundcolor red
}


#identify the lists to export
$listsToExport = @()
foreach($list in $lists)
{
    $ctx.load($list)
    $ctx.load($list.RootFolder)
    $ctx.executeQuery()
    $listTitle = [string]$list.Title
    $listRoot = $list.RootFolder.Name

    Write-host ("Processing List: " + $list.Title + " with " + $list.ItemCount + " items").ToUpper() -ForegroundColor Yellow
    Write-host (">> List Root Folder: " + $listRoot) -ForegroundColor Yellow

    if ($listRoot.StartsWith($SWMRoot,"CurrentCultureIgnoreCase") -and $list.ItemCount -ge 1)
    {
        Write-Host ">> Found: Shared With Me List" -ForegroundColor Green
        $listDetails = @{listType = "Shared With Me List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $SWMFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $notificationsRoot)
    {
        Write-Host ">> Found: Notifications List" -ForegroundColor Green
        $listDetails = @{listType = "Notifications List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $notificationsFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $activityFeedRoot)
    {
        Write-Host ">> Found: User Activity Feed List" -ForegroundColor Green
        $listDetails = @{listType = "User Activity Feed List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $activityFeedFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $accessRequestsRoot)
    {
        Write-Host ">> Found: Access Requests List" -ForegroundColor Green
        $listDetails = @{listType = "Access Requests List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $accessRequestsFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $microfeedRoot)
    {
        Write-Host ">> Found: MicroFeed List" -ForegroundColor Green
        $listDetails = @{listType = "Microfeed List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $microfeedFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $SPHomeCacheRoot)
    {
        Write-Host ">> Found: SharePoint Home Cache List" -ForegroundColor Green
        $listDetails = @{listType = "SharePoint Home Cache List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $SPHomeCacheFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $sharingLinksRoot)
    {
        Write-Host ">> Found: Sharing Links List" -ForegroundColor Green
        $listDetails = @{listType = "Sharing Links List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $sharingLinksFields}
        $listsToExport += $listDetails
    }
    elseif ($listRoot -eq $socialRoot)
    {
        Write-Host ">> Found: Social List" -ForegroundColor Green
        $listDetails = @{listType = "Social List"; listTitle = $listTitle; listRoot = $listRoot; listFields = $socialFields}
        $listsToExport += $listDetails
    }

}

#export list function
function exportList
{
    Param ([string] $listTitle, [string[]]$listFields, [string]$exportFile)

    Write-Host ("Exporting List: " + $listTitle).ToUpper() -ForegroundColor Green
    Write-Host (">> File location: $exportFile") -ForegroundColor Green

    #Get the list items
    $list = $lists.GetByTitle($listTitle)
    $listItems = $list.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
    $fieldColl = $list.Fields
    $ctx.load($listItems)
    $ctx.load($fieldColl)
    $ctx.executeQuery()

    if ($listFields) #if you're passing a specific set of fields, in a specific order, process those
    {
         #Array to Hold List Items
         $listItemCollection = @()
         #Fetch each list item value to export to excel
         foreach($item in $listItems)
         {
            $exportItem = New-Object PSObject

            Foreach ($field in $listFields)
            {
                    if($NULL -ne $item[$field])
                    {
                        #Expand the value of Person or Lookup fields
                        $fieldType = $item[$field].GetType().name
                        if (($fieldType -eq "FieldLookupValue") -or ($fieldType -eq "FieldUserValue"))
                        {
                            $fieldValue = $item[$field].LookupValue
                        }
                        elseif ($fieldType -eq "FieldUrlValue")
                        {
                            $fieldValue = $item[$field].Url
                        }
                        else
                        {
                            $fieldValue = $item[$field]
                        }
                    }
                    $exportItem | Add-Member -MemberType NoteProperty -name $field -value $fieldValue
            }
            #Add the object with above properties to the Array
            $listItemCollection += $exportItem
         }
        #Export the result Array to CSV file
        $listItemCollection | Export-CSV $exportFile -NoTypeInformation
    }
    else #export all fields for the list
    {
         #Array to Hold List Items
         $listItemCollection = @()
         #Fetch each list item value to export to excel
         foreach($item in $listItems)
         {
            $exportItem = New-Object PSObject
            Foreach($field in $fieldColl)
            {
                    if($NULL -ne $item[$field.InternalName])
                    {
                        #Expand the value of Person or Lookup fields
                        $fieldType = $item[$field.InternalName].GetType().name
                        if (($fieldType -eq "FieldLookupValue") -or ($fieldType -eq "FieldUserValue"))
                        {
                            $fieldValue = $item[$field.InternalName].LookupValue
                        }
                        elseif ($fieldType -eq "FieldUrlValue")
                        {
                            $fieldValue = $item[$field].Url
                        }
                        else
                        {
                            $fieldValue = $item[$field.InternalName]
                        }
                    }
                    $exportItem | Add-Member -MemberType NoteProperty -name $field.InternalName -value $fieldValue
            }
            #Add the object with above properties to the Array
            $listItemCollection += $exportItem
         }
        #Export the result Array to CSV file
        $listItemCollection | Export-CSV $exportFile -NoTypeInformation
    }

}

#export the lists
foreach ($list in $listsToExport)
{
     #if we have a valid folder for export, use it, otherwise export to the current directory
     if ($exportFolder -and (Test-Path $exportFolder -PathType Container))
     {
         $filepath = Join-Path -Path $exportFolder -ChildPath ($list["listTitle"] + ".csv")
     }
     else
     {
         $filepath = ($list["listTitle"] + ".csv")
     }

     #export the lists
     if ($exportAllFields)
     {
         exportList -listTitle $list["listTitle"] -exportFile $filepath
     }
     else
     {
         exportList -listTitle $list["listTitle"] -listFields $list["listFields"] -exportFile $filepath
     }
}