One of my favorite features in PowerShell v2.0 is the ability to add help scripts and functions. The help system with cmdlets is terrific. Type help and the name of a cmdlet and you get syntax, parameters, a description and examples. In PowerShell v2 you can get this same functionality for your scripts and functions. The example I want to show you will work with PowerShell v2.0 that ships with WIndows 7 Release Candidate. There have been some changes since PowerShell CTP3 so if you want the absolute latest PowerShell bits you’ll need Windows 7. Here’s what you can look forward to.
Tag: Functions
Folder Usage Function
A few days ago I went over the PowerShell oneliner from SAPIEN’s March ’09 newsletter. I suggested using it in a scriptblock to save typing. Another possibility is to turn it into a function. Even better would be a function that accepts pipelined input. This would permit me to pipe in a list of folder names and get a usage object for each one. Here’s how it works.
Get-OtherDate
PowerShell’s [DATETIME] object has some handy methods for calculating a date such as AddDays(). Let me show you how as well as my own function for those situations where PowerShell’s methods just aren’t enough.