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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS