Skip to content

Instantly share code, notes, and snippets.

@IISResetMe IISResetMe/passfunc.ps1
Last active Aug 29, 2015

Embed
What would you like to do?
Pass function as argument in PowerShell
function Reverse-String {
param(
[string]$instr
)
$chars = $instr.ToCharArray()
[array]::Reverse($chars)
$chars -join ""
}
Invoke-Command {
param($string,$func)
[scriptblock]::Create($func).Invoke($string)
} -ArgumentList "abc",${function:Reverse-String}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.