匯出 Microsoft OneDrive 體驗設定
使用者的 Microsoft OneDrive 體驗會儲存資訊,以協助使用者尋找並流覽至他們感興趣的內容。 使用者可以使用下表所列的對應產品內功能來存取大部分的資訊:
功能 | 儲存的資料 | 使用者存取 |
---|---|---|
共用項目 | 其他人與使用者共用的檔案清單。 它也會顯示使用者與其他人共用之檔的檢視,這是使用者在其 OneDrive 帳戶中設定專案的許可權檢視。 | 請從使用者的 OneDrive 中選取 [共用]。 |
行動推播通知 | 如果已設定,請將通知推送至使用者的 OneDrive 和 SharePoint 行動裝置應用程式。 這包括相關的活動,例如與他們共用的新檔案。 系統管理員可以在新的 SharePoint 系統管理中心的 [設定] 頁面上管理這些專案。 |
|
追蹤的網站和內容 | 使用者可以追蹤網站、文件或人員。 可以使用產品內體驗來檢視追蹤的網站。 |
您可以在 SharePoint 首頁體驗中檢視和管理追蹤的網站。 此體驗也會顯示 最近的網站 。 使用者可以從他們的 OneDrive 帳戶中,依次選取 [設定] 齒輪圖示、[網站設定]、[新聞摘要]。 在右側的 [我正在追蹤] 底下,他們可以按一下適當的內容類型。 |
新聞摘要 | 使用者活動清單,包括追蹤的內容、提及和設定檔變更。 使用者可以使用產品內體驗來存取它。 | 使用者可以從他們的 OneDrive 帳戶中,依次選取 [設定] 齒輪圖示、[網站設定]、[新聞摘要]。 新聞摘要設定可以當作使用者設定檔體驗 (先前所述) 的一部分來管理。 |
存取要求 | 對內容的存取要求清單。 | 使用者可以從他們的 OneDrive 帳戶中,依次選取 [設定] 齒輪圖示、[網站設定]、[存取要求和邀請]。 |
在本文中,系統管理員可以使用 PnP PowerShell 和 SharePoint Client-Side物件模型 (CSOM) 命令來匯出這些清單。 所有必要的 CSOM 元件都包含在 SharePointPnPPowerShellOnline Microsoft PowerShell 模組中。
這是範例腳本,可以根據組織的需求進行調整。 例如,系統管理員可以使用下列程式擷取 的資訊 user1@contoso.com 。
為自己指派使用者的 OneDrive 帳戶系統管理員權限。 可在 在 Microsoft 365 系統管理中心完成這項動作。
安裝所需的 Microsoft PowerShell 模組:
Install-Module SharePointPnPPowerShellOnline
Install-Module CredentialManager
請執行以下的 ExportODBLists PowerShell 指令碼 (或指令碼的自訂版本):
$ODBSite = "https://contoso-my.sharepoint.com/personal/user1_contoso_com"
ExportODBLists.ps1 -siteUrl $ODBSite
腳本會將上表所述功能所儲存的資料匯出至多個 CSV 檔案。 系統管理員可以先檢閱或修訂,再將它們提供給使用者。
如果) 找到對應的清單,腳本會建立下列 CSV 檔案 (。 CSV 檔案的名稱會對應至清單的標題。
檔案 | 描述 |
---|---|
(參考, < id >) .csv,其中 < id > 是字母和數位的序列 | 與使用者共用的項目清單 |
Sharing Links.csv | 使用者產生之共用連結的清單 |
userActivityFeedHiddenListF4387007-BE61-432F-8BDB-85E6B9679E4B.csv | 相關活動的清單 |
notificationSubscriptionHiddenList6D1E55DA-2564-4A22-A5F9-6C4FCAFF53DE.csv | 傳送至行動裝置應用程式的通知清單,以及這些裝置的應用程式識別碼的清單 |
Social.csv | 追蹤的內容清單 |
MicroFeed.csv | 新聞摘要項目的清單 |
Access Requests.csv | 存取要求的清單 |
SharePointHomeCacheList.csv | 從流覽至 SharePoint 首頁的使用者快取資料。 每次使用者流覽至 SharePoint 首頁時,就會重新整理。 |
複製下列內容,並將它們貼到文字檔中。 將檔案儲存為 ExportODBLists.ps1。 腳本可以使用 exportAllFields
參數,從目標清單匯出所有欄位。 您可以修改腳本以匯出所有清單,以及處理其他網站。
注意
如果您看到有關元件未載入的錯誤,請仔細檢查最新版 SharePointPnPPowerShellOnline PowerShell 模組的路徑,如 Add-Type Path 參數中所定義。 您的電腦上的路徑可能不同,或者您可能使用不同版本的模組, (模組版本是路徑) 的一部分。
#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
}
}