Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: A question about PowerShell's Alias function

25 Jun 2015   #1
Alpha90

Windows 7 Professional x64
 
 
A question about PowerShell's Alias function

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 System SpecsSystem Spec
.
26 Jun 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Sorry, Alpha, not possible.

See here:
Quote:
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".
Quote   Quote: Originally Posted by Alpha90 View Post
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 System SpecsSystem Spec
Reply

 A question about PowerShell's Alias function




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
eMachines E725-4520 - Function Key Driver Question
Hello, I'm 7ech7utorials and I'm new to the forums. I want to say hi, and was wondering if someone could help me with a driver I'm looking for. :D Also, sorry if this has been asked before, or if this a noob question. Before I tell you what driver I'm looking for, I have to tell you my system...
Drivers
How to create an email alias or expiring address?
Does anyone know a way to create an email alias? I sometimes need to email data to people without enabling them to contact me (they're supposed to go through a help desk). I've looked at services like 10minute mail, but they don't enable you to create and send mail, only receive it. Any ideas?
Browsers & Mail
Anti-Alias in the new paint
Why is it everywhere i look on the internet, everyone loves the new anti aliasing feature which in all honestly gets on my <<proverbial expletive>>. Please oh please MS, at least give us the option to disable it! i can't do pixel like this!:(
Software
How to Rename the alias My Documents
Hi guys I have a brief question...In vista the personal folders didn't have my as prefix to Pictures, Documents Movies etc.... I would like to get rid of the MY..How to? I allready tried to rename but it renames the actual folder and not the alias:confused:
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 12:02.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App