Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Computer Name in output from Invoke-Command

$
0
0

Is there a way to know to which computer an output text belongs when executing an Invoke-Command on a list of computers?

If I run something like this:

Invoke-Command -ComputerName Computer1,Computer2 -ScriptBlock { Remove-Item C:\Backup -Verbose }

I'll get output that looks something like this:

VERBOSE: Performing operation "Remove Directory" on Target "C:\Backup".
VERBOSE: Performing operation "Remove Directory" on Target "C:\Backup".

But I would like to get something like this:

Computer1: VERBOSE: Performing operation "Remove Directory" on Target "C:\Backup".
Computer2: VERBOSE: Performing operation "Remove Directory" on Target "C:\Backup".


Paulo Morgado



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>