A good question came up in class today while we were studying PowerShell Format commands. We took a good look at how Format cmdlets consume the original object and make piping limited. One of the questions that came up was if it is possible to save the information to a file and still be able to use it in the pipeline? Fortunately for us, there is Tee-Object . We have a couple of ways that we can implement Tee-Object. Let’s look at it from a reusability perspective. Here is our starting code: Get-Process | Select-Object -first 3 -Property Name , VM , PM And here is the output: Name VM PM ---- -- -- AcroRd32 472272896 216985600 AcroRd32 132603904 10866688 ApMsgFwd 96550912 1626112 We will now add Tee-Object and send the data to another cmdlet. Get-Process | Select-Object -first 3 -Property Name , VM , PM | Tee-Object -FilePath C:\PS\Data1.txt | Sort-Object -Property VM T
Welcome to the blogsite of MCTExpert. I am a Microsoft Certified Trainer. Here you will find the real questions that are asked to me by my students.