When you write objects to the pipeline in Windows PowerShell, at the end of the pipeline PowerShell’s formatting system handles displaying the results to the console. It accomplishes this by using a set of rules stored in XML configuration files. This is why when you run Get-Process you get a table with a pre-defined set of properties. But sometimes there are alternate views defined. For example, for process objects there is a table view called Priority. Once you know the view name you can use it.
PS C:\> Get-Process | Format-Table -view Priority
The difficult part is finding what alternate views have been defined. For that, you can use my Get-View function. Continue reading
For last week’s Friday Fun, I posted a PowerShell script to create a traditional Bingo card. I hoped you would also learn a few PowerShell concepts along the way. This week I’ve taken this to the next level, and have a complete module that not only creates the card but also let’s you play the game. There’s a lot going on here with regular expressions, custom view PS1XML files, variable scope and more. Continue reading
Some of you know my relationship with the a command prompt goes back a long, long way. Naturally I became very adept at using the DIR command, fully taking advantage of its switches to tease out hidden information or to quickly get just the information I wanted. When PowerShell first came out, I made the transition to the DIR alias without too much difficulty. Although I still found myself wanting to run a command like DIR /ad (ie list only directories). Yes, you can achieve the same results with the PowerShell cmdlets, but that takes too much typing, especially for something I might want to use on a regular basis. I finally got around to writing a DIR function for PowerShell that better emulates my beloved DIR command from the CMD shell. Continue reading