February 2019
Intermediate to advanced
626 pages
15h 51m
English
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 that contains parameters for Get-Process. The local variable may contain any reasonable value:
$params = @{
Name = 'powershell'
IncludeUserName = $true
}
Invoke-Command -ComputerName PSTest -ScriptBlock {
$params = $using:params
Get-Process @params
}
The using scope is a handy alternative to the ArgumentList parameter.
Read now
Unlock full access