Defining Alias Properties

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!


Posted Aug 19 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.