PowerShell

PowerShell Techniques : Alias v/s Full Cmdlets usage.

Hi Everyone,

I hope you are enjoying your weekend.

This is my another post on Powershell techniques.

We all love Powershell alias’s they are good and they handy and saved lots of key strokes.  I use Powershell alias a lot. But i have seen few Powershell scripter and they do use Powershell alias in their scripts. 

In Console

1 (fig. 1)

2(fig. 2)

You can see when we use alias in Powershell Console, it use less space and less key strokes,

Good, we know Alias are good so?

In Powershell scripts i don’t prefer to user Powershell alias. Powershell scripts are used by other too , we share the script , so if someone want to change anything or append anything then it is bit difficult  and intercept the code.

So for easy reading, easy interception using full cmdlets are very useful to use in the scripts.

3

Note :- This is my personal opinion and view. 

 

That’s all for now.

Thanks

Aman Dhally

clip_image001 clip_image002 clip_image003 clip_image005clip_image007

2 thoughts on “PowerShell Techniques : Alias v/s Full Cmdlets usage.

  1. Hi Aman … for column VM which has a (M) in the end the -gt seems to be not working fine

    getting VM rows having value less then 200

    same command works fine with handles and id ..

    PS D:\POWERSHELL\Myscript> Get-Process | where-object {$_.handles -gt 200}

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
    ——- —— —– —– —– —— — ———–
    225 7 4132 1640 57 1.52 2616 AdobeARM
    266 37 4392 512 47 1.16 1048 ccApp
    567 13 10884 3244 84 219.59 1380 ccSvcHst
    235 13 134512 75756 254 1,001.58 720 chrome
    4263 54 232912 184800 486 3,247.45 4200 chrome
    861 35 176552 120384 707 7,439.38 4396 chrome

    1. Hi Gurpreet,

      Thanks!

      But if you read the post , it is not about “getting result by using Get-Process cmdlet”,but, this post is about, using PowerShell alias versus using full Cmdlets name is the script.

      Thanks
      Aman

Comments are closed.