Get-NumberedContent v2

I wasn’t completely satisfied with the updated version of my Get-NumberedContent function. You should still refer to the earlier post for details on how to use the function. But I had some issues with the previous version and realized there were a few bugs. I’ve since updated the Get-NumberedContent function.

Many of my PowerShell v2.0 scripts use comment blocks like this:

As written, my function couldn’t detect this as a comment. So I updated Get-NumberedContent to check PowerShell scripts for a <# and if found flip a flag that basically says, I’m in comment mode.

The function will treat every line as a comment until a #> is found, at which point the comment flag is turned off.

I also fixed a few bugs and tweaked some things. For example, now the full filename will be displayed as line 00. The function now writes a blank line after each file. This is helpful when running through a collection of files. Finally, I added an online link to the help section to link to this page. When creating links, the online link needs to be separate from any other links you want to display.

If you have any bugs or suggestions, I hope you’ll share them with me.

Download the latest version of Get-NumberedContent

3 thoughts on “Get-NumberedContent v2”

  1. Nice Jeff! I’m also a Linux guy, so this is the equivalent of cat -n, where it numbers the lines.

    One little typo in the description I came across:

    For script files, or any file for that matter, you can specify a character ad the comment character.

    Think you meant as the comment character. Either way it’s loaded into my PS Profile now for future use!

  2. Even Microsoft documentation has typos, if you can believe it! I’ll fix it and replace the file on the server.

Comments are closed.