Reputation:
I am trying to append a suffix to a variable in order to create a path in Powershell. Let me clarify. My $workingDirectory variable contains the path C:\temp. However, I would like to use the New-Item command to create an item in that path. My item has to be called temp.csv. The full path would be C:\temp\temp.csv.
New-Item $workingDirectory\temp.csv -type file
would however not work. I am most likely overseeing some basic syntax rule?
Does anybody know how to fix my problem? Thanks in advance!
Upvotes: 0
Views: 1635
Reputation: 9854
You need to put your path in quotes for it to work.
New-Item "$workingDirectory\temp.csv" -type file
You can find out more about escaping characters by typing this command in the powershell console window
PS C:\> Help about_escaping_characters
Upvotes: 3