After working on this for a few days, I finally thought I'd appeal to the collective wisdom of TechNet :)
I'm trying to pre-provision OneDrive for Business storage areas via PowerShell. The idea is to provision these without having to have the user login, and then migrate data from another location to each user's OD4B folders.
I've seen all sorts of blog posts on this, and have tried every one I could find, but none result in an account that is provisioned. I can only gain access to a user's OneDrive after I've logged in as their user account and tried to login via the web once.
I've attached a small script I wrote to connect to SharePoint Online, request an SPO Personal Site (Which in this case is the same as OneDrive for Business space... right?), and then built a function to try and connect to each user's space via the 'Get-SPOSite' commandlet. I've blanked out variable names so you'll have to replace a few portions with the proper values for this to work.
Function Test-UserOd4b { param($spoCred, $upn, $spoBaseURL) Write-Verbose 'Testing to see if the OneDrive site exists' #take the UPN passed in and make it into the URL that we need $userURL = $upn.replace('@','_') $userURL = $userURL.replace('.','_') Try { #I don't do anything with success, I just capture it so it doesn't echo out $success = Get-SPOSite "https://$spoBaseURL-my.sharepoint.com/personal/$userURL" -ErrorAction SilentlyContinue Write-Verbose 'The site exists and is provisioned!' } Catch { $accessError = $_ Write-Verbose "It doesn't look like the site exists for this user" } $accessError } ##### MAIN ##### #Testing Vars $spoBaseURL = '<BASE URL FOR ADMIN AND USER SITE URL CREATION>' $emails = @('email1@hostname.com','email2@hostname.com') # Verbose Logging $VerbosePreference = "Continue" # SharePoint Online administration URL $spAdminUrl = "https://$spoBaseURL-admin.sharepoint.com" #create Credential for SPO $spoUsername = "<SPO ADMIN EMAIL>" $spoPassword = "<SPO ADMIN PASS>" $spoCred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $spoUsername, $(convertto-securestring $spoPassword -asplaintext -force) #connect to SPO Connect-SPOService -Url $spAdminUrl -Credential $spoCred #pre-provision Request-SPOPersonalSite -UserEmails $emails #Check and see if sites have provisioned foreach ($upn in $emails) { $spoCommandOutput = Test-UserOd4b -spoCred $spoCred -upn $upn -spoBaseURL $spoBaseURL }
There seem to be several alternatives to the 'Request-SPOPersonalSite' commandlet and I've tried the examples at the following links already, with no greater success:
- https://technet.microsoft.com/en-us/library/dn800987.aspx
- http://www.lieben.nu/liebensraum/2015/08/provisioning-onedrive-for-business-for-all-your-users/
I am also aware that it may take 30+ minutes to provision an account, and I've gone back after waiting a lengthy period of time (Over 24 hours) and just re-checked, without trying to re-provision, each account, and no luck.
Am I doing this totally wrong here? Or barking up the wrong tree? It seems that everyone else has good luck with the above posts, and yet I'm not seeing any change in the status of my users.
Thanks!