Navigating the World of OneDrive File Attributes
In our ever-connected digital landscape, OneDrive has remained a prominent player in the realm of cloud storage and collaboration. Managing files and syncing them across devices is generally effortless, but have you ever wondered about the nitty-gritty details of how OneDrive handles these files locally? Today, we’ll unveil the magic of PowerShell and explore how to retrieve and interpret the attributes of local OneDrive files, specifically focusing on their File On Demand (FOD) states.
Beggining Our Quest
My journey began with a simple yet intriguing task: I wanted to create a script that could examine local OneDrive files and extract their attributes, particularly shedding light on their FOD states. After some exploration, I stumbled upon a reference script from Tristan Tyson’s tech blog that seemed promising.
The initial script was straightforward:
|
|
This script looped through files and displayed their attributes. However, to adapt it for my needs, I needed to focus on OneDrive’s specific attributes.
The Reference Table and Adjustments
The reference script came with a table that associated attribute values with file states:
File State | Attribute |
---|---|
Cloud-Only | 5248544 |
Always available | 525344 |
Locally Available | ReparsePoint |
However, during my testing phase, I realized that the provided values didn’t correctly align with OneDrive’s attributes on my machine.
I desperately scoured the archives in search of any mention of the elusive attributes but alas, I came up short in this endeavor. So, I rolled up my sleeves and manually tested different sync states to identify the correct attribute values and their corresponding human-readable states.
For testing (and ultimately my end goal), I took the reference script and adjusted it to drill down to the current users OneDrive (Commercial) directory. This allowed me (with toggling sync states multiple times) to identify the different attributes assiociated with different states.
|
|
Armed with the information gathered in the testing phase, I then constructed my own reference table.
File State | Attribute |
---|---|
Cloud-Only | 5248544 |
Always available | 525344 |
Downloading | 4724256 |
Uploading | 1049632 |
Locally Available | Archive, ReparsePoint |
Hidden System File | 1572902 |
There might be additional attributes I didn’t come across during my testing phase. I’ll keep exploring and updating the reference table here whenever I spot them. For now, I deemed the collected data sufficient to make sense of the attribute values in a way that humans can understand.
Cracking the Code: The Finished Script
After traveling so far on this quest, the elements of the script emerged, ready to unveil the OneDrive attributes we sought. To that end, I focused on generating clear and comprehensible results into a table format, leveraging a switch statement and PSCustomObject to complete this final task.
|
|
The script was then tested for its efficiency at gathering the needed information.
With this final script, I was able to successfully list the OneDrive file attributes as desired. The script translates OneDrive file attribute values into human-readable states, making it easier than ever to understand the synchronization status of each file.
Final Thoughts and Further Explorations
In this exhilarating journey, we ventured into the realm of PowerShell to reveal the attributes of local OneDrive files. Armed with a script that interprets File On Demand states, we’ve unlocked a deeper understanding of file synchronization. As we continue our IT expeditions, let’s remain curious and ever-ready to explore the intricacies of our digital world.