How do I change $pshome?

Welcome Forums General PowerShell Q&A How do I change $pshome?

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
3 years, 5 months ago.

  • Author
    Posts
  • #27320

    Participant
    Points: 0
    Rank: Member

    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?

  • #27321

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

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

  • #27322

    Participant
    Points: 0
    Rank: Member

    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"?

  • #27324

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    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.

  • #27325

    Participant
    Points: 0
    Rank: Member

    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.

    Cheers
    David

The topic ‘How do I change $pshome?’ is closed to new replies.