When working in PowerShell, and especially when scripting, you might want to give the user a choice of actions. For example, you might develop a configuration script that another admin or technician will run. Perhaps one of the steps is to configure networking depending on their location so you want to give the person running the script a menu of choices. Here’s one way you might accomplish this, without resorting to graphical tools or WinForms. Continue reading
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
I have to say I’m generally impressed with the quality of submissions to this year’s Scripting Games. But there is a recurring concept that some people are using and I think there’s a better way. Some contestants are defining function or script parameters as booleans. But I believe they really should be using the [switch] type. Let me show you why.