title: Backup a user's OneDrive for Business account using PowerShell
body: <p>Our company is implementing a process where we automatically backup specific users' Exchange mailbox and OneDrive contents during the offboarding process.<br />
  My idea was pretty simple: using the cmdlets for the Compliance center to retrieve both and schedule deletion after an x period of time.<br />
  The problem is the e-mail backup is working perfectly, but for some reason OneDrive is not.<br />
  I created a test account with some e-mails in its mailbox and a added some files to its OneDrive, but for some reason it's only saving the mailbox contents.<br />
  Here's my code:</p>
  <pre><code># For running on Azure runbooks
  $Creds = Get-AutomationPSCredential -Name &quot;testcred&quot;
  
  Connect-IPPSSession -Credential $Creds
  
  New-ComplianceSearch -Name &quot;test-name&quot; -ExchangeLocation &quot;test.user@company.com&quot; -AllowNotFoundExchangeLocationsEnabled $true -SharePointLocation &quot;https://company-my.sharepoint.com/personal/test_user_company_com/&quot; | Start-ComplianceSearch
  </code></pre>
  <p>The search then pops up on <a href="https://compliance.microsoft.com/contentsearch" rel="nofollow noreferrer">https://compliance.microsoft.com/contentsearch</a> and can be exported if necessary to access.<br />
  Problem is when I export it the contents of the OneDrive just simply don't show up even though in the compliance center it does seem to register the request for the site:</p>
  <p><a href="https://i.stack.imgur.com/oAP5d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oAP5d.png" alt="compliancecenterprintscrn" /></a></p>
  <p>That's great, but then after extracting the contents to my PC no OneDrive contents come with:</p>
  <p><a href="https://i.stack.imgur.com/yDt6N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yDt6N.png" alt="extractioncontents" /></a></p>
  <p>The Exchange folder contains the .pst file with mailbox contents, but no OneDrive files to be found.<br />
  Am I missing something here?<br />
  Edit: I should mention we use a 100% cloud Office 365 environment.<br />
  Edit2: Just as an additional proof, here's the content inside the OneDrive in the preview section of the Compliance's Content Search:</p>
  <p><a href="https://i.stack.imgur.com/RW6QA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RW6QA.png" alt="searchcontents" /></a></p>