This is frustrating me so i am asking you guys for help..
i have a million(exaggerating a bit) folders to delete, I can go one by one and delete from Windows Explorer YAY... BUT I want to script it in Powershell (version 4)
using this code:
$Path = '\\verylonguncpath\plussomemore\'
Remove-Item -Path $Path -Recurse -Force -Confirm:$False
I get the error:
Remove-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248
characters.
At line:5 char:1
+ Remove-Item -Path $Path -Recurse -Force -Confirm:$False
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (\\verylongpath\plussomemore:String) [Remove-Item], PathTooLongException
+ FullyQualifiedErrorId : RemoveItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
It works if the $Path
isn't very long....
I even tried mapping to a letter then deleting content but i get the same problem?
Apparently its Microsoft or Powershell that is the problem from what i having been reading?
maybe its a user error :\
any advice would be great, i would really like to just use MS products but third party programs will be fine (to use within Powershell script)..
Thanks Pav.