Powershell Command : Set-Alias

Set-Alias :

It was used for create or change the alias from one cmdlet to another.

Set-Alias Description :

The Set-Alias cmdlet is used for creating or changing an alias cmdlet, such as a function, a script, a file, or other executable. You need to add these changes or save these changes to the Windows Powershell profile, if not the changes will be lost of you close the current session.

Set-Alias Syntax :

Parameter Set: Default
Set-Alias [-Name] <String> [-Value] <String> [-Description <String> ] [-Force] [-Option <ScopedItemOptions> ] [-PassThru] [-Scope <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Set-Alias Parameters :

-PassThru

It was used to return the objects that represents the alias.

-Name<String>

Use to specify the new alias. Here you can use the alphanumeric characters.

-Force

Used to set the read-only alias.

-Description<String>

Used for specifying the description.

-Scope<String>

Used to get the aliases in specified scope. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope.

-Value<String>

Used to specify the name of the cmdlet.

-Option<ScopedItemOptions>

Sets the value of the Options property of the alias.

-Confirm

It will prompt you for a confirmation before running a cmdlet.

-WhatIf

It will show what happens when the cmdlet runs.

CommonParameters:

-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable.

Set-Alias Examples :

1) This command is used to create an alias called “list” for the Get-ChildItem cmdlet.

PS C:> set-alias -name list -value get-childitem

2) This command is used to set the alias for the notepad application.

PS C:> Set-Alias np c:windowsnotepad.exe

3) This command creates an alias named list for replacing the command get-childitem.

PS C:> new-alias list get-childitem

You may also like...

1 Response

  1. rhonda says:

    Thanks for the powershell tutorial script..thank you so much…

Leave a Reply

Your email address will not be published. Required fields are marked *