¿Cómo descargar todos los archivos de un sitio de SharePoint?
Requisito: Descargar todos los archivos desde un sitio de SharePoint.
¿Cómo descargar todos los archivos en el sitio de SharePoint?
Descargar todos los archivos de SharePoint puede ser una tarea desalentadora, especialmente cuando tiene una gran cantidad de archivos y carpetas. Sin embargo, es una tarea necesaria cuando necesitas hacer una copia de seguridad de los datos o moverlos a otra plataforma. Cuando tiene muchas bibliotecas de documentos diferentes con archivos, lleva bastante tiempo descargar todos los archivos de la biblioteca. ¡Afortunadamente, existe una manera fácil de hacer esto! Exploremos cómo descargar fácilmente todas las bibliotecas de documentos de un sitio:
Para descargar todos los archivos de una biblioteca o carpeta de documentos de SharePoint, utilice la "Vista del Explorador".
- Navegue a su biblioteca de SharePoint local o SharePoint Online.
- Haga clic en "Ver en el Explorador de archivos" en el menú desplegable Vistas en SharePoint Online. Para SharePoint local, haga clic en el botón "Abrir con el Explorador" en la pestaña "Biblioteca".
Desde la vista Explorar, puede descargar todos los documentos o todos los archivos adjuntos de cualquier lista o biblioteca a su máquina local.
-
Ahora, en la vista del Explorador, navegue un nivel hacia arriba y podrá descargar el sitio completo o la colección de sitios usando la vista del explorador navegando hacia arriba y hacia abajo hasta el sitio, la lista o los objetos de la biblioteca.
¡Muy sencillo, eh! Sin embargo, puede ser una tarea desalentadora descargar todos los documentos de todas las bibliotecas en SharePoint Online manualmente. Como solución, PowerShell es una forma eficaz de automatizar este proceso. Veamos cómo descargar todos los documentos de todas las bibliotecas de documentos en SharePoint Online usando PowerShell.
PowerShell para descargar todos los archivos desde el sitio local/en línea de SharePoint:
También podemos utilizar el método WebDav para descargar todos los archivos de un sitio o colección de sitios de SharePoint. Simplemente configure los parámetros en el siguiente script y presione ejecutar. Este script de PowerShell copia todos los archivos, incluidos los archivos de todas las bibliotecas y las versiones de documentos, los archivos adjuntos de elementos de lista del sitio determinado y sus subsitios en la ruta del disco local proporcionada. Es posible que tengas que iniciar sesión en el sitio del servidor SharePoint una vez para establecer una cookie de sesión, ¡por cierto!
#Configuration Parameters
$DownloadPath= "c:\Downloads\Online"
#$WebDavUrl = "\\intranet.crescent.com\DavWWWRoot\sites\operations"
$webDavUrl = "\\crescent.sharepoint.com@SSL\DavWWWRoot\sites\operations" #SharePoint Online
#Create Local Folder it it doesn't exists
If(!(Test-Path $DownloadPath))
{
New-Item -ItemType Directory -Force -Path $DownloadPath | Out-Null
}
#Get All files from the Site and download to local folder
Get-ChildItem -Path $webDavUrl -Recurse | ForEach-Object {
#Frame the destination path
$DestinationPath = Join-Path -Path $DownloadPath -ChildPath (Split-Path $_.FullName -NoQualifier).Replace($webDavUrl,'');
#Copy File to local path
Copy-Item $_.FullName -Destination $DestinationPath -Force
Write-host -f Green File Copied to $DestinationPath
}
Este método funciona tanto en SharePoint local como en SharePoint Online.
PnP PowerShell para descargar todas las bibliotecas de documentos desde un sitio de SharePoint Online
Si necesita descargar todos los documentos de SharePoint Online para fines de copia de seguridad, migración o archivado, hacerlo manualmente puede ser una tarea tediosa. Aquí está el script de PowerShell para automatizarlo:
#Function to download a library from SharePoint Online
Function Download-PnPLibrary
{
[cmdletbinding()]
param
(
[Parameter(Mandatory=$true)][Microsoft.SharePoint.Client.List]$List,
[Parameter(Mandatory=$true)][string]$DownloadPath
)
Try {
Write-host -f Yellow "Downloading Document Library:"$List.Title
#Create a Local Folder for the Document Library, if it doesn't exist
$LibraryFolder = $DownloadPath +"\" +$List.RootFolder.Name
If (!(Test-Path -Path $LibraryFolder)) {
New-Item -ItemType Directory -Path $LibraryFolder | Out-Null
}
#Get all Items from the Library - with progress bar
$global:counter = 0
$ListItems = Get-PnPListItem -List $List -PageSize 500 -Fields ID -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete `
($global:Counter / ($List.ItemCount) * 100) -Activity "Getting Items from Library:" -Status "Processing Items $global:Counter to $($List.ItemCount)";}
Write-Progress -Activity "Completed Retrieving Items from Library $($List.Title)" -Completed
#Get all Subfolders of the library
$SubFolders = $ListItems | Where {$_.FileSystemObjectType -eq "Folder" -and $_.FieldValues.FileLeafRef -ne "Forms"}
$SubFolders | ForEach-Object {
#Ensure All Folders in the Local Path
$LocalFolderPath = $DownloadPath + ($_.FieldValues.FileRef.Substring($Web.ServerRelativeUrl.Length)) -replace "/","\"
#Create Local Folder, if it doesn't exist
If (!(Test-Path -Path $LocalFolderPath)) {
New-Item -ItemType Directory -Path $LocalFolderPath | Out-Null
}
Write-host -f Green "`tEnsured Folder '$LocalFolderPath'"
}
#Get all Files from the folder
$FilesColl = $ListItems | Where {$_.FileSystemObjectType -eq "File"}
#Iterate through each file and download
$FilesColl | ForEach-Object {
#Frame the Parameters to download file
$FileDownloadPath = ($DownloadPath + ($_.FieldValues.FileRef.Substring($Web.ServerRelativeUrl.Length)) -replace "/","\").Replace($_.FieldValues.FileLeafRef,'')
$FileName = $_.FieldValues.FileLeafRef
$SourceURL = $_.FieldValues.FileRef
#Download the File
Get-PnPFile -ServerRelativeUrl $SourceURL -Path $FileDownloadPath -FileName $FileName -AsFile -force
Write-host -f Green "`tDownloaded File '$FileName' from '$SourceURL'"
}
}
Catch {
Write-Host -f Red "Error Downloading Library '$($List.Title)' :"$_.Exception.Message
}
}
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$DownloadPath ="C:\Temp\NewDocs"
#Connect to SharePoint Online
Connect-PnPOnline $SiteURL -Interactive
$Web = Get-PnPWeb
#Exclude certain libraries
$ExcludedLists = @("Form Templates", "Preservation Hold Library","Site Assets", "Pages", "Site Pages", "Images",
"Site Collection Documents", "Site Collection Images","Style Library")
#Get all non-hidden document libraries
$DocumentLibraries = Get-PnPList -Includes RootFolder | Where {$_.BaseType -eq "DocumentLibrary" -and $_.Title -notin $ExcludedLists -and $_.Hidden -eq $False}
#Enumerate each library
ForEach($Library in $DocumentLibraries)
{
Download-PnPLibrary -List $Library -DownloadPath $DownloadPath
}
Este artículo trata sobre la descarga de todos los documentos de SharePoint Online con diferentes métodos disponibles. Dependiendo de sus necesidades específicas, puede descargar rápida y fácilmente todos los documentos de una biblioteca específica a su máquina local.
Consulte mi otra publicación para descargar todos los documentos de una biblioteca usando PowerShell: PowerShell para descargar todos los archivos de la biblioteca de documentos de SharePoint Online

