I am trying to pass a local function to remote server with multiple arguments. I plan on running this for a number of servers, so the argument list will change for each server type. Here is a snippet of the function I am trying to call with the command I am using. The remote computer accepts the first argument, but never gets the second it seems.
Function Backup-Server{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]$BackupTarget,
[Parameter(Mandatory=$false)]
[switch]$BareMetal,
[Parameter(Mandatory=$false)]
[switch]$SystemState,
[Parameter(Mandatory=$false)]
[string[]]$Volume,
[Parameter(Mandatory=$false)]
[switch]$CriticalVolumes,
[Parameter(Mandatory=$false)]
[string[]]$File
)
Do stuff...
}
Invoke-Command -ComputerName dc-01.test.com -ScriptBlock ${Function:Backup-Server} -ArgumentList @("$BackupTarget","$SystemState") -AsJob
Any thoughts? I appreciate any help!