Author Archives: Administrátor webu

SharePoint Online PowerShell Script to Extract All Documents and Their Versions

SharePoint

Dowload documents SharePoint Online with versions

This script will dowload documents from SharePoint Online document library with all their versions using client object model. The script uses very good powershell module from Arleta Wanat and you can download currect module here SPOMod.

•You have to put my script with SPOMod script module together in e.g. c:\temp

•Customize the variables in download.ps1 script

•Read how to use SPOMod here (In description section): SPOMod

•Open the Powershell console and run the script download.ps1


$userName = "foo@domain.com"
$password = "password"
$siteCollectionUrl = "https://yourcollection.sharepoint.com"
$webUrl = $siteCollectionUrl + "/Sites/yourweb"
$docLibraryTitle = "Documents"
$destinationLocalFolder = "c:\temp\doc"

#------------------------------------------------
Import-Module .\SPOMod20160326.psm1
#------------------------------------------------

Connect-SPOCSOM -Username $userName -Url $webUrl

#Download document function
function HTTPDownloadFile ($serverFileLocation, $downloadPath)
{
#create secure password
$sPassword = $password | ConvertTo-SecureString -AsPlainText -Force

$webClient = New-Object System.Net.WebClient
$webClient.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $sPassword)
$webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")

[System.Uri]$destinationUri = [System.Uri]$serverFileLocation

Write-Host "Downloading" $serverFileLocation "as" $downloadPath

$webClient.DownloadFile($destinationUri, $DownloadPath)
$webClient.Dispose()
}

#------------------------------------------------
#Get files (not dirs)
$listItems = Get-SPOListItems -ListTitle $docLibraryTitle -IncludeAllProperties $true -Recursive | where {$_.FsObjType -eq 0}

#Iteration on all files in doc. library
foreach ($item in $listItems)
{
[string]$sourceDirectory = $item.FileDirRef
[string]$sourceFileName = $item.FileLeafRef
[String]$sourceFileUrl = $siteCollectionUrl + $item.FileRef

#create destination directory
[string]$destinationDirectory = $destinationLocalFolder + $sourceDirectory
$destinationDirectory = $destinationDirectory.Replace("/","\")
if (!(Test-Path -path $destinationDirectory))
{
New-Item -path $destinationDirectory -type directory
}

#download current version document
[string]$destinationFilePath = $destinationDirectory + "\" + $sourceFileName
HTTPDownloadFile $sourceFileUrl $destinationFilePath

#get versions of curent file
$fileVersions = Get-SPOListItemVersions -ListTitle $docLibraryTitle -ItemID $item.Id

#iteration on all file versions
foreach ($ver in $fileVersions)
{
$fileHistoryUrl = $webUrl + "/" + $ver.Url
$version = $ver.VersionLabel

if (![string]::IsNullOrEmpty($fileHistoryUrl))
{
$filesplit = $sourceFileName.split(".")
$fullname = $filesplit[0] $fileext = $filesplit[1] $fullFileName = $fullname + "_v" + $version + "." + $fileext

#download history version document
$destinationFilePath = $destinationDirectory + "\" + $fullFileName

HTTPDownloadFile $sourceFileUrl $destinationFilePath
}
}
}

Azure BackUp Error 130024

Na zálohování do Windows Azure jsem se těšil dávno. Jsou pryč doby, kdy jsem důvěřoval externím diskům nebo flashkám. Externí disk odejde do křemíkového nebe zároveň se zálohovaným strojem a zálohovací flashku jsem těsně před ztrátou dat použil na něco jinýho 🙂 Takže do cloudu zálohuju servery už dlouho. Nedávno jsem se dočetl, že je možné takto zálohovat i Windows 10. Skvělý. Vytvořím backup vault. Stáhnu soubor s konfigurací pro klienta. Uložím soubor. Nainstaluju Azure backup klienta a…chyba 130024.

Azure Backup error 130024

Azure Backup error 130024

V mém případě to bylo proto, že jsem konfigurační soubor z backup vault uložil přímo do šifrovaného adresáře. Backup klient běží v kontextu jiného uživatele, takže ho nemohl přečíst. Takže pozor kam soubor ukládáte 🙂