Powershell pass variables to Invoke-Command
Last updated:
POWERSHELL
Refer to local variable with $using
Use the ‘$using:’ scope
$Using:variablename
references:
about Scopes - PowerShell | Microsoft Learn PowerShell: Passing variables to remote commands (powershellexplained.com)