PowerShell/Scripts/list-cli-tools.ps1

151 lines
3.7 KiB
PowerShell
Raw Normal View History

2021-07-22 10:49:42 +02:00
<#
.SYNOPSIS
list-cli-tools.ps1
.DESCRIPTION
2021-07-22 20:09:17 +02:00
Lists available command-line interface (CLI) tools
2021-07-22 10:49:42 +02:00
.EXAMPLE
PS> .\list-cli-tools.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
2021-07-26 20:09:48 +02:00
function CheckFor { param([string]$Cmd, [string]$VersionArg)
2021-07-22 20:04:58 +02:00
try {
$Info = Get-Command $Cmd -ErrorAction Stop
$Location = $Info.Source
2021-08-02 08:39:17 +02:00
if ("$($Info.Version)" -eq "0.0.0.0") {
if ("$VersionArg" -ne "") {
$Result = invoke-expression "$Location $VersionArg"
2021-08-02 08:39:17 +02:00
if ("$Result" -match '\d+.\d+\.\d+') {
$Version = "$($Matches[0])"
} elseif ("$Result" -match '\d+\.\d+') {
$Version = "$($Matches[0])"
} else {
2021-08-02 08:39:17 +02:00
$Version = ""
}
} else {
$Version = ""
2021-07-26 20:09:48 +02:00
}
2021-08-02 08:39:17 +02:00
} else {
$Version = $Info.Version
2021-07-26 20:09:48 +02:00
}
2021-07-22 20:04:58 +02:00
if (test-path "$Location" -pathType leaf) {
$FileSize = (Get-Item "$Location").Length
} else {
$FileSize = "0"
}
2021-07-26 20:09:48 +02:00
new-object PSObject -Property @{ Name=$Cmd; Version=$Version; Location=$Location; FileSize=$FileSize }
2021-07-22 20:04:58 +02:00
} catch {
return
}
2021-07-22 10:49:42 +02:00
}
function ListTools {
2021-07-27 19:31:59 +02:00
CheckFor 7z "-version"
2021-08-02 08:39:17 +02:00
CheckFor ant "-v"
2021-07-26 20:09:48 +02:00
CheckFor apt "--version"
CheckFor apt-get "--version"
CheckFor amixer "--version"
CheckFor aplay "--version"
CheckFor ar "--version"
CheckFor arecord "--version"
2021-08-02 08:39:17 +02:00
CheckFor at ""
2021-07-26 20:09:48 +02:00
CheckFor awk "--version"
CheckFor basename "--version"
CheckFor bash "--version"
CheckFor bc "--version"
CheckFor cc "--version"
CheckFor cksum "--version"
CheckFor clang "--version"
2021-07-27 19:31:59 +02:00
CheckFor cmake "--version"
CheckFor cpack "--version"
CheckFor ctest "--version"
2021-07-26 20:09:48 +02:00
CheckFor curl "--version"
CheckFor cut "--version"
CheckFor diff "--version"
CheckFor find "--version"
CheckFor ftp "--version"
CheckFor gcc "--version"
CheckFor gdb "--version"
CheckFor git "--version"
CheckFor gpg "--version"
CheckFor help "--version"
CheckFor htop "--version"
CheckFor ipfs "--version"
CheckFor java "--version"
2021-08-02 08:39:17 +02:00
CheckFor lsb_release ""
2021-07-26 20:09:48 +02:00
CheckFor lzma "--version"
CheckFor make "--version"
CheckFor md5sum "--version"
CheckFor mkfifo "--version"
CheckFor nice "--version"
CheckFor nroff "--version"
2021-08-02 08:39:17 +02:00
CheckFor nslookup ""
CheckFor openssl ""
2021-07-26 20:09:48 +02:00
CheckFor perl "--version"
2021-07-27 19:31:59 +02:00
CheckFor ping "-V"
2021-08-02 08:39:17 +02:00
CheckFor ping6 "-V"
2021-07-26 20:09:48 +02:00
CheckFor printf "--version"
CheckFor python "--version"
CheckFor regedit "--version"
CheckFor replace "--version"
CheckFor robocopy "--version"
CheckFor rsh ""
2021-07-26 20:09:48 +02:00
CheckFor rsync "--version"
CheckFor rundll32 "--version"
2021-08-02 08:39:17 +02:00
CheckFor scp ""
CheckFor sftp ""
2021-07-26 20:09:48 +02:00
CheckFor sha1sum "--version"
CheckFor sha256sum "--version"
CheckFor sha512sum "--version"
2021-08-02 08:39:17 +02:00
CheckFor ssh ""
CheckFor ssh-keygen ""
2021-07-26 20:09:48 +02:00
CheckFor sort "--version"
CheckFor split "--version"
CheckFor strace "--version"
CheckFor strings "--version"
CheckFor strip "--version"
CheckFor sudo "--version"
CheckFor tail "--version"
CheckFor tar "--version"
CheckFor tasklist "--version"
CheckFor tee "--version"
2021-08-02 08:39:17 +02:00
CheckFor time ""
2021-08-01 12:02:41 +02:00
CheckFor top "-v"
2021-07-26 20:09:48 +02:00
CheckFor tskill "--version"
CheckFor tzsync "--version"
CheckFor uniq "--version"
CheckFor vi "--version"
CheckFor vim "--version"
CheckFor vulkaninfo "--version"
CheckFor waitfor "--version"
2021-08-02 08:39:17 +02:00
CheckFor wakeonlan ""
2021-07-26 20:09:48 +02:00
CheckFor wget "--version"
CheckFor where "--version"
CheckFor whatis "--version"
2021-08-02 08:39:17 +02:00
CheckFor which ""
2021-07-26 20:09:48 +02:00
CheckFor whoami "--version"
CheckFor wput "--version"
2021-08-02 08:39:17 +02:00
CheckFor write ""
2021-07-26 20:09:48 +02:00
CheckFor xcopy "--version"
CheckFor yes "--version"
CheckFor zip "--version"
CheckFor zipcloak "--version"
2021-08-02 08:39:17 +02:00
CheckFor zipdetails ""
CheckFor zipgrep ""
CheckFor zipinfo ""
CheckFor zipnote ""
CheckFor zipsplit ""
2021-07-26 20:09:48 +02:00
CheckFor zsh "--version"
2021-07-22 10:49:42 +02:00
}
try {
2021-08-02 09:28:33 +02:00
ListTools | format-table -property @{e='Name';width=12},@{e='Version';width=15},@{e='Location';width=45},@{e='FileSize';width=10}
2021-07-22 10:49:42 +02:00
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}