mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-27 18:33:19 +01:00
34 lines
922 B
PowerShell
Executable File
34 lines
922 B
PowerShell
Executable File
<#
|
|
.SYNTAX what-is.ps1 [<abbreviation>]
|
|
.DESCRIPTION prints a description of the given abbreviation
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
|
#>
|
|
|
|
param($Abbreviation = "")
|
|
if ($Abbreviation -eq "" ) { $Abbreviation = read-host "Enter the abbreviation" }
|
|
|
|
try {
|
|
write-progress "Searching ..."
|
|
|
|
$FoundOne = $false
|
|
$Files = (get-childItem "$PSScriptRoot/../Data/Abbr/*" -attributes !Directory)
|
|
|
|
foreach ($File in $Files) {
|
|
$Table = import-csv "$File"
|
|
foreach($Row in $Table) {
|
|
if ($Row.Abbr -eq $Abbreviation) {
|
|
$Filename = (get-item "$File").Name
|
|
" → $($Row.Abbr) = $($Row.Description) (in $Filename)"
|
|
$FoundOne = $true
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($FoundOne -eq $false) { "Sorry, no entry for $Abbreviation found" }
|
|
exit 0
|
|
} catch {
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|