我需要将大量已删除的文件还原回Sharepoint。 Sharepoint是一种恶心的野兽,当然应该不惜一切代价避免,但客户正在运行它,我需要为它们找到解决方案。
Connect-SPOService -Url https://clientdomain-admin.sharepoint.com -Credential $userCredential
到目前为止一切顺利。
$Site = Get-SPOSite
Write-Host $Site
输出:Microsoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint .Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSiteMicrosoft.Online.Sharepoint.Powershell .SPOSiteMicrosoft.Online.Sharepoint.Powershell.SPOSite
我不是在开玩笑。所以尝试不同的方式:
$SiteUrl = "https://clientdomain.sharepoint.com"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Site = $Context.Site
$RecycleBinItems = $Site.RecycleBin
Write-Host "Total Number of Items:" $RecycleBinItems.Count
输出:“项目总数:0
我在这一点上陷入困境。有谁知道如何以这种方式访问回收站?
答案 0 :(得分:0)
$SiteUrl = "https://clientdomain.sharepoint.com"
$AdminUserName = "administrator@clientdomain.com"
$Password = Read-host -assecurestring "Enter Password for $AdminUserName"
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($AdminUserName,$Password)
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $Credentials
$Site = $Context.Site
$RecycleBinItems = $Site.RecycleBin
$Context.Load($Site)
$Context.Load($RecycleBinItems)
$Context.ExecuteQuery()
Write-Host "Total Number of Items:" $RecycleBinItems.Count
输出:14440
答案 1 :(得分:0)
Bisclavret 的回答对我有用。
我需要导出列表,所以我在查询之前添加了一个导出路径,然后 “$RecycleBinItems | Export-Csv -Path $FilePath NoTypeInformation” 结尾如下。
$FilePath = "C:\Users\Admin\Documents\Restore from recycle bin\restore.csv"
$Context.ExecuteQuery()
$RecycleBinItems | Export-Csv -Path $FilePath