I tried your code, but I am still not getting any text file created??

SetOption("WrapAtEOL","ON")
$COMMAND = ' %COMSPEC% /C "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "test54.txt" '
? $COMMAND
SHELL $COMMAND