OnPremise One Drive Usage

6/1/2016

One of the steps in migrating your on premise users to Onedrive for business is to copy the existing content from on premise to O365 one drive tenant. 
There are numerous ways to do that migration in cluding asking users to manually copy their files, use third party tool and better still write your on script ( more on this later). 

But before you do so, IT needs to identify these users sites on on premise SharePoint. Here is a power shell script to do.  Replace the XXXX parameters to reflect your environment 
 -------------------------------------------------------------------------------

# web application url where the mysites are located
$SPWebApp = Get-SPWebApplication https://XXXXXX

foreach ($spSite in $SPWebApp.Sites)
{
    # the managed path for my sites
   if ( $spSite.Url -like '*/personal/*' )
{
  try{
  $web = Get-SpWeb $spSite.Url
           ###### in case your one drive folder is different replace this Documents
           $list =   $web.Lists["Documents"]

  Write-Host $list.Items.Count:$spSite.Url
           if ( $list.Items.Count -gt 0 )
   {

          $msg =  [string]$list.Items.Count+":"+ $list.Title + ":" + $spSite.Url
          Add-Content C:\Backup\onedrive.txt $msg
    } 
         }

        catch{
           $msg ="ERROR:" + $spSite.Url+":"+$_.Exception.Message
           Add-Content C:\Backup\onedrive.txt $msg
  }
        }
}

Name

Email

WebSite