Экспорт параметров интерфейса Microsoft OneDrive

В интерфейсе Microsoft OneDrive хранится информация, помогающая пользователю находить интересующее его содержимое и переходить к ним. Пользователи могут получить доступ к большей части этой информации с помощью соответствующих функций продукта, перечисленных в следующей таблице:

Интерфейс Хранящиеся данные Доступ пользователя
Общие элементы Список документов, которыми пользователи предоставили общий доступ. В нем также представлено представление документов, которыми пользователь поделился с другими пользователями. Это представление разрешений, заданных пользователем для элементов в своей учетной записи OneDrive. В OneDrive пользователя выберите Общие.
Push-уведомления для мобильных устройств Push-уведомления для мобильных приложений OneDrive и SharePoint пользователей, если они настроены. Сюда входят соответствующие действия, такие как новые файлы, которыми им предоставлен общий доступ.
Администраторы могут управлять ими на странице Параметры нового Центра администрирования SharePoint.
Сайты и контент, на которые вы подписаны Пользователи могут подписываться на сайты, документы или других людей.
Сайты, на которые вы подписаны, можно просмотреть в интерфейсах продуктов.
Отслеживаемые сайты можно просматривать и управлять ими в домашней среде SharePoint. Этот интерфейс также показывает последние сайты .
В учетной записи пользователя в OneDrive можно нажать значок с шестеренкой "Параметры", выбрать пункт Параметры сайта и щелкнуть Канал новостей. В правой части экрана можно выбрать нужный тип контента в разделе "Мои подписки".
Канал новостей Список действий пользователей, включая отслеживаемое содержимое, упоминания и изменения профиля. Пользователи могут получить доступ к нему с помощью встроенных интерфейсов. В учетной записи пользователя в OneDrive можно нажать значок с шестеренкой "Параметры", выбрать пункт "Параметры сайта" и щелкнуть "Канал новостей".
Параметрами каналов новостей можно управлять в ранее описанном интерфейсе профиля пользователя.
Запросы на доступ Список запросов на доступ к контенту. В учетной записи пользователя в OneDrive можно нажать значок с шестеренкой "Параметры", выбрать пункт Параметры сайта, а затем щелкнуть Запросы на доступ и приглашения

Администратор может экспортировать эти списки с помощью команд PnP PowerShell и SharePoint Client-Side объектной модели (CSOM) в этой статье. Все необходимые сборки CSOM включены в модуль SharePointPnPPowerShellOnline Microsoft PowerShell.

Это пример сценария, который можно адаптировать в соответствии с потребностями вашей организации. Например, администратор может извлечь сведения для user1@contoso.com , выполнив следующую процедуру.

  1. Назначьте себе разрешения администратора для учетной записи пользователя OneDrive. Это можно сделать в Центре администрирования Microsoft 365.

  2. Установите необходимые модули Microsoft PowerShell:

    Install-Module SharePointPnPPowerShellOnline

    Install-Module CredentialManager

  3. Выполните сценарий PowerShell ExportODBLists (или его настроенную версию):

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

    ExportODBLists.ps1 -siteUrl $ODBSite

Скрипт экспортирует данные, хранящиеся для функций, описанных в предыдущей таблице, в несколько CSV-файлов. Администратор может просмотреть или отредактировать, прежде чем предоставлять их конечному пользователю.

Скрипт создает следующие CSV-файлы (если соответствующие списки найдены). Имя CSV-файла соответствует заголовку списка.

Файл Описание
(Reference, <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

Скопируйте приведенное ниже содержимое и вставьте его в текстовый файл. Сохраните файл какExportODBLists.ps1. Скрипт может экспортировать все поля из целевых списков с помощью exportAllFields параметра . Скрипт можно изменить для экспорта всех списков и обработки других сайтов.

Примечание.

Если вы видите ошибку о том, что сборка не загружается, проверьте путь к последней версии модуля PowerShell SharePointPnPPowerShellOnline, как определено в параметрах пути Add-Type. Путь может отличаться на компьютере или вы используете другую версию модуля (версия модуля является частью пути).

#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
     }
}