Forum Discussion

AlltheBytes's avatar
AlltheBytes
Copper Contributor
Feb 14, 2023
Solved

O365 Batch Deployment -- OneDrive Auto Configuration

Hello all,   I have been working on a batch script that will deploy all of my company's "standard" programs to new PC's as they come across my desk. It is coming along nicely, and I need to configu...
  • Mark_Albin's avatar
    Feb 14, 2023

    AlltheBytes

    You can automate the configuration of OneDrive to sync only the user's Desktop and Documents folder by using the OneDrive client's command-line interface (CLI). You can use the CLI in a batch script to configure OneDrive for each user.

    Here's an example of how I would do this:

     

    1. Download the OneDrive client: You'll need to download the OneDrive client for your operating system if it is not already installed on the new PC's.
    2. Open Command Prompt: Open the Command Prompt as an administrator on the new PC.
    3. Run the following command:

      OneDrive.exe /configurepolicies "{\"FilesOnDemandEnabled\":true,\"KnownFolderMoveEnabled\":true,\"KnownFolders\":[{\"Name\":\"Desktop\",\"Target\":\"OneDrive\"},{\"Name\":\"Documents\",\"Target\":\"OneDrive\"}]}"


    4. Add the command to your batch script: You can add this command to your batch script so that it   runs automatically when you deploy OneDrive and the other "standard" programs to the new PC's.

    By using the OneDrive CLI in a batch script, you can automate the configuration of OneDrive to sync only the user's Desktop and Documents folder, saving you time and effort. Keep in mind that OneDrive may need to be restarted after the configuration is applied for the changes to take effect.

     

Resources