# Remote Invoke-Command echo results

**URL:** <https://forums.powershell.org/t/remote-invoke-command-echo-results/113>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/remote-invoke-command-echo-results/113 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/remote-invoke-command-echo-results/113/1 "2011-12-31T18:30:00Z")

</div>

by bobsdesk at 2012-08-29 10:09:17

> I want to see the results of the commands from the remote computer that I issue using:  
> Invoke-Command -Session $Session -ScriptBlock {Remove-Item C:\SC\*.opn}, I get no results  
> Invoke-Command -Session $Session -ScriptBlock {Write-Output Remove-Item C:\SC\*.opn}, I see only the text of the command itself, not the result.  
>   
> If I create a .bat file on the remote computer that has the same command (in this case DEL c:\SC\*.opn)  
> Invoke-Command -Session $Session -ScriptBlock {C:\Batch.bat}, I get the command as well as the results (in this case No Files Found).  
>   
> How can I get the similar behavior without using a local batch file on the remote computer?

by RichardSiddaway at 2012-08-29 10:30:06

> Try using -verbose on your remove-item call  
>   
> By default remove-item won’t show any results for deleting the file  
>   
> Follow these steps to see what I mean  
>   
> PS\> $s = New-PSSession -ComputerName $env:COMPUTERNAME  
> PS\> Get-Process | out-file c:\temp\mytest.txt  
> PS\> Remove-Item c:\temp\mytest.txt  
> PS\> Get-Process | out-file c:\temp\mytest.txt  
> PS\> Invoke-Command -Session $s -ScriptBlock {Remove-Item c:\temp\mytest.txt}  
> PS\> Get-Process | out-file c:\temp\mytest.txt  
> PS\> Invoke-Command -Session $s -ScriptBlock {Remove-Item c:\temp\mytest.txt -Verbose}  
> VERBOSE: Performing operation "Remove file" on Target "C:\temp\mytest.txt".

by bobsdesk at 2012-08-30 09:46:21

> That seems to work fine for powershell commands but I have executable programs I’m running as well the display output to the remote console. But if I run a batch file that just calls that same executable I can see the the output from the remote console.

by poshoholic at 2012-08-30 11:13:42

> It would probably be worth it for you to read this article:  
> http://rkeithhill.wordpress.com/2007/09/16/effective-powershell-item-7-understanding-output/  
>   
> Output management gets better in PowerShell 3, but for PowerShell 2 and earlier there are some limitations.  
>   
> Also, when invoking executables, if you’re not getting the output you want, try using the 2&\>1 redirection operator to redirect stderr output to stdout. This may help with some programs you use.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:02pm UTC](https://forums.powershell.org/t/remote-invoke-command-echo-results/113/2 "2024-05-16T21:02:16Z")

</div>

Closed on May 16, 2024, 9:02pm UTC


