Decided to add metainformaton to each PS file as a header comment. Needed to recusively add a template to PS files.

Prepending the template to all PS files in this directory and below

$prependFile = ""
$prepend = get-contents $prependFile
Get-ChildItem -Recurse -file   -Filter "*.ps1" | foreach {$prepend + (Get-Content $_.FullName -raw) | Out-File $_.FullName}

The script to prepend the template to each PS file recursively.

The template is in the file pointed to by $prependFile.

Note that you might want to back up the folder first as it overwrites the folder.

The PS File Template

Discussion Links

The suggested template:

<#
.SYNOPSIS A summary of how the script works and how to use it. 
.DESCRIPTION A long description of how the script works and how to use it. 
.NOTES Information about the environment, things to need to be consider and other information. 
.COMPONENT Information about PowerShell Modules to be required.
.LINK Useful Link to ressources or others. 
.Parameter ParameterName Description for a parameter in param definition section. One entry thus for each parmeter.
#>

Note that <# .. #> comments in PS scripts requires PS 3 or later.

Other info apart from the header

Ref: About Requires in MS Docs

These are placed as comments outside of the header. eg.

Requires -Version 5.0

This means the script requires version 5.0 of PS, or later.

You can add a number of other requirements. See the link above.

Would be nice to automatically extract the Parameter information from the file and add a .Parameter entry for each.


 TopicSubtopic
  Next: > Azure Sphere Projects
   
 This Category Links 
Category:Coding Index:Coding
  Next: > PowerShell
<  Prev:   PowerShell