Trouble Accessing OneDrive Files with PowerShell

0
0
Asked By TechieDude42 On

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!

2 Answers

Answered By PowershellWiz72 On

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.

ExplorerFan88 -

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

Answered By CodeGuru99 On

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.

FileFinder7 -

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.