【发布时间】:2013-01-19 12:38:51
【问题描述】:
我有一个 Powershell 脚本,用户将脚本作为参数传入其中。传入之后,我无法使用 $scriptvariable 调用脚本。当需要从变量调用一个脚本时,有什么方法可以从另一个 Powershell 脚本中调用一个 Powershell 脚本。
param(
[string]hostval,
[string]$scriptpath
)
Invoke-Command -Computer $hostval -Scriptblock { $scriptpath } -credential $cred
这不起作用,我不确定我想要的是否可能。是否有我可以使用的参数类型(例如:[script]$scriptpath)以便可以从 $scriptpath 调用脚本?
【问题讨论】:
标签: powershell parameters parameter-passing powershell-2.0