none
How do I get/set OneDrive "Files On Demand" status from PowerShell?

    General discussion

  • 1. I know that I can determine whether a file is available locally with CMD's "DIR" command as the files that are not available locally have their size displayed in parentheses:

    PS C:/Users/steph> cmd /c dir D:\users\sto\onedrive\cloudonly\amazon\20170927\WP_20170927_18_14_51_Pro.jpg
     Volume in drive D is DATA
     Volume Serial Number is 3C43-3052
     Directory of D:\users\sto\onedrive\cloudonly\amazon\20170927

    2017-12-17  02:07       (3,628,427) WP_20170927_18_14_51_Pro.jpg

    How do I get that information from PowerShell without invoking 'cmd /c dir'?

    How do I get that information for folders?

    2. I know that I can control the offline status using ATTRIB (see https://hansbrender.com/tag/unpinned/, in German). Is there a way to achieve the same using PowerShell without invoking ATTRIB.EXE?

    Note: if some PowerShell-embedded-C# / .NET invocation is needed, that's fine by me...

    Friday, January 19, 2018 6:46 AM

All replies

  • I don't have OneDrive - so I cannot verify. The equivalent of DIR for the Powershell world would be Get-ChildItem. But anyway you can use ATTRIB.EXE from inside Powershell Console as well.

    BTW: There is a German Powershell forum as well. I know sometimes it is easier to ask or to explain something in your native language.


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH_666 Friday, January 19, 2018 9:15 AM
    Friday, January 19, 2018 9:14 AM
  • I hate to say, but what's the point of this response? I doesn't bring any information...

    I do know that Get-ChildItem is the way to find/list files in PowerShell [Note: I'm a senior software engineering professional / architect / developer...], but the FileInfo / DirectoryInfo objects it returns do not contain information about the "OneDrive status."

    And yes I also know I can invoke ATTRIB.EXE from PowerShell scripts.

    P.S. German is not my native language (French is, I took German as first foreign language and English as second foreign language at high school) ;-)

    Friday, January 19, 2018 10:01 AM
  • $file.Attributes is an integer flag field.  It changes value depending on the state of the file.  I haven't yet decoded the bits.


    \_(ツ)_/

    Friday, January 19, 2018 11:30 AM
  • All OneDrive files are set to "ReparsePoint" but there I at least one more flag that is not defined in the enum which causes the display to show as a number and not a decoded attribute like non-OD files.

    If the file is not local then the display is "Archive, ReparsePoint" (1056).  If I set it to be local the display is "5248544"

    These are the added flags:

    PS C:\scripts> '{0:x}' -f 5248544
    501620
    PS C:\scripts> '{0:x}' -f 1056
    420
    PS C:\scripts> '{0:x}' -f (5248544-1056)
    501200


    \_(ツ)_/

    Friday, January 19, 2018 11:43 AM
  • 0x1000 - offline
    0x0200 - SparseFile

    0x500000 - 2 unknown flags 0x400000 and 0x100000

    We can decode this by ignoring those flags:

    PS D:\scripts> [System.IO.FileAttributes](0x501620 -bxor 0x500000)
    Archive, SparseFile, ReparsePoint, Offline

    We can also build a new enum and cast to it.


    \_(ツ)_/



    • Edited by jrv Friday, January 19, 2018 12:04 PM
    Friday, January 19, 2018 12:01 PM
  • Thanks for putting me on the right track (for some reason, I was unsure that it was "just about the Attributes"... my bad ;-) )

    I've written a small script to experiment with part 1 of my question: reading/decoding the "OneDrive status."

    Here's the script:

    foreach ($v in [enum]::GetValues([System.IO.FileAttributes])) 
    {
    Write-Host('0x{0:X8}: {1}' -f [int] $v, $v)
    }

    # from C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\um\winnt.h
    $FILE_ATTRIBUTE_UNPINNED = 0x00100000 # NOT documented at https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117%28v=vs.85%29.aspx
    $FILE_ATTRIBUTE_PINNED = 0x00080000 # NOT documented at https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117%28v=vs.85%29.aspx
    $FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000 # documented at https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117%28v=vs.85%29.aspx

    $itempaths = @(
    'D:\users\sto\onedrive\Free up space.txt',
    'D:\users\sto\onedrive\Always keep on this device.txt',
    'D:\users\sto\onedrive\Created on this device.txt',
    'd:\users\sto\onedrive\somefile.txt',
    'd:\users\sto\photos\Cleanup.ps1',
    'D:\users\sto\onedrive\Free up space',
    'D:\users\sto\onedrive\Always keep on this device',
    'D:\users\sto\onedrive\Created on this device')
    foreach ($itempath in $itempaths)
    {
    $item = get-item $itempath
    $attributes = $item.Attributes
    $hexattributes = '0x{0:X8}' -f [int] $attributes
    $knownattributes = $attributes -band (-bnot ($FILE_ATTRIBUTE_UNPINNED -bor $FILE_ATTRIBUTE_PINNED -bor $FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS))
    Add-Member -InputObject $item -MemberType NoteProperty -Name HexAttributes -Value $hexattributes
    Add-Member -InputObject $item -MemberType NoteProperty -Name KnownAttributes -TypeName [System.IO.FileAttributes] -Value $knownattributes
    $pinned = ($attributes -band $FILE_ATTRIBUTE_PINNED) -ne 0
    Add-Member -InputObject $item -MemberType NoteProperty -Name FILE_ATTRIBUTE_PINNED -TypeName [System.Boolean] -Value $pinned
    $unpinned = ($attributes -band $FILE_ATTRIBUTE_UNPINNED) -ne 0
    Add-Member -InputObject $item -MemberType NoteProperty -Name FILE_ATTRIBUTE_UNPINNED -TypeName [System.Boolean] -Value $unpinned
    $recall_on_access = ($attributes -band $FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) -ne 0
    Add-Member -InputObject $item -MemberType NoteProperty -Name FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS -TypeName [System.Boolean] -Value $recall_on_access
    $item | Select-Object -Property FullName, Length, Attributes, HexAttributes, KnownAttributes, FILE_ATTRIBUTE_PINNED, FILE_ATTRIBUTE_UNPINNED, FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS
    }

    foreach ($itempath in $itempaths)
    {
    $item = get-item $itempath
    $item | ft -AutoSize
    }

    And what it outputs:

    0x00000001: ReadOnly
    0x00000002: Hidden
    0x00000004: System
    0x00000010: Directory
    0x00000020: Archive
    0x00000040: Device
    0x00000080: Normal
    0x00000100: Temporary
    0x00000200: SparseFile
    0x00000400: ReparsePoint
    0x00000800: Compressed
    0x00001000: Offline
    0x00002000: NotContentIndexed
    0x00004000: Encrypted
    0x00008000: IntegrityStream
    0x00020000: NoScrubData
    
    
    FullName                             : D:\users\sto\onedrive\Free up space.txt
    Length                               : 2760
    Attributes                           : 5248544
    HexAttributes                        : 0x00501620
    KnownAttributes                      : Archive, SparseFile, ReparsePoint, Offline
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : True
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : True
    
    FullName                             : D:\users\sto\onedrive\Always keep on this device.txt
    Length                               : 10388
    Attributes                           : 525344
    HexAttributes                        : 0x00080420
    KnownAttributes                      : Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : True
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    FullName                             : D:\users\sto\onedrive\Created on this device.txt
    Length                               : 2304
    Attributes                           : Archive, ReparsePoint
    HexAttributes                        : 0x00000420
    KnownAttributes                      : Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    FullName                             : D:\users\sto\onedrive\somefile.txt
    Length                               : 7
    Attributes                           : 5248544
    HexAttributes                        : 0x00501620
    KnownAttributes                      : Archive, SparseFile, ReparsePoint, Offline
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : True
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : True
    
    FullName                             : D:\users\sto\photos\Cleanup.ps1
    Length                               : 1217
    Attributes                           : Archive
    HexAttributes                        : 0x00000020
    KnownAttributes                      : Archive
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    FullName                             : D:\users\sto\onedrive\Free up space
    Length                               : 
    Attributes                           : 1049648
    HexAttributes                        : 0x00100430
    KnownAttributes                      : Directory, Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : True
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    FullName                             : D:\users\sto\onedrive\Always keep on this device
    Length                               : 
    Attributes                           : 525360
    HexAttributes                        : 0x00080430
    KnownAttributes                      : Directory, Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : True
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    FullName                             : D:\users\sto\onedrive\Created on this device
    Length                               : 
    Attributes                           : Directory, Archive, ReparsePoint
    HexAttributes                        : 0x00000430
    KnownAttributes                      : Directory, Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False
    
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name             
    ----          ------------- ------ ----             
    -a---l 2018-01-20     07:54 (2760) Free up space.txt
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name                          
    ----          ------------- ------ ----                          
    -a---l 2018-01-20     07:55  10388 Always keep on this device.txt
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name                      
    ----          ------------- ------ ----                      
    -a---l 2018-01-20     08:14   2304 Created on this device.txt
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name        
    ----          ------------- ------ ----        
    -a---l 2017-05-18     12:44    (7) somefile.txt
    
    
    
    
        Directory: D:\users\sto\photos
    
    
    Mode          LastWriteTime Length Name       
    ----          ------------- ------ ----       
    -a---- 2017-08-16     16:21   1217 Cleanup.ps1
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name         
    ----          ------------- ------ ----         
    da---l 2018-01-20     08:56        Free up space
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name                      
    ----          ------------- ------ ----                      
    da---l 2018-01-20     08:56        Always keep on this device
    
    
    
    
        Directory: D:\users\sto\onedrive
    
    
    Mode          LastWriteTime Length Name                  
    ----          ------------- ------ ----                  
    da---l 2018-01-20     08:56        Created on this device
    
    
    



    (BTW you'll notice that the default formatting for the Length property of a FileInfo object uses parentheses just like CMD's "DIR" does...)

    Based on this, we have enough information to determine which of the three OneDrive "statuses" a file can be in:

    - online-only

    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : True
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : True

    - locally available

    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False

    - always available

    FILE_ATTRIBUTE_PINNED                : True
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False

    Note that 3 attribute bits are involved, which should allow 8 combinations, but only 3 combinations are used (I would expect that the other 5 are not valid / supported).

    There's a more general discussion about the meaning of all the "new" attribute bits at https://superuser.com/questions/1214542/what-do-new-windows-8-10-attributes-mean-no-scrub-file-x-integrity-v-pinn/1287315 so I won't duplicate it here.

    Now I'm going to move to part 2 of my question: how to change the status. At first glance, changing the attribute bits seems to be enough for files, but I still need to look at folders. Stay tuned ;-)



    • Edited by sba923 Sunday, January 21, 2018 3:47 PM bug in script
    Saturday, January 20, 2018 9:00 AM
  • This is much easier and can be easily updated when needed.

    enum fileAttributes  {
    	ReadOnly = 0x00000001
    	Hidden = 0x00000002
    	System = 0x00000004
    	Directory = 0x00000010
    	Archive = 0x00000020
    	Device = 0x00000040
    	Normal = 0x00000080
    	Temporary = 0x00000100
    	SparseFile = 0x00000200
    	ReparsePoint = 0x00000400
    	Compressed = 0x00000800
    	Offline = 0x00001000
    	NotContentIndexed = 0x00002000
    	Encrypted = 0x00004000
    	IntegrityStream = 0x00008000
    	NoScrubData = 0x00020000
    	Pinned = 0x00080000
    	Unpinned = 0x00100000
    	RecallOnDataAccess = 0x00400000
    }
    Get-ChildItem c:\Users\userid\OneDrive -Recurse | select Name, @{n='Attributes';e={[fileAttributes]$_.Attributes.Value__}}

    The biggest problem is that you are missing on critical high flgg.  Find it and add it to the enume and it will work.

    I would add all flags with unknowns marked as U+itnumber

    eg. U30,U31, ...

    All flags current and future will be decoded and you can see any flag not defined and its bit number.

    The SDK header does not have at least two OneDrive specific flags.


    \_(ツ)_/



    • Edited by jrv Sunday, January 21, 2018 6:51 PM
    Sunday, January 21, 2018 6:45 PM
  • Here is the complete enum cloned from the 2016/10 SDK.

    enum ffileAttributes {
    	Readonly = 0x00000001
    	Hidden = 0x00000002
    	System = 0x00000004
    	Directory = 0x00000010
    	Archive = 0x00000020
    	Device = 0x00000040
    	Normal = 0x00000080
    	Temporary = 0x00000100
    	SparseFile = 0x00000200
    	ReparsePoint = 0x00000400
    	Compressed = 0x00000800
    	Offline = 0x00001000
    	NotContentIndexed = 0x00002000
    	Encrypted = 0x00004000
    	IntegrityStream = 0x00008000
    	Virtual = 0x00010000
    	NoScrubData = 0x00020000
    	RecallOnOpen = 0x00040000
    	Pinned = 0x00080000
    	Unpinned = 0x00100000
    	U200000 = 0x00200000
    	RecallOnDataAccess = 0x00400000
    	U800000 = 0x00800000
    	U1000000 = 0x01000000
    	U2000000 = 0x02000000
    	U4000000 = 0x04000000
    	U8000000 = 0x08000000
    	U10000000 = 0x10000000
    	U20000000 = 0x20000000
    	U40000000 = 0x40000000
    	U80000000 = 0x80000000
    }

    To get a full decode we must create a C# compiled "flags" type that can decode on a cast.

    PS>  I disagree with the "unpinned" name.  It means else.  "Pinned" set/not set defines a "pinned" file.


    \_(ツ)_/



    • Edited by jrv Monday, January 22, 2018 9:00 PM
    Sunday, January 21, 2018 7:25 PM
  • Here is the flags method

    $code = @'
    using System;
    
    [FlagsAttribute]
    public enum FileAttributesEx : uint {
    	Readonly = 0x00000001,
    	Hidden = 0x00000002,
    	System = 0x00000004,
    	Directory = 0x00000010,
    	Archive = 0x00000020,
    	Device = 0x00000040,
    	Normal = 0x00000080,
    	Temporary = 0x00000100,
    	SparseFile = 0x00000200,
    	ReparsePoint = 0x00000400,
    	Compressed = 0x00000800,
    	Offline = 0x00001000,
    	NotContentIndexed = 0x00002000,
    	Encrypted = 0x00004000,
    	IntegrityStream = 0x00008000,
    	Virtual = 0x00010000,
    	NoScrubData = 0x00020000,
    	EA = 0x00040000,
    	Pinned = 0x00080000,
    	Unpinned = 0x00100000,
    	U200000 = 0x00200000,
    	RecallOnDataAccess = 0x00400000,
    	U800000 = 0x00800000,
    	U1000000 = 0x01000000,
    	U2000000 = 0x02000000,
    	U4000000 = 0x04000000,
    	U8000000 = 0x08000000,
    	U10000000 = 0x10000000,
    	U20000000 = 0x20000000,
    	U40000000 = 0x40000000,
    	U80000000 = 0x80000000
    }
    '@
    Add-Type $code

    Get-ChildItem c:\Users\userid\OneDrive -Recurse |
    select FullName, @{n='Attributes';e={[fileAttributesex]$_.Attributes.Value__}}|fl

    Get-ChildItem c:\Users\jvierra\OneDrive -Recurse | select @{n='Attributes';e={[fileAttributesex]$_.Attributes.Value__}}|
    where {$_.Attributes -notmatch 'Directory'}

    We get  "SparseFile, ReparsePoint, Offline, RecallOnDataAccess" and other flag sets on OneDrive.

    The plus of doing it this way is that you can filter on a specific flag by name.


    \_(ツ)_/

    Sunday, January 21, 2018 8:02 PM
  • Thanks for the approach to decode the flags in a "PowerShell-elegant way."

    But wait: The plot thickens.

    It seems there are two possible combinations for "online-only" files.

    1. if a file is created locally, it will get sync'ed up to OneDrive. If you then change its status to "online-only" using "Free up space" you'll get:

    FullName                             : D:\users\sto\onedrive\Free up space.txt
    Length                               : 2760
    Attributes                           : Archive, ReparsePoint
    HexAttributes                        : 0x00000420
    KnownAttributes                      : Archive, ReparsePoint
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : False

    2. However, if the file is created on / uploaded to the OneDrive.com website you'll get the same visual representation of the Status in File Explorer (the "cloud" icon), but the flags are different:

    FullName                             : D:\users\sto\OneDrive\Created via website\Uploaded via website.txt
    Length                               : 858
    Attributes                           : 4199968
    HexAttributes                        : 0x00401620
    KnownAttributes                      : Archive, SparseFile, ReparsePoint, Offline
    FILE_ATTRIBUTE_PINNED                : False
    FILE_ATTRIBUTE_UNPINNED              : False
    FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : True

    Note that in case #2 the behavior is rather different (and confusingly so): as soon as you access "something" about the file (but don't ask to retrieve the contents), then the file is downloaded and changed to "locally available":

    PS C:/Users/steph> $item = (get-item 'D:\users\sto\onedrive\Created via website\Uploaded via website.txt')
    PS C:/Users/steph> $item
        Directory: D:\users\sto\onedrive\Created via website
    Mode                LastWriteTime         Length Name                                                                           
    ----                -------------         ------ ----                                                                           
    -a---l       2018-01-22     20:42          (858) Uploaded via website.txt                                                       
    PS C:/Users/steph> $item | select *
    PSPath            : Microsoft.PowerShell.Core\FileSystem::D:\users\sto\onedrive\Created via website\Uploaded via website.txt
    PSParentPath      : Microsoft.PowerShell.Core\FileSystem::D:\users\sto\onedrive\Created via website
    PSChildName       : Uploaded via website.txt
    PSDrive           : D
    PSProvider        : Microsoft.PowerShell.Core\FileSystem
    PSIsContainer     : False
    Mode              : -a---l
    VersionInfo       : File:             D:\users\sto\onedrive\Created via website\Uploaded via website.txt
                        InternalName:     
                        OriginalFilename: 
                        FileVersion:      
                        FileDescription:  
                        Product:          
                        ProductVersion:   
                        Debug:            False
                        Patched:          False
                        PreRelease:       False
                        PrivateBuild:     False
                        SpecialBuild:     False
                        Language:         
                        
    BaseName          : Uploaded via website
    Target            : {}
    LinkType          : 
    Name              : Uploaded via website.txt
    Length            : 858
    DirectoryName     : D:\users\sto\onedrive\Created via website
    Directory         : D:\users\sto\onedrive\Created via website
    IsReadOnly        : False
    Exists            : True
    FullName          : D:\users\sto\onedrive\Created via website\Uploaded via website.txt
    Extension         : .txt
    CreationTime      : 2018-01-22 20:44:08
    CreationTimeUtc   : 2018-01-22 19:44:08
    LastAccessTime    : 2018-01-22 20:44:08
    LastAccessTimeUtc : 2018-01-22 19:44:08
    LastWriteTime     : 2018-01-22 20:42:05
    LastWriteTimeUtc  : 2018-01-22 19:42:05
    Attributes        : 4199968
    
    PS C:/Users/steph> ls 'D:\users\sto\onedrive\Created via website\Uploaded via website.txt'
        Directory: D:\users\sto\onedrive\Created via website
    Mode                LastWriteTime         Length Name                                                                           
    ----                -------------         ------ ----                                                                           
    -a---l       2018-01-22     20:42            858 Uploaded via website.txt              

                                            

    My guess is that this is linked to "FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS : True" but I don't understand 1) the rationale that governs that such a file should be retrieved even if you don't open it for reading 2) what actually triggers that download / the status change.

    If you look at that from a different angle, this means:
    1. that there are more than 3 combinations of flags to look for to determine the 3 possible Status values
    2. that the behavior of a file with "Online-only" status is not always what one would expect



    • Edited by sba923 Monday, January 22, 2018 8:18 PM formatting
    Monday, January 22, 2018 8:15 PM
  • Sorry but this has nothing to do with how to decode the attributes.  Try posting in the O365 forums is for help in understanding how OD works.

    The technical docs for the newer version of OD have not been released so you will have to fish for a good answer.


    \_(ツ)_/

    Monday, January 22, 2018 8:23 PM
  • You're definitely right.... choosing the right forum will be a tough call, though, given that part of the functionality is implemented in the OneDrive client and part in the OS itself.

    Monday, January 22, 2018 8:29 PM
  • No.  All of the functionality is in the client.  The proof is that the OS (Net) has not been updated to reflect the changes.  OneDrive is an application that runs in the user session.  It runs against the local file system but does not change the file system.  The Windows 10 SDK already had definitions for sparse files and other elements displayed in the attributes.  The only ones added are the two you call "pinned" and "RecallOnDataAccess" which is not the names of those attributes.

    The sequence of attribute changes is not documented but is dependent on settings in OD and on how the files are sync'd.  File sync'ing and sparse files have been part of Windows for many years but are not documented in the XP/WS2003 SDK version that you used.

    A file available for a local copy will be available after a sync.  If it has not been synce'd then any access of the file entry will likely force a sync.

    You could also post in the developer forums for more information on file syncing.

    "RecallOnDataAccess" and the others will likely get added to the enum on the next release of Net (4.3?).  The major functionality of this is that the flag locally tells the client to download or not download the file.  The client also allows direct access tot he file without downloading a copy.  CHa ging the status may take some time to sync.


    \_(ツ)_/

    Monday, January 22, 2018 8:51 PM
  • Note also that there is one flag your code is ignoring.  "RecallOnOpen" 0x00040000 Which has been defined since Windows 7 I believe.   It is part of the "Sparse" file implementation.  The issue with your linear decoding is just this.  It skips any flags that you have not defined.  Using the enum will decode all flags on the cast including any that you have not defined.  Displaying all of these flags as a decoded flag field will let you more accurately understand what is happening.


    \_(ツ)_/

    Monday, January 22, 2018 9:06 PM
  • You're perfectly right about my (unintentionally) ignoring that flag. I will use your logic from now on to perform my experiments about the operation of the "Files On Demand" feature.

    Thank you so much for your help.

    Tuesday, January 23, 2018 5:49 AM
  • I hate to say, but I have to disagree on this.

    Microsoft documents very clearly that changes had to be made in the OS (introduced in Insider build 16215 , GA'd in Fall Creators Update a.k.a. RS3 / 1709) -- see for instance the video at https://www.youtube.com/watch?v=iqOl3ykf0z8&feature=youtu.be -- and not only in the sync client to support the "Files On Demand" feature. And everywhere someone asks whether the feature could be backported to earlier OSes (Windows 10 <= RS3, or Windows 7/8), the answer is clear that this cannot be done because of the necessary underlying OS changes.

    This is specifically about the key difference between Windows 8's "placeholders" and Windows 10's "Files On Demand": in the former, applications that had not been updated to leverage specific WinRT APIs would not be able to retrieve the contents of "online-only" files. This is what caused the major flood of complaints about "application compatibility" that resulted in Microsoft removing the feature altogether. Windows 10 RS3 and later is able to trigger the downloading of the file contents during the execution of the APIs used to e.g. open a file for reading, in a fully transparent (blocking, from the caller's standpoint) manner.

    It's true that this mechanism leverages flags that had been documented in the SDK in the past, most like for functionality that's also related to caching local copies of remote files, such as "offline files" on a LAN.

    BTW, I haven't been using the XP/WS2003 version of the SDK (seems someone else on this thread has), I'm using one of the most recent released versions (10.0.16299.0, which is IIRC the first version that supported RS3). I'll update to the latest version (10.0.16299.91) and check out for any differences in there.

    Tuesday, January 23, 2018 6:10 AM
  • The files attributes and the flags enum have nothing to do with this.  They are not OS changes and the flags Enum has not been released yet and the flags are still clearly there.  They are also not defined in the SDK.

    Note also that the claims made do not fully match with reality as it is not installed with 1709 update but is installed with a full new install.   MS says this will be installed as they ae ready but many devices will not get this.  None of my systems were updated.  All of my phones were updated.

    he claim that it is OS is because it requires fixes to the OS image which is what is slowing down the distribution.  When manually installed it is at your own risk as the OS install and hardware may have issues.

    Of course all of the details seem to be a secret and all of the videos and pages are mostly marketing.

    When the documentation and Net update are released you will be able to believe most of it.  MS does this more and more lately and frequently dies in a corner with the fast release methods.

    For what you want we will have to wait for the updates and docs.  Meanwhile just use the flags enum for that part.  I suspect that soon there will be a PowerShell module for OneDrive administration.


    \_(ツ)_/

    Tuesday, January 23, 2018 7:33 AM
  • I don't understand your story about not getting the update.

    Is this about getting your OS upgraded to 1709/RS3?*

    Is this about getting the new OneDrive sync client (which will offer "Files On Demand" only if installed on RS3 because it needs the "seamless download on access" feature that RS3 adds).

    In both cases, Microsoft is using staged deployment where they monitor the telemetry data to determine what possible new issues are being faced on newly deployed systems. Depending on the outcome, they tune the "spreading" of that release. This is why not everyone is getting 1709 at the same time, and also why is not getting the new OneDrive sync client at the same time. There is a way to force the upgrade if you want to.

    All my systems have obtained 1709 and the new OneDrive sync client as part of the normal (yet staged) upgrade mechanisms, I never had to perform a full/clean (re)install to get "Files On Demand" to work.

    And: yes, they are lagging behind with respect to documenting all this, and they will probably only document what they deem necessary for application developers to properly interact with the feature.

    Tuesday, January 23, 2018 7:58 PM
  • No.  OneDrive is supposed to update automatically on 1709.  It updates on Windows Phone but not on W10 Pro.   MS posted that the update would be released incrementally as devices are tested for compatibility.  Of course this is also true of semi-annual updates.  Even when released they may not be applied or offered until issues with hardware and software inventory are resolved.

    On all of my HP notebooks and workstations the 1709 update was installed as normal but none have the OneDrive update yet.  MS says be patient.   I think the issue is that these machines have VS206/17 and SQLServer 2012r2 and SQS 2017 installed.


    \_(ツ)_/

    Tuesday, January 23, 2018 8:07 PM
  • I just looked and found that the laptop I reset last Friday and haven't re-installed SQS or VS on has now updated OneDrive.

    The workstation has not updated.  An old Acer with VS Express has not updated.   I have a clean HP tablet which has still not updated OneDrive but it has some odd HP hardware which may be slowing things down.  I am pretty sure some older hybrid SSD disks are still being vetted.  There are also issues with the Intel processor which is a tablet specific processor that has had some issues and may not have been tested yet. 

    Since the notebook updated I suspect that the tablet will in a week or so.


    \_(ツ)_/

    Tuesday, January 23, 2018 8:14 PM
  • Yes, the OneDrive client will auto-update, but not all machines that run 1709 will automatically get the latest version (I even saw a version on one of my systems that only about 5% of customers have seen, but that got pulled off, some of my
    contacts within Microsoft tell me).

    My main Acer laptop is running 17.3.7290.1212 (on RS3) and hasn't received the latest 17.3.7294.0108 yet.

    The OneDrive (universal) app on phones is serviced using the Store mechanism, the OneDrive sync client on PCs is serviced using a staged/throttled mechanism similar to Office 365's. These mechanisms are completely different.

    Tuesday, January 23, 2018 8:26 PM
  • Just checking: are all these machines using NTFS for the filesystem where the OneDrive folder resides?

    Tuesday, January 23, 2018 8:27 PM
  • Just checking: are all these machines using NTFS for the filesystem where the OneDrive folder resides?

    Absolutely.  Why would anyone try to move OD to a non-NTFS drive.  It won't work.

    The tablet was hosed trying to auto-update OneDrive. I have run a WU repair and found the January cumulative update was the cause. Fixing it now. Maybe OD will now update.


    \_(ツ)_/

    Tuesday, January 23, 2018 8:31 PM
  • Some people would like to use secondary storage such as (µ)SD, which is not formatted as NTFS by default.

    But of course, some of the filesystem mechanisms like sparse files the Files On Demand feature requires are available only on NTFS.

    That's why Microsoft has (somewhat silently, causing issues with people upgrading) changed the sync client so that it checks that NTFS is used as part of the implementation of the Files On Demand feature.

    Tuesday, January 23, 2018 8:37 PM
  • OneDrive has always refused install to non-NTFS.  If you force move the folder OneDrive will abort on startup.


    \_(ツ)_/

    Tuesday, January 23, 2018 8:46 PM
  • The update will have to come with an update to the net framework which is o  its way.

    The complaints listed above are mostly smoke and mirrors for many reasons. There are no dates associated. The issue doe not appear to me to be about OneDrive for business.

    USB and SDHC cards can be formatted for NTFS.  If the card is not formatted it will usually get formatted when initialize.  The first complaint sounds like the guys sister reformatted his card and left him with a FAT system  I doubt that she used his card or it would have worked.

    The message that the last link refers to was their the fist time I installed OD years ago.  Why it doesn't always show is a mystery.  MS has never said OD would work on any non-NTFS drive.

    Don't believe anything you read in the Internet and be suspicious of anything from the MS "answers" site.

    I started using OneDrive on company sites about  10 years ago when it was called "SkyDrive".

    The documentation for all Office products is always one or more years behind.  Some things never get documented and many things are documented incorrectly.  It is a big pain for developers as it takes hours to sort out the actual technical parameters.  Of course this has always been true of technical docs from any vendor I have worked with for over 30 years. Developers are always at the bleeding edge but pay a price for being there.


    \_(ツ)_/

    Tuesday, January 23, 2018 11:11 PM
  • Just curious: are you using the consumer version of OneDrive or OneDrive for Business or both? Until recently, the sync clients were distinct, so it could be possible that only one (probably the Business client) was explicitly disallowing non-NTFS filesystems, whereas the other wasn't...

    I might (or might not) confirm this via my contacts at Microsoft...

    Saturday, January 27, 2018 8:11 AM
  • I am using both.  On this machine they are  - or were - installed side-by-side.  I reset the PC and haven't re-installed the business version.

    Truthfully ...  I didn't test both recently and the older ones always listed only NTFS drives as targets.  All older versions from SkyDrive on were business versions.

    I think the two are identical now except for the branding and the ability to target Office 365 and SharePoint.


    \_(ツ)_/

    Saturday, January 27, 2018 8:15 AM
  • Yes.  They are both the same.  I am now connected to both business and personal through one instance.

    I think I will remove OneDrive Personal and install Business to see if there are any differences.


    \_(ツ)_/

    Saturday, January 27, 2018 8:19 AM