Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
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
2 Answers
- husoskiLv 71 year agoFavorite 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".)
- MarvinatorLv 71 year ago
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.