Here is what I am trying to get to work in a scriptblock
$scriptblock={
for /f "tokens=14" %i in ('"ipconfig | findstr IPv4"') do set ip=%i
nslookup %ip%
}
Everytime though I get
Exception calling "Create" with "1" argument(s): "At line:4 char:4 + for /f "tokens=14" %i in ('"ipconfig | findstr IPv4"') do set ip=%i + ~ Missing opening '(' after keyword 'for'. " At line:1 char:1 + $scriptblock=[scriptblock]::create($scriptblock) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ParseException
I have tried setting it to a here string first then using [scriptblock]::create()
, but still get the same thing.
How do I get this into the scriptblock?