Forwarding Parameters

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

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!

Posted Sep 16 2011, 06:00 AM by ps1
Copyright 2012 All rights reserved.