mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-03 13:23:56 +01:00
Improved list-scripts.ps1
This commit is contained in:
parent
e2f8513719
commit
80ca148f65
@ -12,10 +12,8 @@ function ListDirectory { param([string]$Path)
|
||||
$Items = get-childItem -path $Path
|
||||
foreach ($Item in $Items) {
|
||||
if ($Item.Mode -eq "d-----") {
|
||||
#write-output "$($Item.name)/"
|
||||
New-Object PSObject -Property @{ Filename = "$($Item.Name)/" }
|
||||
} else {
|
||||
#write-output "$($Item.name)"
|
||||
New-Object PSObject -Property @{ Filename = "$($Item.Name)" }
|
||||
}
|
||||
}
|
||||
|
@ -6,18 +6,22 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
$PathToRepo = "$PSScriptRoot/.."
|
||||
function ListScripts { param([string]$Path)
|
||||
write-progress "Reading $Path..."
|
||||
$Table = import-csv "$Path"
|
||||
foreach($Row in $Table) {
|
||||
New-Object PSObject -Property @{
|
||||
'Script' = "$($Row.Filename)"
|
||||
'Description' = "$($Row.Description)"
|
||||
}
|
||||
}
|
||||
write-output ""
|
||||
write-output "($($Table.Count) PowerShell scripts total)"
|
||||
}
|
||||
|
||||
try {
|
||||
write-progress "Reading Data/scripts.csv..."
|
||||
$Table = import-csv "$PathToRepo/Data/scripts.csv"
|
||||
|
||||
write-output ""
|
||||
write-output "Collection of $($Table.Count) PowerShell Scripts"
|
||||
write-output "==================================="
|
||||
foreach($Row in $Table) {
|
||||
write-output "* $($Row.Filename) - $($Row.Description)"
|
||||
}
|
||||
$PathToRepo = "$PSScriptRoot/.."
|
||||
ListScripts "$PathToRepo/Data/scripts.csv" | format-table -property Script, Description
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user