I think you want:
function Foo ( $a,$b) {
$a
$b
return "foo"
}
$x = "abc"
$y= 123
Invoke-Command -Credential $c -ComputerName $fqdn -ScriptBlock ${function:Foo} -ArgumentList $x,$y
More Related Contents:
- Redirecting standard input\output in Windows PowerShell
- How to perform keystroke inside powershell?
- Delete files older than 15 days using PowerShell
- How to get disk capacity and free space of remote computer
- Recursive file search using PowerShell
- Executing an EXE file using a PowerShell script
- Obtaining ExitCode using Start-Process and WaitForExit instead of -Wait
- How do I get only directories using Get-ChildItem?
- Web.Config transforms outside of Microsoft MSBuild?
- How to properly -filter multiple strings in a PowerShell copy script
- copy-item With Alternate Credentials
- PowerShell – Decode System.Security.SecureString to readable password
- How do I concatenate two text files in PowerShell?
- Extract the filename from a path
- How to export data to CSV in PowerShell?
- Methods to hex edit binary files via Powershell
- Comparing array variables in PowerShell
- Copy file remotely with PowerShell
- Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)
- PowerShell script to check the status of a URL
- Gracefully stopping in Powershell
- Powershell – Reboot and Continue Script
- Hashtables and key order
- Can’t install nuget package because of “Failed to initialize the PowerShell host”
- PowerShell The term is not recognized as cmdlet function script file or operable program
- PowerShell is missing the terminator: “
- Using PowerShell to remove lines from a text file if it contains a string
- What security setting is preventing Remote PowerShell 2.0 from accessing UNC paths
- List of all colors available for PowerShell?
- Prevent trailing newline in PowerShell Out-File command