Deploying the new Onedrive Next Generation Sync client as MSI through Intune to Windows 10

Onedrive for Business’s client, the new Next Generation Sync client, is awesome. Obviously.

So you want it on your devices, but Microsoft distributes it as .exe. Nasty, because I want to manage Windows 10 as mobile devices through Intune, and that only allowes me to distribute as MSI.

I created an MSI for Onedrive for Business’s Next Generation Client using Advanced Installer. Because I’m not allowed to redistribute Microsoft’s .exe, this MSI downloads the .exe from Microsoft’s website, it uses /silent and /takeover as installation switches.

This is the installer that self-downloads Onedrive NGen: OnedriveNGSC.msi (right click, save as).

Optionally, you can change the URL from which the .exe installer is downloaded by supplying downloadURI as parameter to the MSI. (e.g. msiexec /i OnedriveNGSC.msi downloadURI=”http://www.example.com/file.exe”)

The MSI is an empty placeholder for the following Powershell script:

 

Param(
$downloadURI
)

function runProcess ($cmd, $params, $windowStyle=1) {
    $p = new-object System.Diagnostics.Process
    $p.StartInfo = new-object System.Diagnostics.ProcessStartInfo
    $exitcode = $false	
    $p.StartInfo.FileName = $cmd
    $p.StartInfo.Arguments = $params
    $p.StartInfo.UseShellExecute = $False
    $p.StartInfo.RedirectStandardError = $True
    $p.StartInfo.RedirectStandardOutput = $True
    $p.StartInfo.WindowStyle = $windowStyle; #1 = hidden, 2 =maximized, 3=minimized, 4=normal
    $null = $p.Start()
    $output = $p.StandardOutput.ReadToEnd()
    $exitcode = $p.ExitCode
    $p.Dispose()	
    $exitcode
    $output
}

#download the client
$exePath = Join-Path $Env:Temp "onedriveNGSC.exe"
try{
		invoke-webrequest $downloadURI -OutFile $exePath -ErrorAction Stop
}catch{
		Throw "Failed to download the installer from $downloadURI"
}

$res = runProcess $exePath "/silent /takeover"

#check if return code is 0
if(0 -ne $res[0]){
		Throw "Failed to install client: $($res[0]) $($res[1])"
}

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz