Wednesday, April 02, 2014

Three Shortcuts of PowerShell Script

Recently I have been writing PS codes at work. PS is a really good and powerful script language in Windows environment. I have never learned it systematically or from basic concept to advanced level.  Based on my other programming skills, I just pick it and use it at work. In most cases, I just do the internet search for solutions if I don't have clue how to resolve my problems. Therefore, I have been on and off depending on my work requirements.

Still I don't know some very basic concepts. Here are three most commonalty used code cases:

%{....}
@{....}
?{....}


I just use them based on other people's codes. For these three shortcuts, I have trouble to google explanations. Finally, last week, I got an answer from SO.

%{...}: ForEach{}
@{...}: Constructor for hash table
?{...}: shortcut for Where {....}

References


  • SO comment discussion on Francis Padron's quetsion.

0 comments: