
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements