investigating_onedrive.ps1 1.0 KB

1234567891011121314151617181920212223242526272829
  1. # List some example files
  2. Get-ChildItem w* -File | Format-Table name,attributes
  3. Get-ChildItem -force | Where-Object {$_.attributes -match "Offline"}
  4. # Select two for analysis
  5. foreach ($file in ('.\WirelessCodes.txt', '.\urgTimes.xlsx')) {
  6. # Get the attributes of the file
  7. $attributes = (Get-ItemProperty $file).Attributes
  8. # Show the binary flags that were set
  9. "{0}: {1}" -f ($file, ([System.Convert]::ToString($attributes.value__,2))) | Write-Host
  10. # These are probably the attributes that govern the OneDrive settings
  11. foreach ($attrib in ('ReparsePoint', 'Offline', 'SparseFile')) {
  12. " {0}: {1} {2}" -f (
  13. $attrib,
  14. ($attributes -band [System.IO.FileAttributes]::$attrib),
  15. ($attributes.value__ -band [System.IO.FileAttributes]::$attrib.value__)
  16. ) | Write-Host
  17. }
  18. }
  19. $file = '.\WirelessCodes.txt'
  20. attrib.exe -p +u $file # Mark as online and remove the file
  21. attrib.exe -p -u $file # Mark as online, but keep the file
  22. attrib.exe +p +o $file # Mark as offline and download