I wrote a PS1 script that will count how many processes (in this case MS Project) are running on a Citrix farm.
The code it's:
$variable=(query farm /process | where { $_.Contains("WINPROJ") } | measure ).count
echo $variable
If I execute the PS1 from powershell, it works flawlessly but If I invoke it from cmd (for schedule it) using powershell.exe -file "C:\foo\countProcessProject.ps1" or powershell.exe -c "C:\foo\countProcessProject.ps1" the script will stop until I press a button multiple times, outputting the variable.
I've compared environment variables on CMD and PS execution and are almost the same.
Greets,