I'm trying to run a PowerShell script to move files between folders on my NAS drive, but I'm running into issues. The script works fine for local directories on my desktop, but it fails to recognize files in the SMB mounted folder. I have confirmed I have both read and write access to the NAS. The specific line that doesn't seem to be executing properly is:
`$docFiles = Get-ChildItem -Path $folderPath -File | Where-Object { $fileExtensions -contains $_.Extension }`
The command lists the subfolders, but it doesn't find any files inside them. I also tried using the -Force flag with no success, and PowerShell doesn't show any errors. What could be going wrong?
5 Answers
First, check if `Get-ChildItem -Path $folderPath -File` is returning any results at all. If it's empty, you might want to simplify your command to see if it lists anything without the filter.
Make sure you can see the drive with `Get-PSDrive`. If you don't see it, try enabling `EnableLinkedConnections` in the registry and set it to `1`. You'll need to reboot afterward.
I tried `Get-PSDrive`, but it didn't list the NAS drive; only C and D drives were shown.
I added the registry key, but it still didn't help.
Have you tried accessing the files using a UNC path? It might help resolve the issue you're facing with the SMB connection.
I did try that. Using the name from Windows Explorer wasn't working, so I'm using the shared folder name instead.
Sometimes ISPs block SMB protocols which can lead to issues. However, since you mentioned both machines are on a LAN, that shouldn’t be your problem. Just double-check you have the right network permissions.
Yeah, both are connected to the same network.
I had a similar issue but found out that moving the folder up a level into the directory helped my script to recognize the files again. It might be related to folder path length limits in Windows.
Sounds like that might have been the key. Using -Recurse usually helps with deeper directory structures, but for simple cases, it can be tricky.
That’s interesting! I think the folder names were quite long, which could've caused the issue.

I ran it without the filter, but it still didn’t list any files, just folders.