PowerShell/Scripts/what-is.ps1

39 lines
958 B
PowerShell
Raw Normal View History

2021-05-19 07:51:30 +02:00
<#
2021-04-27 15:54:52 +02:00
.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 {
2021-04-29 20:19:07 +02:00
write-progress "Searching ..."
2021-04-27 15:54:52 +02:00
$FoundOne = 0
2021-04-29 20:19:07 +02:00
$Table = import-csv "$PSScriptRoot/../Data/Abbr/Aviation.csv"
foreach($Row in $Table) {
if ($Row.Abbr -eq $Abbreviation) {
2021-05-19 07:43:14 +02:00
"$($Row.Description) (in aviation)"
2021-04-29 20:19:07 +02:00
$FoundOne = 1
}
}
$Table = import-csv "$PSScriptRoot/../Data/Abbr/Misc.csv"
2021-04-27 15:54:52 +02:00
foreach($Row in $Table) {
if ($Row.Abbr -eq $Abbreviation) {
2021-05-19 07:43:14 +02:00
"$($Row.Description) (in misc)"
2021-04-27 15:54:52 +02:00
$FoundOne = 1
}
}
if ($FoundOne -eq 0) {
"Sorry, no entry for $Abbreviation found"
}
exit 0
} catch {
2021-05-02 21:30:48 +02:00
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-04-27 15:54:52 +02:00
exit 1
}