Import-Alias in $profile

Welcome Forums General PowerShell Q&A Import-Alias in $profile

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

 
Participant
4 years, 8 months ago.

  • Author
    Posts
  • #15198

    Participant
    Points: 0
    Rank: Member

    Hi,
    I'm trying to load my aliases into a session by using the Import-Alias cmdlet using the command:

    Import-Alias .\Alias.txt

    which has the following alias:

    epp,"C:\Program Files\Just Great Software\EditPad Lite 7\EditPadLite7.exe","Launches Editpad Pro",None

    If I run Get-Alias -Name epp I get:

    CommandType Name ModuleName
    ———– —- ———-
    Alias epp -> C:\Program Files\Just Great Software\Edi...

    but if I run epp %profile I get:

    PS T:\Scripts> epp $profile
    epp : The term 'C:\Program Files\Just Great Software\EditPad Lite 7\EditPadLite7.exe' is not
    recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
    of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + epp $profile
    + ~~~
    + CategoryInfo : ObjectNotFound: (C:\Program File...ditPadLite7.exe:String) [], Comma
    ndNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    I think this is to do with my Alias.txt or my use of the Import-Alias cmdlet, but can't see where I'm going wrong.

    Thanks
    Tony

  • #15199

    Participant
    Points: 0
    Rank: Member

    First question – is the path to the file 'C:\Program Files\Just Great Software\EditPad Lite 7\EditPadLite7.exe' correct. Try running the file directly in PowerShell to test you have the correct path.

    Second question – are you opening your PowerShell session with credentials that allow you to access the file?

    Have you tried creating the alias using New-Alias rather than importing – to determine that your syntax is correct. If you can get the alias working that way then use Export-Alias to recreate your text file and try again.

  • #15200

    Participant
    Points: 0
    Rank: Member

    Feel so stupid. The path was to EditPad Lite (which I'd deleted as I'd upgraded and deleted) and I'm using EditPad Pro (different path). Stupid, stupid, stupid – spent 2 hours wondering why this didn't work.

    Thanks Richard

The topic ‘Import-Alias in $profile’ is closed to new replies.