Defining Alias Properties

by Aug 19, 2010

Your functions can have properties with built-in alias names. The user can then either use the descriptive "long" name or its short and convenient alias name:

function Get-BIOSInfo {
param(
[Alias("CN")]
$ComputerName = "."
)

Get-WmiObject Win32_BIOS -ComputerName $computername
}

You should either use -ComputerName or its alias -CN to retrieve BIOS information from a remote system..

Twitter This Tip! ReTweet this Tip!