In PowerShell, I type:

PS C:> sal cdp "cd 'C:\Users\ec\Documents\Visual Studio 2010\Projects'"

I get no error from this, and

PS C:> gal cdp

shows definition as: cd 'C:\Users\ec\Documents\Visual Studio 2010\Projects'

But, when I try to use cdp, I get this:

Cannot resolve alias 'cdp' because it refers to term 'cd 'C:\Users\ec\Documents\Visual Studio 2010\Projects'', which is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:4
+ cdp <<<<
 + CatergoryInfo   : ObjectNotFound (dsp:String) [], CommandNotFoundException
 + FullyQualifiedErrorId   : AliasNotResolvedException

I am guessing that this is trivially easy. So I apologize in advance if that is the case. I have googled and googled and have also read through Windows PowerShell Cookbook.

1 Answer 1


From my understanding, aliases in piowershell do not behave like they do in unix/linux type shells. An alias is merely a shorthand way of typing a much longer command. For the functionality that you are looking for, it may be easier to eaither define a function:

function cdp { Set-Location 'C:\Users\ec\Documents\Visual Studio 2010\Projects' }

Then you can execute cdp on the line to get to the desired location. Or you can create a variable for the location and then cd to that variable name:

$cdp = 'C:\Users\ec\Documents\Visual Studio 2010\Projects'
cd $cdp

Those are the two easiest solutions to what it appears you're trying to achieve.

  • Thanks. Yes, I am trying to replicate *nix shell scripting behavior. Both of your suggestions worked for me - so I will see if I can get them to persist in some easily re-useable form.
    – westsider
    Jun 29, 2011 at 0:04
  • 1
    Even though you haven't opened a question regarding the persistence issue, at the powershell prompt execute get-help about_profile that'll help you out with the persistence issue Jun 29, 2011 at 0:16
  • 1
    Thanks. At the risk of running amok of etiquette, I settled on using profile.ps1 in Documents/WindowsPowerShell/ as the easiest path. That works well for my immediate needs - much like .profile on other systems.
    – westsider
    Jun 29, 2011 at 0:45
  • Well then I am an amok runner as well. Pretty much all my shell customizations go into my AllUsersAllHosts profile as well.
    – EBGreen
    Jun 29, 2011 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.