Answered by:
PowerShell can not find a part of a path specified with Export-CSV command.

Question
-
Hi,
I have this code-line to export a file:
epcsv "c:\temp\My schedule Home/Work.csv" -NoT
But I get an error that PowerShell couldn't find a part of a path. Probably its de slash between "Home" and "Work causing the error. How can I solve ?
I have tried: ..."c:\temp\My schedule Home"+"/"+"Work.csv". But no luck
this.Greetings, P
Sunday, January 13, 2019 4:34 PM
Answers
-
See the following test:
PS D:\scripts> [io.path]::GetInvalidFileNameChars() -contains '/' True PS D:\scripts>
\_(ツ)_/
- Marked as answer by PeetK Sunday, January 13, 2019 5:32 PM
Sunday, January 13, 2019 5:02 PM
All replies
-
Is c:\temp and "c:\temp\My schedule Home" standard directories? This error usually means, that the path does not exist. Please try to run
mkdir "c:\temp\My schedule Home" -force
before running your command.M.
Sunday, January 13, 2019 4:46 PM -
The directory path must be valid before u export file. Export-CSV cant create directory for you.Sunday, January 13, 2019 4:48 PM
-
The "/" character is not legal in a file name.
\_(ツ)_/
Sunday, January 13, 2019 4:58 PM -
See the following test:
PS D:\scripts> [io.path]::GetInvalidFileNameChars() -contains '/' True PS D:\scripts>
\_(ツ)_/
- Marked as answer by PeetK Sunday, January 13, 2019 5:32 PM
Sunday, January 13, 2019 5:02 PM -
Hi,
Something happend to my commend before, it is deleted. As jrv posted you need to use backslash
epcsv "c:\temp\My schedule Home\Work.csv" -NoT
-----------------------------------------------------------------------------------------------------------
If you found this post helpful, please give it a "Helpful" vote.
Please remember to mark the replies as answers if they help.
Sunday, January 13, 2019 5:08 PM -
The chararacter / does not belong to a path, its a character I use in the name of the file.Sunday, January 13, 2019 5:30 PM
-
Oke I understand now. The / is not a valid character in a file name. Thank you for the information. Gr. PeterSunday, January 13, 2019 5:32 PM
-
Hi,
Something happend to my commend before, it is deleted. As jrv posted you need to use backslash
epcsv "c:\temp\My schedule Home\Work.csv" -NoT
-----------------------------------------------------------------------------------------------------------
If you found this post helpful, please give it a "Helpful" vote.
Please remember to mark the replies as answers if they help.
I repeat. You cannot use either / or \ in a file name.
\_(ツ)_/
Sunday, January 13, 2019 7:51 PM -
The chararacter / does not belong to a path, its a character I use in the name of the file.
It is not allowed in a file name. If you force it then the name will be inaccessible by most utilities. PS will not allow you to create a file with this name.
\_(ツ)_/
Sunday, January 13, 2019 7:52 PM -
Sunday, January 13, 2019 7:58 PM