Is there a way to assign an alias to the Remote-Item Cmdlet's -Force parameter?

0

I would like to use the Remove-Item in a similar manner to how it is used in Unix/Linux:

PS> rm -r -f <the_directory>

However, this syntax produces an error:

Remove-Item : Parameter cannot be processed because the parameter name 'f' is ambiguous. Possible matches include: -Filter -Force.

Is there a way to assign an alias to the Remote-Item Cmdlet's -Force parameter (in my profile)?

Craig

Posted 2015-10-22T13:58:39.160

Reputation: 785

First I would point out that all you need to do is add an o (-fo) to disambiguate it. Second I would say that aliasing a parameter would break autocomplete even if it were possible to alias a parameter. Third I would say that is typing that one letter is an onerous burden, I think the right solution would be to put a function in your profile that does rm using the full (or at least disambiguated) parameters then alias that as something like rmf. – EBGreen – 2015-10-22T14:08:11.693

@EBGreen, I wasn't aware of the disambiguation technique--that should suffice. – Craig – 2015-10-22T14:14:20.027

No answers