能否修改远程变量?我想要做类似以下的事情:
$var1 = ""
$var2 = ""
Invoke-Command -ComputerName Server1 -ScriptBlock{
$using:var1 = "Hello World"
$using:var2 = "Goodbye World"
}
当我尝试这样做时,会出现错误:
The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property.
显然,使用此方法无法实现目标,但是否有其他方法可行?我需要在远程和本地作用域中使用和修改这些变量。