When working with Invoke-Command, PowerShell makes the using variable scope available.
The using variable scope allows access to variables created on a local machine within a script block used with Invoke-Command.
The following example shows the use of a variable containing parameters for Get-Process. The local variable may contain any reasonable value:
$params = @{ Name = 'powershell' IncludeUserName = $true } Invoke-Command { $params = $using:params Get-Process @params } -ComputerName PSTest
The using scope is a handy alternative to the ArgumentList parameter.