Trouble Accessing OneDrive Files with PowerShell

April 18, 2026 2 answers
Asked by squall.line.watch
I'm trying to tidy up a OneDrive folder because a user has accidentally created a bunch of duplicate files. However, I'm facing a weird issue: when I try to get the filename of two files to compare and potentially remove them using commands like Get-Item, Get-FileHash, Copy-Item, and Remove-Item, it seems like the file paths I retrieve don't actually exist. This happens even though I got those paths from running "Get-ChildItem $SourceDir -File -Recurse". When I check the directory, I notice that the files are all listed as links (their mode is **-a---l**), which I think might be causing the problem. Although I've forced OneDrive to download the files, the issue persists. If anyone has advice or insights, I'd greatly appreciate it!

Answers

sweep_the_floor
Have you tried removing the files through Explorer? Also, can you manipulate them using PowerShell at all? It might be worth checking if there's a SharePoint issue, like if the files are checked in or something.

supper time: I can remove them fine in Explorer, but I don't think it's a checkout problem. Even basic commands like "get-item $File.FullName" fail, so I canโ€™t even verify if the file is really there.

Reply to this answer
+!rounding error
It sounds like the files might be sparse files from OneDrive. Have you tried setting them to always download? If they appear downloaded and still donโ€™t work, maybe try toggling them back to online only and then back to offline to refresh them.

+come on in: Yeah, all the files are in the same folder and I confirmed they're downloaded.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions