Forwarding Parameters

by Sep 16, 2011

To forward function parameters to a cmdlet, use $psboundparameters automatic variable and splatting. Here is a sample:

function Get-BIOS($ComputerName, $Credential) {
  Get-WmiObject Win32_BIOS @psboundparameters
}

Your function Get-BIOS works both locally and remotely. Only the parameters submitted by the user will actually be forwarded to Get-WmiObject.

Twitter This Tip!
ReTweet this Tip!