I have an issue with moving a file that contains spaces.
This is the example path: $transfer.FileName = D:\this\is\a\file with a lot of spaces.xml
$file = $transfer.FileName
Move-Item -path $file -Destination $archiveFolder
Error:
Move-Item : Illegal characters in path.
At line:1 char:17
+ Move-Item -path $file -Destination $archiveFolder
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (D:\this\i...ong 2022-08.xml:FileInfo) [Move-Item], ArgumentException
+ FullyQualifiedErrorId : MoveFileInfoItemArgumentError,Microsoft.PowerShell.Commands.MoveItemCommand
When i run test-path $file I receive $true. I have tried replacing the spaces with "` " but after that i got a new error saying that the path was not correct.
Does someone know how I can fix this?