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 https://docs.microsoft.com/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