Condividi tramite


How to deploy OneDrive next generation sync client with SCCM

Hello everyone!

I've seen people having trouble while deploying the OneDrive next generation sync client with SCCM,

So i've decided to create a new blog post to share same ideas of how i'm usually deploying it on our clients.

 

On the Onedrive documentation we have the following:

https://support.office.com/en-us/article/Plan-to-deploy-the-OneDrive-for-Business-Next-Generation-Sync-Client-in-an-enterprise-environment-6af6d757-0a73-4fe8-99bd-14c56a333fa3

I just want to install the OneDrive.exe client on user’s machines

Maybe all you’re interested in is getting the new OneDrive for Business sync client onto your users’ machines. If all you want to do is install OneDrive.exe on a machine you can use either SCCM or a Group Policy script to execute the following:

Execute <pathToSomeAccessibleNetworkShare>\OneDriveSetup.exe /silent

Result: OneDrive.exe is installed transparently on your users’ machines, but it is not automatically launched. Users can launch OneDrive.exe by opening their OneDrive folder in File Explorer, or by launching OneDrive from the start menu. Or IT administrators at any time later can run %localappdata%\Microsoft\OneDrive\OneDrive.exe through SCCM or Group Policy script to automatically open OneDrive.exe on the users machine.

 

This new Onedrive client has some specific requirements to be created as an SCCM application as it's based on an EXE file that is installed on a user Profile. This means that we need to create an Application based on a script instead of an MSI and that we need to run it only we have an user logged on so that we can get it on the proper users profile

 

 

On this post I will discuss only the installation part, you will need to run Onedrive.exe afterwards either by asking the users to do so or you can also automate the Onedrive execution with SCCM. Start by creating a simple application based on a script

  • Start by creating an application based on a script1
  • Then fill out the application information 2

 

  • On the deployment types, add a new type of deployment of Script Installer type

3

 

 

4

 

  • This is one of the most important part of this deployment, the detection method, for this specific detection as the application is always installed on the user profile, we need to scan on the current user profile for the OneDrive.exe to see if it's installed or not. We need to use the option to "use a custom script to detect the presence of this deployment type" and then use the following script:

 

I need to give a huge thanks to my colleague Herbert Fuchs who's an amazing SCCM PFE based in Austria and a Powershell Guru that entirely developed this detection script.

Just copy & Paste the bellow into the SCCM console:

# OneDriveSetup Detection in ConfigMgr

# This Sample Code is provided for the purpose of illustration only and is not intended to be used in a production environment.

# THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,

# INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

# We grant You a nonexclusive, royalty-free right to use and modify the Sample Code and to reproduce and distribute the object

# code form of the Sample Code, provided that You agree: (i) to not use Our name, logo, or trademarks to market Your software

# product in which the Sample Code is embedded; (ii) to include a valid copyright notice on Your software product in which the

# Sample Code is embedded; and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and against any claims

# or lawsuits, including attorneys’ fees, that arise or result from the use or distribution of the Sample Code.inst

[String]$LogfileName = "OneDriveDetection"

[String]$Logfile = "$env:SystemRoot\logs\$LogfileName.log"

Function Write-Log

{

Param ([string]$logstring)

If (Test-Path $Logfile)

{

If ((Get-Item $Logfile).Length -gt 2MB)

{

Rename-Item $Logfile $Logfile".bak" -Force

}

}

$WriteLine = (Get-Date).ToString() + " " + $logstring

Add-content $Logfile -value $WriteLine

}

$User = gwmi win32_computersystem -Property Username

$UserName = $User.UserName

$UserSplit = $User.UserName.Split("\")

$OneDrive = "$env:SystemDrive\users\" + $UserSplit[1] +"\appdata\local\microsoft\onedrive\onedrive.exe"

# Parameter to Log

Write-Log "Start Script Execution"

Write-Log "Logged on User: $UserName"

Write-Log "Detection-String: $OneDrive"

If(Test-Path $OneDrive)

{

Write-Log "Found DetectionFile"

$OneDriveFile = Get-Item $OneDrive

Write-Log "Get File Details"

Write-Log "Version found:$OneDriveFile.VersionInfo.FileVersion"

Write-Log "Script Exectuion End!"

Write-Log ""

Return $true

}

Else

{

Write-Log "Warning: OneDrive.exe not found - need to install App!"

}

 

 

5

 

  • Also, it's very important to set User experience like this, to make sure that the application gets installed on the user profile

6

  • Now  just deploy it into a computer collection!

Be advised that you have to sign this script or use Client settings and set the Powershell execution policy to bypass (use with caution!)

https://technet.microsoft.com/en-us/library/gg682067.aspx

Hope this helps !

Cheers

PS : This blog will be removed in the future, for future reference use the article /en-us/onedrive/deploy-on-windows

On that article you can also find an example that you can quickly download and import to your environment to avoid copy & paste errors and to speed up the app creation

Comments

  • Anonymous
    May 24, 2016
    Two questions:1. How do you force the install to default to OneDrive Business?2. How do you populate the user's Office 365 UPN so the install process is completely transparent to the user?
    • Anonymous
      May 27, 2016
      Hello Joey, In this case the objective was to only deploy the client, which is the step 1 in the Onedrive deployment documentation. Please check Onedrive's remaining documentation to do all the remaining configuration. If in the future I do that in an unattended way i'll be sure to update this blog! thanks for your comment
    • Anonymous
      February 28, 2017
      Just set the option to use default the onedrive next gen client in office365
  • Anonymous
    May 25, 2016
    The comment has been removed
    • Anonymous
      May 26, 2016
      Thanks Jeremy for your feedback! There's lot of different scenarios for each customer specific needs, thanks for your valuable input !
    • Anonymous
      October 04, 2016
      Hi Jeremy,see also my post later to get things done with user log-ins.
  • Anonymous
    May 30, 2016
    Hi,I made a shorter powershell. But you need more than this one you have posted from a guy based in Austria. At first, this app does not install with Admin privileges, so it must be in user context. Then, it must identify the user logged, and with System context, (I didn't test the code above but) I doubt if it can get the user logged instead of System account. Then, since this App has different builds, you must guarantee that the one you are deploying is the one you are getting "Installed" message from Software Center. At the end, if you simply run onedrivesetup.exe /silent alone from your server, probably the only thing you will get is, that onedrivesetup.exe file, copied to your ProgramFiles path. So, you must force running that setup from that path after running onedrivesetup.exe /silent alone from your server.
    • Anonymous
      August 29, 2016
      Hello Tiago! thanks for the feedback! there are lots of different approaches to this kind of deployment (check Steve Rachui's blog for a different one!) for several of my customers this is working in production. And yes, version control is a great idea! and you do have to run OneDrive afterwards for the setup as mentioned! thanks! cheers
  • Anonymous
    May 31, 2016
    Thank you for this post and it worked for me but was wondering what to do when a different user logs on afterward. Even the same user after logging off and back on I lose the ability to uninstall OneDrive. A new user would also show as "Installed".
    • Anonymous
      June 02, 2016
      Thanks for the feedback Luc! I didn't test that scenario, but have you tried sending the deployment to a user collection ?
  • Anonymous
    June 17, 2016
    The comment has been removed
    • Anonymous
      August 29, 2016
      Hello Nick! thanks for sharing your script. I didn't run into multiple logged on results in my customers. Check Steve Rachui's blog for another approach! cheers
  • Anonymous
    July 01, 2016
    Good post,What about uninstall? Standard users can install the user portion after SYSTEM has run OneDriveSetup.exe /silent... but what if I want to remove (i.e. customers testing and finally not buying).Thanks.
    • Anonymous
      August 29, 2016
      hello Juan, working on that! I hope to have an update on that in some weeks. cheers
      • Anonymous
        February 09, 2017
        Hi Paulo,I am facing problem with uninstall of onedrive. If one user uninstall the onedrive then there is no option for other user uninstall the onedrive .
        • Anonymous
          March 06, 2017
          hello Vishnu! you can try to deploy this to users instead of machines, but I haven't tested it! thanks
  • Anonymous
    July 13, 2016
    Hello I have managed to setup this for ODFB. Thanks for the help but I have a problem. If push this software out it shows Past - due will be installed in software console. The problem is the software never installs it just sits there. If I manually click install button it works fine so the detection\ software is all ok just this pause and manual intervention which is a problem. I need to push it out to 1600 PC's silently. CheersRoss
    • Anonymous
      August 29, 2016
      Hello Ross! thanks for the feedback. Did you get anything in the Appenforce log? cheers
  • Anonymous
    August 04, 2016
    Did someone receive this error message?+++ Application not discovered with script detection.Error code: 0x87D00324 (-2016410844)The application was not detected after installation completed.
    • Anonymous
      August 29, 2016
      hello MGj, check the appdiscovery log to try to understand where the detection part is failing. cheers
  • Anonymous
    August 11, 2016
    The comment has been removed
    • Anonymous
      August 29, 2016
      hello Don, awesome! thanks for sharing that. just want to add the information that the wmi query usually doesn't run as expected inside virtual machine and the current logged on user is not returned. cheers!
  • Anonymous
    October 03, 2016
    The comment has been removed
    • Anonymous
      October 11, 2016
      are you using virtual machines?
  • Anonymous
    October 04, 2016
    The comment has been removed
    • Anonymous
      October 11, 2016
      Hello Juergen, that's great! thanks for the feedback !
  • Anonymous
    November 02, 2016
    The comment has been removed
    • Anonymous
      November 07, 2016
      hello Dusky! 1. Yes 2. Following this instructions still will have you to configure the accounts per user. Cheers!
  • Anonymous
    November 30, 2016
    The comment has been removed
    • Anonymous
      March 06, 2017
      Hello Allen, having a group policy usually as a higher priority than everything else in SCCM, so I'm afraid that with that gpo you won't be able to run the powershell. You could however have a different detection method. thanks!
  • Anonymous
    December 06, 2016
    The comment has been removed
    • Anonymous
      March 06, 2017
      The comment has been removed
  • Anonymous
    February 28, 2017
    We really want to install onedrive next gen client for every user on the same pc, but If I read correctly this script just works once per pc?does someone has a workaround for that? The only one I have read is the active setup key, but we would like to use sccm.I really do not understand that the developers don't know what a system base installation is, so frustrating.
  • Anonymous
    March 01, 2017
    Thanks for the detection script. I found a more efficient and reliable way is to use the %LOCALAPPDATA% variable to check for the presence of OneDrive.exe (which caters for the case where a user has another profile directory e.g. "C:\Users\JSmith.domain" - the initial profile may have become corrupted)Replace:$User = gwmi win32_computersystem -Property Username$UserName = $User.UserName$UserSplit = $User.UserName.Split(“\”)$OneDrive = “$env:SystemDrive\users\” + $UserSplit[1] +“\appdata\local\microsoft\onedrive\onedrive.exe”with $OneDrive = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"
    • Anonymous
      March 01, 2017
      Actually - my previous suggestion works OK if you run it standalone (as I tested it) - but does not work in SCCM (it gets the system account's profile).
  • Anonymous
    March 06, 2017
    It's a very nice procedure.I've got 2 questions:- How do you deal with situations where the user profile is not located in "C:\users\USERID"?- How do you deal with roaming profiles? (I can't get "OneDriveSetup.exe" to install because my roaming profile has a registry for a newer version of OneDrive. I get error "80040692" until I delete the OneDrive key in my registry.)
    • Anonymous
      March 06, 2017
      hey Pascal! you need to adapt the script for that. thanks!
      • Anonymous
        March 13, 2017
        Hello Paulo,Any idea on how to adjust the script?
        • Anonymous
          April 13, 2017
          sorry Pascal, haven't used this with Roamingprofiles! cheers
          • Anonymous
            September 14, 2017
            Roaming profiles aren't supported:Roaming, Mandatory and Temporary Windows profiles aren't supported. The OneDrive for Business sync app only supports users who can write to OneDrive for Business application directories.https://support.microsoft.com/en-us/help/3125202/restrictions-and-limitations-when-you-sync-files-and-folders
  • Anonymous
    April 03, 2017
    here's a much shorter detection script which also works for VDI sessions$Path = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"If (Test-Path $Path){Write-Host "$Path Exists"}
    • Anonymous
      April 13, 2017
      nice Matt! thanks! cheers
  • Anonymous
    July 27, 2017
    I get a old errorError Code: 0xFFFFFFFF (-1) I look in Appenforce log and it doesn't even show as trying to install.Andy ideas.
  • Anonymous
    February 13, 2019
    The comment has been removed
    • Anonymous
      May 23, 2019
      nicely done! thanks for sharing