A question about PowerShell's Alias function

Alpha90

New member
Local time
6:31 PM
Messages
49
I am trying to set up a powershell resource file and add a bunch of aliases to common unix programs and I am trying to find out if I can alias function flags some how as well.

For example the string regex function Select-String looks alot like grep in the *nix world and I know I can alias Select-String to grep if I wanted to. However the flags are completely different so I am wondering is their a way to alias flags as well. For example going back to Select-String, Select-String -NotMatch would be grep -v. So to boil down my question can I make an alias to the flags of an alias.
eg:
Select-String -Case-Sensitive -> grep
Select-String -> grep -i
Select-String -NotMatch -> grep -v
etc ...
 

My Computer My Computer

Computer Manufacturer/Model Number
Personally Built
OS
Windows 7 Professional x64
CPU
i7 2600k
Motherboard
P8z68-VLe Asus
Memory
4gb DDR3 x4 Dimms
Graphics Card(s)
MSI Radeon 6950
Sound Card
Asus Xonar DS
Monitor(s) Displays
Flatron D2342
Screen Resolution
1920 x 1080
Hard Drives
Hatachi 2TB Sata 3.0
PSU
Antec 1200 Gold
Case
NZXT Phantom
Cooling
Corsair H100 Cooling System
Keyboard
Logitech G11
Mouse
Logitech G5
Internet Speed
25MBPS to the router modem
Other Info
500W Logitech Speakers, Wacom Tablet, HP WebCam, KWorld PC150-U TV tuner, HP4050 Printer, Brothers MFC-415 All in one, Floppy Drive
Sorry, Alpha, not possible.

See here:
You can create an alias for a cmdlet, but you cannot create an alias for a command with parameters and values. For example, you can create an alias for Set-Location, but you cannot create an alias for "Set-Location C:\Windows\System32".

So to boil down my question can I make an alias to the flags of an alias.
You're going to have to create a wrapper function for that.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top