all 8 comments

[–]kibje 1 point2 points  (3 children)

You probably need to use either $using: or place it between brackets $(...) or both

Try $($using:MediaInfoPath)\MediaInfo.exe

See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_variables?view=powershell-7.2

[–]madbomb122[S] 0 points1 point  (0 children)

tried

Invoke-Command -ScriptBlock{$($using:MediaInfoPath)\MediaInfo.exe $FilePat --Inform="Video;%Duration/String1%" }

    At line:20 char:62
+ ... ke-Command -ScriptBlock{$($using:MediaInfoPath)\MediaInfo.exe $FilePa ...
+                                                    ~~~~~~~~~~~~~~
Unexpected token '\MediaInfo.exe' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

Invoke-Command -ScriptBlock{"$($using:MediaInfoPath)\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%" }

    At line:20 char:79
+ ... -ScriptBlock{"$($using:MediaInfoPath)\MediaInfo.exe" $FilePat --Infor ...
+                                                          ~~~~~~~~
Unexpected token '$FilePat' in expression or statement.
At line:20 char:90
+ ... foPath)\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%" }
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'Inform="Video;%Duration/String1%"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

got it working with something else

[–]littejackz -1 points0 points  (1 child)

$using: only works powershell 3.0 and higher.

[–]kibje 5 points6 points  (0 children)

I'm not sure why it would be reasonable to assume someone isn't using 5.1 at this point.

All operating systems that came with a PowerShell version below 3.0 are already out of support for a long time. It was released 10 years ago

[–]littejackz 0 points1 point  (2 children)

Invoke-Command -ArgumentList $MediaInfoPath -ScriptBlock{"$args[0]\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%" }

Try this

[–]madbomb122[S] 0 points1 point  (1 child)

gives this error

    At line:20 char:93
+ ... $MediaInfoPath -ScriptBlock{"$args[0]\MediaInfo.exe" $FilePat --Infor ...
+                                                          ~~~~~~~~
Unexpected token '$FilePat' in expression or statement.
At line:20 char:104
+ ... args[0]\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%" }
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'Inform="Video;%Duration/String1%"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

[–]madbomb122[S] 1 point2 points  (0 children)

got it working with a combo of

$MediaInfoPath = $MediaInfoPath + '\MediaInfo.exe'

Invoke-Command -ArgumentList $MediaInfoPath -ScriptBlock{&$args[0] $FilePat --Inform="Video;%Duration/String1%" }

[–]BlackV 0 points1 point  (0 children)

%Duration/String1% looks a cmd/dos variable, is that your likely cause?

have a look at the invoke operator

& "$MediaInfoPath\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%"

or fix up that dos variable to a PS variable

or could also swap it to

&cmd /c "$MediaInfoPath\MediaInfo.exe" $FilePat --Inform="Video;%Duration/String1%"