- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use an alias() for the parameter in PowerShell?
PowerShell alias is a good way to use the shortcut name for the Parameter instead of writing the full name of the parameter. For example, you can refer to Server as ServerName, AppID as the ApplicationID.
So you don’t have to use the whole name of the parameter and it is easy to remember as well.
Example
function Aliastest{ param( [parameter(Mandatory=$true)] [Alias("Server")] [string]$ServerName ) Write-Output "Server name is $ServerName" }
Now we can use the Server instead of ServerName while passing the arguments.
PS C:\> Aliastest -server "Test1-Win2k16" Server name is Test1-Win2k16
- Related Articles
- How to use function Alias in PowerShell?
- How to use the ErrorAction parameter in PowerShell?
- How to use -For parameter in Restart-Computer cmdlet in PowerShell?
- How to use the -recursive parameter in Get-ChildItem using PowerShell?
- What is an alias in PowerShell?
- How to use an Alias in MySQL calculations?
- How to use –Wait parameter in Restart-Computer cmdlet in PowerShell?
- How to use –Timeout parameter in Restart-Computer cmdlet in PowerShell?
- How to create PowerShell alias permanently?
- How to create new alias with PowerShell?
- How to overwrite or remove PowerShell alias?
- How to get/resolve the command from the alias in PowerShell?
- What is the use of Passthru parameter in Stop-Process in PowerShell?
- What is the use of -Force parameter in Get-ChildItem in PowerShell?
- How to use PowerShell as a Calculator? Or How to use PowerShell for arithmetic operations?

Advertisements