O4BClientAutoConfig

The new Onedrive for Business client when installed on Windows 10 has a number of options we can use to streamline the user portion of the configuration. I’ve taken information from several sources and written a single “Do It All – Onedrive For Business configuration script” for the Windows 10 Modern Management (Intune MDM Azure AD Join) scenario.

The script can be deployed through Intune and will do the following:

  • check latest O4B version, install if needed
  • detect O4B configuration, start auto config
  • completely silent configuration with SSO
  • optionally, enable Files On Demand
  • optionally, redirect folders to Onedrive
  • optionally, copy old content

Other stuff you’ll like to know:

  • The script logs to %APPDATA%\Temp on the local device for the user details
  • The script logs to c:\windows\temp for the SYSTEM install portion
  • User needs to have an Intune and Onedrive for Business license
  • If MFA is enabled the ‘silent’ part won’t apply, but redirection is still applied after the user finishes Onedrive configuration
  • User does not need to be local admin
  • Script runs at each logon (scheduled task) but is invisible due to a VBS wrapper

Credits / Sources used:

Instructions:

  1. Download script source and save locally: GitLab link
  2. Go to Intune and add the Powershell script:
  3. Now assign the added script to a group containing your users4. Click OK, you’re all set!

Note for Office 2016 MDM users: the Intune deployment of Office may conflict if it runs at the same time, this will delay the installation by a few minutes but will not cause issues.

35
Leave a Reply

avatar
15 Comment threads
20 Thread replies
10 Followers
 
Most reacted comment
Hottest comment thread
12 Comment authors
PriyaGopClaymanJosBeatNick Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
Tim
Guest
Tim

The Join-Folder in the script should be Join-Path

PriyaGop
Guest
PriyaGop

Hi Jos,

Great script, I tested it in a couple of our test Windows 10 machines and it works great! I am new to PowerShell and might need your support.

This script syncs files/ folders from cloud to PC as well. Can we restrict that? Can this script be modified to make sync only from PC to onedrive cloud?

Please assist

Clayman
Guest
Clayman

I am using your script and trying to Redirect the Downloads folder also I have added the line and copy content. I get an error message.
Test-Path : Cannot bind argument to parameter ‘Path’ because it is null here is part of the script I am using. What am I doing wrong. @{“knownFolderInternalName” = “Downloads”;”knownFolderInternalIdentifier”=”Downloads”;”desiredSubFolderNameInOnedrive”=”Downloads”;”copyContents”=”true”},

I’ve also added Downloads in $KnownFolders and Set-knowfolderPath

Beat
Guest
Beat

It is possible to redirect the OneDrive to another drive?

Nick
Guest
Nick

Will this work if the documents location is already redirected to a share on a server?

Beat
Guest
Beat

The script works great. Is it possible to redirect the Desktop, Documents and Pictures folders to a subfolder (e.g. Profile) on the OneDrive?

Ben
Guest
Ben

It works 🙂
Thank you Jos for the great work!

Devaki Priya
Guest
Devaki Priya

Hi,

I used your script to auto configure onedrive. it works great. but users started reporting that they are missing desktop files. Desktop files resides in C:\Users\username\Desktop and not in C:\Users\username\OneDrive – companyname\Desktop. Can you help me redirect user desktop files to onedrive folder.

Ben
Guest

Hi Jos,
You’ve done a great job with this script en can help me a lot 🙂 -> I’m a bit a newcomer in the world of Powershell but trying to learn and understand, and now I’m struggling how and where to set the ‘Get/Set-KnownFolderPath’ function to redirect the folders. Even Google can’t help me out on this one. Can you please clarify how and where to properly configure the arrays mentioned in line 18?
Thanks in advance!

chintan
Guest
chintan

Hi Jos,
i am trying to redirect download folder in O4b. i know its not a part of Windows library but how can i add this folder in o4b could you please help me out ?

Joel
Guest
Joel

Awesome script Jos! I’m testing this with some client machines before rolling out across our customer fleet.
Little thing I’ve found is OneDrive client reinstalling on every login. In the log I get this “TerminatingError(Get-ItemProperty): “The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: Property Version does not exist at path HKEY_CURRENT_USER\Software\Microsoft\OneDrive.”
But in the reg, the key is there and the value is 17.005.0107.0008 yet in the script it says “Microsoft’s XML shows the latest Onedrive version is 17.005.0107.0004 and can be downloaded from https://oneclient.sfx.ms/Win/Insiders/17.005.0107.0004/OneDriveSetup.exe

Sam
Guest
Sam

Hey Jos, great work again!
Just struggeling with redirecting the user download Folder to od4b.
I guess its missing in “Get-KnownFolderPath”. Could you help me out with this one?

Jan
Guest
Jan

Hi Jos, New-ScheduledTaskPrincipal -GroupId “BUILTIN\Users” gives an error : No mapping between account names and security IDs was done. Is this because my OS language? Changing it to New-ScheduledTaskPrincipal -GroupId “Gebruikers” works.

trackback

[…] O4BClientAutoConfig + source code. […]