In previous blog posts, we talked about optimizations as they related to the Windows Operating System, including Active Setup, the Microsoft Store, Services & Scheduled Tasks, and more.
The focus of this blog series will be Application Optimizations. We started this series with our Introduction to Application Optimization, which showcases common items to look for when it comes to Application Optimization. We followed up with Application Optimization Essentials: Google Chrome, then soldiered on with Application Optimization Essentials: Microsoft Edge, before rounding out the most common browsers with Application Optimization Essentials: Mozilla Firefox. We then switched to a different type of application next, Adobe Acrobat Reader. This blog will deep dive into a common application, and one that is generally forced on you whether you like it or not, Microsoft OneDrive.
Since these blog posts will be hyper-focused on just one application or application type, they will be mostly shorter in nature, but will still provide you with good information that you can use to optimize your environment.
Please note, the optimizations provided in this blog are intended only as a guide. Be sure to test the optimizations described internally before pushing the changes to your production environment.
Now, let’s jump directly in.
What is Microsoft OneDrive?
Microsoft OneDrive is an online cloud storage service that … wait. Why are we talking about this here? Frame has a full Solutions Guide specifically designed for Microsoft OneDrive. Rather than waste precious space here, go visit it then come back here for just the optimizations.
Ok, so I read through your Solutions Guide and have installed Microsoft OneDrive, now what?
As how Microsoft handles OneDrive in their operating system can be tricky, so too are the optimizations possible for OneDrive. As such, we will need to talk about these optimizations out of the normal order from previous blogs, with more background as to why.
Preventing the per-user installation
The first piece to discuss was described in the Solutions Guide; how OneDrive installs on a per user basis.
To understand this, it may be beneficial to read the Frame Image Management: Preconfiguring user-specific settings for all users from the Sandbox blog, as it details how to use the Default Users registry hive. Basically, inside the Default Users registry hive, located at
C:\Users\Default, is a registry location
SOFTWARE\Microsoft\Windows\CurrentVersion\Run that contains a Startup registry value which is used by the operating system to do the initial, per-user installation of OneDrive on each users’ initial logon. This can be seen below in Figure 1, with the manually added Default profile hive called Default2.
In scenarios where you don’t want OneDrive as part of your image, the best practice is to remove the OneDriveSetup registry value, as shown above.
In scenarios where you want the per-machine version of OneDrive as part of your image, removing this value provides no benefit, as the application is already installed, albeit as part of the machine instead of the user. It is still recommended to remove this registry value as a basic optimization, to prevent resource utilization.
There is a single optimizable service for OneDrive, but it only exists in the per-machine installation of OneDrive.
As can probably be inferred, this service is used in the per-machine installation of OneDrive to keep the application updated. For easier non-persistent image management, best practice is to disable this service.
There is no matching service for OneDrive in the per-user installation, as the updating of OneDrive is handled via scheduled tasks.
We can use the same PowerShell commands as described in Part 3 of the Windows OS Optimization Essentials blog post.
There are a number of scheduled tasks for OneDrive, some are conditional based upon the installation method, while others will exist when OneDrive is installed, regardless of how it was installed.
In a per-user scenario, OneDrive will show multiple scheduled tasks, based upon certain criteria. If you are logged into the operating system as an administrator, such as in the Sandbox, you may only see two scheduled tasks, but you may see two scheduled tasks per current user in a BYO image scenario.
In the figure below, two administrative accounts existed in my BYO image Sandbox, so I was able to see each scheduled task for each user. On my workload VMs, where I was logged in using a non-administrative account, the only scheduled task visible was for that user.
In a per-machine scenario, the OneDrive scheduled tasks will differ. The per-user OneDrive Standalone Update Task (SID) task will be replaced by a per-machine OneDrive Per-Machine Standalone Update Task, while the Reporting tasks aren’t touched.
The per-machine Scheduled Task can be disabled as per normal, as described in Part 3 of the Windows OS Optimization Essentials blog, but the per-user Scheduled Tasks were a different beast entirely.
It took me awhile, but I was able to figure out how to prevent these per-user scheduled tasks from being created. You would think it would be part of the Startup registry value discussed above, but no, why would it be that easy?
To prevent these scheduled tasks from being created on a per-user basis, even when the per-machine installation method was used, we have to return to the Default Users registry hive. Once there, browse to SOFTWARE\Microsoft\OneDrive and you will see a value called EnableTHDFFeatures. While I can’t say everything this value does, I can verify that switching this value from 1 to 0 prevented the per-user scheduled tasks from being created on the Workload VMs on a per-user basis. As with any changes to the Default Users registry hive, any changes made are only pertinent for first time user logins, not users who have an existing profile.
Changing this value will prevent the creation of both the per-user Standalone Update Tasks that are created with the per-user installation, as well as the per-user Reporting Tasks that are created with both the per-user and per-machine installation.
If you wish to remove the Per-User Reporting Tasks from the current account, you can use the command:
Unregister-ScheduledTask -TaskName “OneDrive Reporting*”
The * wildcard will ensure that all Scheduled Tasks that start with OneDrive Reporting will be unregistered. When unregistered, the scheduled tasks will not be visible in the Task Scheduler applet anymore.
Please note that updating OneDrive will recreate the Per-User Reporting Tasks, requiring that they be optimized again, if desired.
How can I automate this?
If you are looking for a way to automate this process, look no further. Outside of the basic optimizations like disabling scheduled tasks and services, for which descriptions of this process are linked above, below are the commands that will implement the Default User optimizations for OneDrive.
Please note these commands come with no error checking. Please use the below commands at your own discretion and please create backups before doing any optimizations in your environment.
Reg Load HKEY_Users\Default “C:\Users\Default\NTUser.dat”
Remove-ItemProperty -Path “Registry::HKU\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run” -Name “OneDriveSetup” -ErrorAction SilentlyContinue
Set-ItemPropertyValue -Path “Registry::HKU\Default\SOFTWARE\Microsoft\OneDrive” -Name “EnableTHDFFeatures” -Value “0”
Reg Unload HKEY_Users\Default
This blog post covers the optimization options for Microsoft OneDrive. The next blog will cover optimizations for Java Runtime Environment (JRE).
As always, any information provided in this guide are recommendations only and should be vetted against your environment before implementing in a production scenario.
Need help with your Frame deployment, have an idea for a new use case, or just want to learn more about Frame?
Email us at firstname.lastname@example.org and one of our experts will reach out!
More content created byJake Norman
© 2024 Dizzion, Inc. All rights reserved. Frame, the Frame logo and all Dizzio product, feature and service names mentioned herein are registered trademarks of Dizzion, Inc. in the United States and other countries. All other brand names mentioned herein are for identification purposes only and may be the trademarks of their respective holder(s). This post may contain links to external websites that are not part of Dizzion. Dizzion does not control these sites and disclaims all responsibility for the content or accuracy of any external site. Our decision to link to an external site should not be considered an endorsement of any content on such a site. Certain information contained in this post may relate to or be based on studies, publications, surveys and other data obtained from third-party sources and our own internal estimates and research. While we believe these third-party studies, publications, surveys and other data are reliable as of the date of this post, they have not independently verified, and we make no representation as to the adequacy, fairness, accuracy, or completeness of any information obtained from third-party sources.