Formatting the verbose output of a Remove-Item command

Question:

I have the following command:

to clear some files from the build folder of a VS solution. I use the Verbose switch so that I can see which files are being deleted. It works fine but the output is too verbose:

I just need to see something like that:

I know i can do this with a foreach statement and a Write-Host command, but I believe it can be done with some pipelining or something. Any ideas?

Answer:

Using ForEach-Object is pretty straightforward:


As @user978511 pointed out, using the verbose output is more complicated:

Source:

Formatting the verbose output of a Remove-Item command by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply