Placing a Office 365 group on legal hold and accessing content from a Preservation Hold Library

Sriram Varadarajan
 
Solution Architect
July 25, 2016
 
Rate this article
 
Views
5556

The site created for Office 365 group can be put on hold. Any content deleted shall be moved to Preservation Hold Library. But, accessing “Preservation Hold Library “from UI is currently a challenge since site contents page redirects users to the document library again. This seems to be expected since adding new lists such as document library is not allowed in this site. To ensure this, the site contents seems to have been blocked and instead redirects to document library again.

I would appreciate everyone to read my previous article to know about e-Discovery, this article would be a continuation of that.

Here are the list of workarounds that can be done to access the contents

1. We can use SharePoint designer to access this contents. We can browse to the library and copy the contents from SharePoint designer

2. We can open the site in explorer view and copy the content.

3. Following PowerShell script that browses to the library and downloads the file in mentioned location.

 $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
 $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
 
 $webUrl = Read-Host -Prompt "HTTPS URL for your SP Online 2013 site" 
 $username = Read-Host -Prompt "Email address for logging into that site"
 $password = Read-Host -Prompt "Password for $username" -AsSecureString
 
 $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) 
 $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
 $ctx.RequestTimeout = [System.Threading.Timeout]::Infinite
 
 $web = $ctx.Web
 $ctx.Load($web);
 $ctx.ExecuteQuery();
 
 $list=$web.Lists.GetByTitle("Preservation Hold Library");
 $ctx.Load($list);
 $ctx.ExecuteQuery();
 
 $query=new-object Microsoft.SharePoint.Client.CamlQuery
 $query.ViewXml="<View><Query><Where></Where></Query></View>";
 $items=$list.GetItems($query);
 $ctx.Load($items);
 $ctx.ExecuteQuery();
 
 $destinationPath = "" #Enter location within quotes
 
 function recur_folder($item,$destinationPath)
 {
 if($item.FileSystemObjectType -ne "File")
     {
         $folderName = $item["FileLeafRef"];
         $folderPath1 = $item["FileRef"];
         $pathOfFolder=$destinationPath+$folderName
         New-Item -ItemType directory -Path $pathOfFolder;
         $folderQuery=New-Object Microsoft.SharePoint.Client.CamlQuery;
         $folderQuery.ViewXml="<View><Query><Where></Where></Query></View>";
         $folderQuery.FolderServerRelativeUrl=$folderPath1;
         $folderItems=$list.GetItems($folderQuery);
         $ctx.Load($folderItems);
         $ctx.ExecuteQuery();
         $pathOfFolder= $pathOfFolder+""
         foreach($folderItem in $folderItems)
         {
             recur_folder $folderItem $pathOfFolder  
         }
     }
     else
     {
          Write-Host "Saving " $item["FileRef"]
          $fileRef = $item["FileRef"]
          $fileInfo = [Microsoft.SharePoint.Client.File]::OpenBinaryDirect($ctx,$fileRef.ToString())
          $new = $destinationPath + $item["FileLeafRef"]
 
          [byte]$byte = ""
          $list = New-Object System.Collections.Generic.List[byte]
          try {
          while(($byte = $fileInfo.Stream.ReadByte()) -ne -1)
          { 
          $list.Add($byte)
          }
          } catch [Exception] {
          }
          [System.IO.File]::WriteAllBytes($new, $list.ToArray());
          $fileInfo.Dispose() 
          }
             }
             
  
 foreach($item in $items)
 {
 recur_folder $item $destinationPath
 }  
 

Conclusion:

MS is the process of fixing this issue with the new Security and compliance roadmap…

Category : Office 365, SharePoint

Author Info

Sriram Varadarajan
 
Solution Architect
 
Rate this article
 
Sriram is a Technology Evangelist with 15+ years experience in Microsoft Technologies. He is an enterprise architect working for large pharmaceutical organization which has presence globally with largest Microsoft implementation ...read more
 

Leave a comment