PowerShell/Scripts/export-to-manuals.ps1

37 lines
1.0 KiB
PowerShell
Raw Normal View History

<#
.SYNOPSIS
Exports all scripts as manuals
.DESCRIPTION
This script exports the comment based help of all PowerShell scripts as manuals.
.EXAMPLE
PS> ./export-to-manuals.ps1
2021-10-23 11:06:03 +02:00
Found 264 scripts, exporting them to /home/markus/PowerShell/Docs...
2021-10-17 11:56:55 +02:00
exported 264 PowerShell scripts in 28 sec
.NOTES
2021-10-10 09:24:31 +02:00
Author: Markus Fleschutz · License: CC0
.LINK
2021-10-10 09:24:31 +02:00
https://github.com/fleschutz/PowerShell
#>
2021-10-10 09:24:31 +02:00
#requires -version 2
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetDir = "$PSScriptRoot/../Docs")
try {
2021-10-10 09:24:31 +02:00
$StopWatch = [system.diagnostics.stopwatch]::startNew()
$Scripts = Get-ChildItem "$FilePattern"
2021-10-23 11:06:03 +02:00
"⏳ Found $($Scripts.Count) scripts, exporting them to $TargetDir..."
2021-10-10 09:24:31 +02:00
foreach ($Script in $Scripts) {
2021-11-15 07:38:37 +01:00
& "$PSScriptRoot/convert-ps2md.ps1" "$Script" > "$TargetDir/$($Script.BaseName).md"
2021-10-10 09:24:31 +02:00
}
2021-10-10 09:24:31 +02:00
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
2021-10-17 11:56:55 +02:00
"✔️ exported $($Scripts.Count) PowerShell scripts in $Elapsed sec"
exit 0 # success
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}