...

Programming languages - Powershell

Back to Course

Lesson Description


Lession - #119 PowerShell-Alias


The PowerShell Alias supplier allows you to get, add, change, clear, and delete aliases in PowerShell.

A alias is a substitute name for a cmdlet, function, executable file, including scripts. PowerShell incorporates a bunch of built-in aliases. You can add your own aliases to the ongoing session and to your PowerShell profile.

The Alias drive is a level namespace that contains just the alias objects. The aliases have no child things.

The Alias supplier upholds the accompanying cmdlets, which are shrouded in this article.

  • Get-Location
  • Set-Location
  • Get-Item
  • New-Item
  • Remove-Item
  • Clear-Item

PowerShell incorporates a bunch of cmdlets that are intended to see and to change aliases. At the point when you use Alias cmdlets, you don't have to determine the Alias: drive in the name. This article doesn't cover working with Alias cmdlets.

  • Export-Alias
  • Get-Alias
  • Import-Alias
  • New-Alias
  • Set-Alias
Creating aliases
Create an alias from the Alias: drive
This command makes the serv alias for the Get-Service cmdlet. Since the ongoing area is in the Alias: drive, the - Path boundary isn't required.

This command likewise utilizes the - Options dynamic parameter to set the AllScope choice on the alias . The - Options parameter is accessible in the New-Item cmdlet just when you are in the Alias: drive. The dot (.>
shows the ongoing directory, which is the alias drive.

PS Alias:\> New-Item -Path . -Name serv -Value Get-Service -Options "AllScope"

Changing aliases

Set-Item -Path Alias:dir -Options "AllScope,ReadOnly"


Change an aliases referenced command
Set-Item -Path gp -Value Get-Process -Force

To view the effect of the change, type the following command:
Get-Item -Path gp | Format-List -Property *