2

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
ZEE
  • 2,931
  • 5
  • 35
  • 47
  • 3
    I believe this isn't possible with an Alias but certainly is with a Function. Why do you explicitly not want a Function? – Mark Wragg Aug 07 '17 at 15:13
  • 3
    It's not, you _will_ have to define a function (or equivalent) for this – Mathias R. Jessen Aug 07 '17 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.... – ZEE Aug 07 '17 at 15:30
  • 1
    Take a look at some of the built-in wrapped functions like `mkdir`. `Get-Command mkdir | Select-Object -ExpandProperty Definition` – BenH Aug 07 '17 at 15:32
  • by the way... picking the replace string path I referred above... even dynamic parameters would be easy (and light) to implement in alias... this is a tipical Microsoft failure... – ZEE Aug 07 '17 at 15:37
  • thanks for the tip Ben... – ZEE Aug 07 '17 at 15:45
  • 1
    As [documented](https://learn.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/about_Aliases?view=powershell-3.0) 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. – Ansgar Wiechers Aug 07 '17 at 15:51

0 Answers0