Posts

Showing posts with the label List

PowerShell Custom Object Formatting

On this article I'm going to touch a field of PowerShell development that most are not aware of. That is formatting. Every PowerShell user has used the "Format-Table" and "Format-List" cmdlets or even the "Format-Custom" to display data in a manner that suits them. What happens though when you have objects that you'll like to format a bit differently or set the default view for? Then its time to use formatting. To start off, we're going to create a custom module. Pick a name for the module - mine is going to be "TestModule" - and create a directory with that name. Then create the module manifest using the "New-ModuleManifest" cmdlet and a script file with the ".psm1" extension. You should end up with a structure like the following: PS C:\> New-Item -ItemType dir -Name TestModule     Directory: C:\Users\cpolydorou\Desktop Mode        LastWriteTime  Length Name ----        -------------  ------ ---- d--...