forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-scripts.ps1
executable file
·40 lines (38 loc) · 1.01 KB
/
list-scripts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<#
.SYNOPSIS
Lists all PowerShell scripts
.DESCRIPTION
This PowerShell script lists all PowerShell scripts in the repository (sorted alphabetically).
.EXAMPLE
PS> ./list-scripts.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
function ListScripts { param([string]$FilePath)
Write-Progress "Reading $FilePath..."
$table = Import-CSV "$FilePath"
[int]$No = 1
foreach($row in $table) {
New-Object PSObject -Property @{
'No' = $No++
'Script' = $row.SCRIPT
'Description' = $row.DESCRIPTION
}
}
$global:NumScripts = $Table.Count
Write-Progress -completed "."
}
try {
# ListScripts "$PSScriptRoot/../Data/scripts.csv" | Format-Table -property No,Script,Description
$files = Get-ChildItem -path "./*.ps1" -attributes !Directory
foreach ($file in $files) {
$help = Get-Help $file -full
Write-Output "$($file.Name),$($help.Synopsis),"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}