How do I write the following cmd script inside a powershell function:
@echo off
C:\bin\command.exe %*
Powershell Script:
function f{
[CmdletBinding()] Param()
# .. Code? ...
}
If you want to define a param block and still capture all arguments you can define a parameter that uses the ValueFromRemainingArguments argument on the Parameter attribute.
function Test-Function {
[CmdletBinding()]
param(
[string] $FirstParameter,
[Parameter(ValueFromRemainingArguments=$true)]
[object[]] $RemainingArguments
)
end {
$PSBoundParameters
}
}
Test-Function first and then the rest go to remaining
# Key Value
# --- -----
# FirstParameter first
# RemainingArguments {and, then, the, rest...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With