3

I want to create an alias with fixed (static) parameters,
like the example below:

set-alias -name xxx -value Get-Process -ComputerName group1\xpto-pc

I don't want to changeable parameter values...
I want them to be fixed in the alias...

  • note: i do not want to create a function
7
  • 3
    I believe this isn't possible with an Alias but certainly is with a Function. Why do you explicitly not want a Function? Commented Aug 7, 2017 at 15:13
  • 3
    It's not, you will have to define a function (or equivalent) for this Commented Aug 7, 2017 at 15:15
  • 1
    I already have this working with functions... If it work with alias (since parameters are static) it would have a nice advantage to one of my projects of modeling/prototyping a language in powershell... by the way... I asked this question because I find so stupid that fixed parameters aren't accepted in an alias (basically a string to be replaced) that I thought I was making some moron mistake... it appears not.... Commented Aug 7, 2017 at 15:30
  • 1
    Take a look at some of the built-in wrapped functions like mkdir. Get-Command mkdir | Select-Object -ExpandProperty Definition Commented Aug 7, 2017 at 15:32
  • 1
    As documented aliases can be defined for "a cmdlet or for a command element, such as a function, script, file, or executable file". They cannot be defined for (partial) commandlines. Commented Aug 7, 2017 at 15:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.