Jams Client Illegal Characters in Path

I am getting an "illegal characters in path" error with the following code. Any thoughts?

$source = \\md\drive\MMM\<<DriveEnv>>\AA\Extracts\Active\filename.csv

$newfilename = \\md\drive\MMM\<<DriveEnv>>\AA\Extracts\Active\filename.csv.TEMP

Rename-Item $source -NewName $newfilename
0

1 Answer

Find the illegal characters and use Replace to strip them out in PowerShell. Below is an example how to replace < and > characters with NULL values which basically removes those characters.

It also appears that the << and >> are not be valid characters for a folder name in a UNC path. So you might replace those with the valid location or give an example to further test what that is actually set to in your example.

$source = "\\md\drive\MMM\<<DriveEnv>>\AA\Extracts\Active\filename.csv"

$source = $source.Replace("<","")
$source = $source.Replace(">","")

$newfilename = $source
$newfilename = $newfilename + ".TEMP"

Rename-Item $source -NewName $newfilename
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest