0

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!

4

1 に答える 1

3

パスを機能させるには、パスを引用符で囲む必要があります。

  New-Item "$workingDirectory\temp.csv" -type file

PowerShell コンソール ウィンドウで次のコマンドを入力すると、文字のエスケープの詳細を確認できます。

PS C:\> Help about_escaping_characters
于 2013-09-03T19:58:59.730 に答える