For some unknown reason, the devs included "curl" as an alias for Invoke-WebRequest, even though it is not compatible with the proper implementation of curl, which means it gets in the way when I try to make a curl request. I can remove the alias using Remove-Item alias:curl, but next time I start Powershell, the alias has returned. Is there a way to remove it permanently without having to run a script every time I start?

up vote 20 down vote accepted

Skip this step if you already have a Powershell profile:

New-Item $profile -force -itemtype file

Then edit your profile:

notepad $profile

Add the following line to it:

remove-item alias:curl

Save, close notepad and reload the profile with the command below or close and open Powershell to apply the profile:

. $profile
  • 1
    Thanks. I must say it's annoying that the powershell developers didn't think this through, forcing us to now have to work around the issue in this way. – Nathan Ridley Mar 17 '15 at 2:12
  • I don't think it's meant to be a 1:1 replacement. Powershell focuses on an overarching use of a defined set of parameters and automatic parameter binding (which is really great once you get into it). Providing the curl alias is to show folks accustomed to *nix that there is a curl equivalent in Powershell. – megamorf Mar 17 '15 at 7:32
  • The first step can always be skipped. I just did, and got a pop-up asking if I wanted to create the file. – np8 Aug 23 '17 at 17:12
  • FYI: For some aliases, you will need to append "-Force" – Dan Friedman May 1 at 18:40

I'd stick with using curl.exe instead of just curl. This approach doesn't rely on PowerShell running with particular profile (and PowerShell could be run with no profile at all using -NoProfile switch).

add Remove-Item alias:cur to powershell autorun script

above XP,2003:

%ALLUSERSPROFILE%\Documents\Msh\profile.msh
%ALLUSERSPROFILE%\Documents\Msh\Microsoft.Management.Automation.msh_profile.msh

XP,2003:

%USERPROFILE%\My Documents\msh\profile.msh
%USERPROFILE%\My Documents\msh\Microsoft.Management.Automation.msh_profile.msh

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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