title: Automate OneDrive for Business local setup for use with Folder Redirection
body: <p>after successfully enabling automatic sign in and mapping a drive to OneDrive for business, I want to take it one step further in replacing on-premise fileshares:</p>
  
  <p>I want to use folder redirection to make sure all user data is stored on the OneDrive, just like we make sure all user data is stored on the fileserver at the moment.</p>
  
  <p>A direct redirection to the cloud is not possible. It IS possible to redirect to the local OneDrive folder from which data will get synced to the cloud.</p>
  
  <p>There are some challenges in this regard:</p>
  
  <ol>
  <li>The user has to start the 'OneDrive for business' app to setup the
  sync and local folder.</li>
  <li>It is possible for the user to change the default location.</li>
  </ol>
  
  <p>For use with folder redirection we need to make sure:</p>
  
  <ol>
  <li>Sync is enabled and there actually <em>is</em> a local folder...</li>
  <li>This folder needs to be in the same location for every user.</li>
  </ol>
  
  <p>I thought it would be quite simple something like this:</p>
  
  <pre><code>onedrive.exe -sync c:\users\%username%\Onedrive
  </code></pre>
  
  <p>But no way )-:</p>
  
  <p>Turns out the executable is called 'GROOVE.EXE' and resides in the Office directory.</p>
  
  <p>Documentation is virtually non-existent, I have managed to determine the following command-line switches:</p>
  
  <pre><code>/clean
  /clean all
  /RunFolderSync
  /OneNoteStub:
  /TakeOffline:
  /TrayOnly
  </code></pre>
  
  <p>Running the following command starts OneDrive for business silent and in the tray but the user has to right-click and use 'Sync A new library', not usable!</p>
  
  <pre><code>GROOVE.EXE /RunFolderSync /TrayOnly
  </code></pre>
  
  <p>The following invokes the 'Ready to sync?'-dialog but the user can change the location and has to click 'Sync Now'. Also not usable!</p>
  
  <pre><code>GROOVE.EXE" /TakeOffline: https://contosocom-my.sharepoint.com/personal/%SKYDRIVEID%/Documents
  </code></pre>
  
  <p>Would like to run the last command silent and settle for the default location!</p>
  
  <p>I have been messing with prepopulating registry keys that are created but to no avail.</p>
  
  <p>Anyone?</p>