I have a script file Get-ProcesWithParam.ps1 as
param( $name ) function List-Process($name) { Write-Host "Process List" get-process -name $name
In another script, I get this file name as a string variable
$scriptFile = Get-ExecFile
The problem is that I need to execute this file (pass the argument to the file as well!)
I tried Invoke-Command
invoke-command -scriptblock { param($name) $scriptFile -name $name } -ArgumentList "chrome"
but it didn’t work, it just prints the file name, how can I execute the file that is in the string variable $ stringFile?
Jeez
source share