Powershell beginner command question?

I am doing my first ps script. I am trying to make a text file but the command requires that i put a path for the destination. What do i put so that the text file goes to the current directory for anyone who runs the script. Thank you

husoski2019-11-16T06:39:34Z

Favorite Answer

The shorthand for the current directory is ".", so a file named "info.txt" in the current directory could be referred to as "./info.txt" or ".\info.txt".  Most of Windows allows you to use Unix-style / characters as separators instead of the \ separator inherited from MS-DOS.

The parent of the current directory is named "..", so that allows you to make current-directory-relative references to that directory.  (The parent of the parent directory is not "..." though.  It's "../..", meaning "the parent directory of the parent directory".)

Marvinator2019-11-16T03:52:19Z

It's dangerous to use a 'common' or unknown directory destination.  the average person won't know where to go to find the text file.  If nothing else, have your script create a folder in the c:\ root directory and place any files created into that folder.  

Sorry, forgot to include the command. Here you go.  
New-Item -Path . -Name "testfile1.txt" -ItemType "file" -Value "This is a text string."

The dot ('.') in the value of the Path parameter indicates the current directory.