| Richard's profileRichard Siddaway's BlogPhotosBlogLists | Help |
|
November 19 Powershell and ObjectsPowerShell is .NET based. .NET is object orientated. Therefore PowerShell is object based. One of the first things we learn about PowerShell is that we are working with .NET objects. Just what does that mean? Look at the list of cmdlets specifically designed to work directly with objects: Compare-Object Commonly the aliases foreach, group, select, sort and where are used for their respective cmdlets. These are the ones that are used all of the time and everyone is happy with. What about the others? When was the last time you used Tee-Object? Tee-Object enables you to store output in a file or variable and display to the console (if tee-object terminates pipeline) or pass along the pipeline Consider Get-Process | Tee-Object -FilePath ptest.txt | Select name, handles Get-Content ptest.txt Will get the current processes, save the information in a file and then display the name and handles of the processes. We can then view the contents of the file. Even more useful is this Get-Process | Tee-Object -Variable procs | select name, handles This time we put the information into a variable. Note we don't use a $ on the variable name. We can then input $procs to the pipeline for further analysis. Any time you may need to dig further into some data think about using tee-object in your pipeline. Could save a bit of effort.
Technorati Tags: Powershell,Objects TrackbacksThe trackback URL for this entry is: http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1875.trak Weblogs that reference this entry
|
|
|