Cmdlet, Alias, Function and Modules in Windows Powershell

Cmdlets in Windows Powershell

Cmdlets are a .NET classes. Each Cmdlet is in the form “verb-noun”. For example to get he list of processes, you can use “Get-Process” Cmdlet. Each Cmdlet has methods like BeginProcessing(), ProcessRecord() and EndProcessing(). Cmdlets get data from providers like file system, registry. Modules are used when you want to reuse the code.

You can get the members of object returned by specific Cmdlet using below syntax.

Get-Process | Get-Member

Alias in Windows Powershell

Alias is nothing but another name for the Cmdlet. For example – You must be familiar with “ls” command in Linux. This command displays the files and directories in current directory.

In Windows Powershell, we have “Get-ChildItem” Cmdlet to do the same thing. But cool thing is that in Powershell, we can use “ls” command without any problems. This is possible due to Alias.

To list down all alias in Powershell, you can use below command.

> Get-Alias



To create new Alias, you can use below command.

> Set-Alias -Name myls -Value get-childitem

To export an alias from current session to file, you can use below command.

> Export-Alias -Path “myalias.csv”

To import an alias from file, you can use below command. If any alias already exists, error will be thrown.

> Import-Alias myalias.csv

You can also find out main command running behind alias using below command.

Get-Alias –Name ls

Output of above command will be Get-ChildItem.

When you view help of any command, it shows the aliases for that command there.

Here is the list of some of the popular Linux aliases in Windows Powershell.

  1. ls – Get-ChildItem, gci, dir
  2. cat – Get-Content, gc, type
  3. man – Get-Help, help
  4. clear  – Clear-Host, cls
  5. cp – Copy-Item, cpi, copy
  6. mv – Move-Item, mi, move
  7. rm – Remove-Item, ri, del, erase, rmdir, rd
  8. mv  – Rename-Item, rni, ren
  9. pwd – Get-Location, gl, cd
  10. popd – Pop-Location
  11. pushd – Push-Location
  12. cd – Set-Location, sl, chdir
  13. echo – Write-Output, write
  14. ps  – Get-Process, gps
  15. kill – Stop-Process, spps
  16. curl – Invoke-WebRequest, iwr,  wget

You may also like...