none
How to set PowerShell default directory? RRS feed

  • Question

  • I would like to know on how to set PowerShell default directory to be H:\scripts, whenever I open powershell.

    Does anyone have any suggestions?
    Thanks in advance for any suggestions

    Thanks in advance for any suggestions


    Friday, January 19, 2018 2:57 PM

Answers

  • I receive following error message when I restart PowerShell.

    $home = 'h:\scripts'
    CateogoryInfo : WriteError: (Home:String) [], SessionStateUnauthorizedAccessException
    FullyQualifiedErrorId : VariableNotWritable

    Do you have any suggestions on how to fix it?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    cd d:\scripts
    Set-Variable -Name home -Value $pwd -Force


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, January 20, 2018 12:43 PM
    Saturday, January 20, 2018 9:42 AM

All replies

  • Just add it to your profile.

    $home = 'h:\scripts'


    \_(ツ)_/

    Friday, January 19, 2018 3:03 PM
  • Could you please tell on how to edit profile?

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Friday, January 19, 2018 7:03 PM
  • help about_profiles


    \_(ツ)_/

    Friday, January 19, 2018 7:48 PM
  • I receive following error message when I restart PowerShell.

    $home = 'h:\scripts'
    CateogoryInfo : WriteError: (Home:String) [], SessionStateUnauthorizedAccessException
    FullyQualifiedErrorId : VariableNotWritable

    Do you have any suggestions on how to fix it?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Saturday, January 20, 2018 5:44 AM
  • In your profile use the same command you would use in a PowerShell session the change the current directory.

    cd h:\Scripts

    This assumes that drive h: exists. See the help about_profiles, or check the automatic variable $profile for the location of your profile.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Saturday, January 20, 2018 8:53 AM
    Moderator
  • I receive following error message when I restart PowerShell.

    $home = 'h:\scripts'
    CateogoryInfo : WriteError: (Home:String) [], SessionStateUnauthorizedAccessException
    FullyQualifiedErrorId : VariableNotWritable

    Do you have any suggestions on how to fix it?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    cd d:\scripts
    Set-Variable -Name home -Value $pwd -Force


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, January 20, 2018 12:43 PM
    Saturday, January 20, 2018 9:42 AM
  • Thanks, to everyone very much for suggestions (^v^)

    Thanks in advance for any suggestions

    Saturday, January 20, 2018 12:43 PM