none
Powershell: edit profile error "does not exist" RRS feed

  • Question

  • Hi,

    I'm trying to edit my powershell profile (started x86 since I need that one) but I get errors, pls advise.
    The path does not exist indeed but why does it show it then?

    J.

    PS K:\> $profile
    C:\Users\jhoedt\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

    PS K:\> cd $profile
    cd : Cannot find path 'C:\Users\jhoedt\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1' because it does not exist.
    At line:1 char:1
    + cd $profile
    + ~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\Users\jhoedt...ISE_profile.ps1:String) [Set-Location], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

     

    Jan Hoedt

    Wednesday, September 24, 2014 9:52 AM

Answers

  • You can only change directory (cd) to a folder, not to a file. $profile points to a file.
    • Marked as answer by janhoedt Wednesday, September 24, 2014 11:31 AM
    • Unmarked as answer by janhoedt Wednesday, September 24, 2014 11:33 AM
    • Proposed as answer by Mike Laughlin Wednesday, September 24, 2014 1:26 PM
    • Marked as answer by janhoedt Wednesday, September 24, 2014 3:17 PM
    Wednesday, September 24, 2014 10:56 AM
  • However, I could create the ps1 and that solved the problem. Still don't understand however, that the proflle path points to a non existing file.

    The $profile points to a file location, which if it exists, is loaded when the console/ISE is first started. If it doesn't exist, then it doesn't get loaded. I don't personally find that difficult to understand.

    If this was blank, then there would be no way to load a profile, as you would need to load the console/ISE first, before being able to point that variable to the relevant file.

    The way it is currently, you know exactly while file to edit or create if it doesn't exist.

    • Proposed as answer by Mike Laughlin Wednesday, September 24, 2014 1:26 PM
    • Marked as answer by janhoedt Wednesday, September 24, 2014 3:18 PM
    Wednesday, September 24, 2014 12:06 PM

All replies

  • You can only change directory (cd) to a folder, not to a file. $profile points to a file.
    • Marked as answer by janhoedt Wednesday, September 24, 2014 11:31 AM
    • Unmarked as answer by janhoedt Wednesday, September 24, 2014 11:33 AM
    • Proposed as answer by Mike Laughlin Wednesday, September 24, 2014 1:26 PM
    • Marked as answer by janhoedt Wednesday, September 24, 2014 3:17 PM
    Wednesday, September 24, 2014 10:56 AM
  • I was trying to open the profile in notepad, so notepad $profile and that didn't work.
    Then I tried the cd $profile, what wasn't a good idea :-)

    However, I could create the ps1 and that solved the problem. Still don't understand however, that the proflle path points to a non existing file.


    Jan Hoedt

    Wednesday, September 24, 2014 11:33 AM
  • However, I could create the ps1 and that solved the problem. Still don't understand however, that the proflle path points to a non existing file.

    The $profile points to a file location, which if it exists, is loaded when the console/ISE is first started. If it doesn't exist, then it doesn't get loaded. I don't personally find that difficult to understand.

    If this was blank, then there would be no way to load a profile, as you would need to load the console/ISE first, before being able to point that variable to the relevant file.

    The way it is currently, you know exactly while file to edit or create if it doesn't exist.

    • Proposed as answer by Mike Laughlin Wednesday, September 24, 2014 1:26 PM
    • Marked as answer by janhoedt Wednesday, September 24, 2014 3:18 PM
    Wednesday, September 24, 2014 12:06 PM
  • I was trying to open the profile in notepad, so notepad $profile and that didn't work.
    Then I tried the cd $profile, what wasn't a good idea :-)

    However, I could create the ps1 and that solved the problem. Still don't understand however, that the proflle path points to a non existing file.


    Jan Hoedt

    PowerShell does not have any profiles defind at start.  Profiles are fr customizing PowerShell.  IF they were defined they would have to initially be signed but the system has no signing certificate initially.  THis would nitially cause errors.

    Profiles are designed to be optionally chosen and configured by the user.

    It is highly recommended that, if you are a technician, you learn PowerShell by studying or training.  DO not attempt to guess your way through it. You will waste hundreds of hours of time learning basic things.


    ¯\_(ツ)_/¯

    • Proposed as answer by Mike Laughlin Wednesday, September 24, 2014 2:34 PM
    Wednesday, September 24, 2014 2:26 PM