这是我想要在脚本块中工作的内容
$scriptblock={
for /f "tokens=14" %i in ('"ipconfig | findstr IPv4"') do set ip=%i
nslookup %ip%
}
每次虽然我得到
使用“1”参数调用“Create”的异常:“At line:4 char:4 + for /f "tokens=14" %i in ('"ipconfig | findstr IPv4"') do set ip=%i + ~ 在关键字 'for' 之后缺少开头的 '('。" 在 line:1 char:1 + $scriptblock=[scriptblock]::create($scriptblock) + ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ParseException
我尝试先将其设置为 here 字符串,然后使用[scriptblock]::create()
,但仍然得到相同的结果。
如何将其放入脚本块?