The using variable scope

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.219.166