Save output of a command


hi all,

i trying save output of command can read , decide weather completed or not.  i having trouble running command though. it's working switches aren't.

$servers = get-content servers.txt | sort-object  foreach ( $server in $servers ) {   	& psexec.exe \\$server 'c:\program files (x86)\progfolder\program.exe' option -t=$duration -e=$email -c=$comment -q=110  }

when ran complains not specifying options/switches. ideas?
thanks.

you don't need = options...try this.  $results collective output running command on each of servers.

$results = @() $servers = get-content servers.txt | sort-object foreach ( $server in $servers ) {  	$result = & psexec.exe \\$server 'c:\program files (x86)\progfolder\program.exe' option -t $duration -e $email -c $comment -q 110 $results += new-object psobject -property @{computer=$server;result=$result} }



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html