Yes, you can pipe within the shelled command to a file but you need to keep it all inside the quotes or better yet avoid vars in strings:

$ShellCMD = '%comspec% /c tsprof /q /domain:frost_bank '+$UserName+' >'+$file
Shell #ShellCMD
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.