Author Posts

July 8, 2015 at 2:55 pm

I'm a new user and prefer not to use my Documents folder. Can I change the value of $pshome to an arbitrary folder on my computer?

July 8, 2015 at 2:58 pm

$pshome is the PowerShell installation folder. You can't change that, no.

July 8, 2015 at 3:30 pm

Aah, I see. So to use a different folder for data, I would have to set a new variable and use it explicitly to "cd" or "save to"?

July 8, 2015 at 3:44 pm

So... maybe I don't understand the situation.

PowerShell does not automatically save anything to $pshome. Most commands that save something, such as Out-File, simply default to the current directory, whatever that might be. You can always specify an alternate path, along with the filename, if you want something saved elsewhere.

I presume you're using the ISE, because you mentioned "save to." The ISE also defaults to saving to the current directory, whatever that is. It doesn't default to $pshome. Setting a variable doesn't change any of that behavior. If you want to save a script to C:\Script, just type "C:\Script\" before the filename. Same as anywhere else in Windows.

The ISE may default to your Documents folder – like most other apps do – but you can specify any other directory.

July 8, 2015 at 3:48 pm

Thanks again for your prompt and accurate reply. As I said, I am just learning PowerShell and must have misread something in Chapter 1. Yes your interpretation is correct and I get it now.