Skip to content

Instantly share code, notes, and snippets.

@danielniccoli
Last active September 17, 2024 08:47
Show Gist options
  • Save danielniccoli/f221abdd7567b7cc01cc91e9ff926270 to your computer and use it in GitHub Desktop.
Save danielniccoli/f221abdd7567b7cc01cc91e9ff926270 to your computer and use it in GitHub Desktop.
Remove File Attributes that are not supported in PowerShell
# Removes all OneDrive attributes from files
Get-ChildItem * -Recurse -Depth 999 | % {
$flagsToRemove = 0x00040000 -bor 0x00080000 -bor 0x00100000 -bor 0x00040000 -bor 0x00400000
$flags = [System.IO.File]::GetAttributes($_.FullName)
$fixedFlags = $flags -band (-bnot $flagsToRemove)
[System.IO.File]::SetAttributes($_.FullName, $fixedFlags)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment