PowerShell/Scripts/list-cli-tools.ps1

279 lines
7.3 KiB
PowerShell
Raw Normal View History

2021-09-27 10:38:12 +02:00
<#
2021-07-22 10:49:42 +02:00
.SYNOPSIS
2022-09-05 19:45:54 +02:00
Lists installed CLI tools
2021-10-04 21:29:23 +02:00
.DESCRIPTION
2022-09-05 19:45:54 +02:00
This PowerShell script lists installed command-line interface (CLI) tools.
2021-07-22 10:49:42 +02:00
.EXAMPLE
2021-09-24 17:19:49 +02:00
PS> ./list-cli-tools
2021-09-29 21:50:10 +02:00
2022-09-27 14:02:28 +02:00
Name Version Path FileSize
---- ------- ---- --------
at 10.0.19041.1 C:\WINDOWS\system32\at.exe 31232
2021-09-29 21:50:10 +02:00
...
2021-07-22 10:49:42 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2022-01-29 12:47:46 +01:00
.NOTES
2022-03-29 07:37:01 +02:00
Author: Markus Fleschutz | License: CC0
2021-07-22 10:49:42 +02:00
#>
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
2022-09-27 14:02:28 +02:00
$Path = $Info.Source
2021-08-02 08:39:17 +02:00
if ("$($Info.Version)" -eq "0.0.0.0") {
if ("$VersionArg" -ne "") {
2022-09-27 14:02:28 +02:00
$Result = invoke-expression "$Path $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
}
2022-09-27 14:02:28 +02:00
if (Test-Path "$Path" -pathType leaf) {
$FileSize = (Get-Item "$Path").Length
2021-07-22 20:04:58 +02:00
} else {
$FileSize = "0"
}
2022-09-27 14:02:28 +02:00
New-Object PSObject -Property @{ Name=$Cmd; Version=$Version; Path=$Path; FileSize=$FileSize }
2021-07-22 20:04:58 +02:00
} catch {
return
}
2021-07-22 10:49:42 +02:00
}
function ListTools {
2021-08-24 21:20:33 +02:00
CheckFor 7z "-version"
CheckFor ant "-v"
CheckFor apt "--version"
2021-07-26 20:09:48 +02:00
CheckFor apt-get "--version"
2021-08-24 21:20:33 +02:00
CheckFor amixer "--version"
CheckFor aplay "--version"
CheckFor ar "--version"
2022-10-08 17:29:48 +02:00
CheckFor arch "--version"
2021-07-26 20:09:48 +02:00
CheckFor arecord "--version"
2021-08-24 21:20:33 +02:00
CheckFor at ""
CheckFor attrib ""
CheckFor awk "--version"
2022-10-08 17:29:48 +02:00
CheckFor b2sum "--version"
CheckFor base32 "--version"
CheckFor base64 "--version"
2021-07-26 20:09:48 +02:00
CheckFor basename "--version"
2022-10-08 17:29:48 +02:00
CheckFor basenc "--version"
2021-08-24 21:20:33 +02:00
CheckFor bash "--version"
2022-10-08 17:29:48 +02:00
CheckFor bc "--version"
CheckFor bunzip2 "--version"
CheckFor bzcat "--version"
CheckFor bzip2 "--version"
CheckFor bzip2recover "--version"
CheckFor captoinfo "--version"
CheckFor cat "-version"
CheckFor cc "--version"
CheckFor chattr "--version"
CheckFor chcon "--version"
2021-08-24 21:20:33 +02:00
CheckFor chdsk ""
2022-10-08 17:29:48 +02:00
CheckFor chgrp "--version"
CheckFor chmod "--version"
2021-08-02 15:51:01 +02:00
CheckFor chkntfs ""
2022-10-08 17:29:48 +02:00
CheckFor chown "--version"
CheckFor chroot "--version"
2022-08-29 09:14:19 +02:00
CheckFor choco "--version"
2021-08-02 15:51:01 +02:00
CheckFor cipher ""
2021-08-24 21:20:33 +02:00
CheckFor cksum "--version"
CheckFor clang "--version"
2022-10-08 17:29:48 +02:00
CheckFor clear "--version"
2021-08-24 21:20:33 +02:00
CheckFor cmake "--version"
CheckFor cmd ""
2022-10-08 17:29:48 +02:00
CheckFor cmp "--version"
CheckFor column "--version"
2021-08-24 21:20:33 +02:00
CheckFor comp ""
2021-08-02 15:51:01 +02:00
CheckFor compact ""
2022-10-08 17:29:48 +02:00
CheckFor cp "--version"
2021-08-24 21:20:33 +02:00
CheckFor cpack "--version"
2022-10-08 17:29:48 +02:00
CheckFor csplit "--version"
2021-08-24 21:20:33 +02:00
CheckFor ctest "--version"
CheckFor curl "--version"
CheckFor cut "--version"
2022-10-08 17:29:48 +02:00
CheckFor cygcheck "--version"
CheckFor cygpath "--version"
CheckFor d2u "--version"
CheckFor dash "--version"
2021-08-24 21:20:33 +02:00
CheckFor date ""
2022-10-08 17:29:48 +02:00
CheckFor dd "--version"
CheckFor df "--version"
2021-08-24 21:20:33 +02:00
CheckFor diff "--version"
2022-10-08 17:29:48 +02:00
CheckFor diff3 "--version"
CheckFor dir "--version"
CheckFor dircolors "--version"
CheckFor dirname "--version"
2021-08-24 21:20:33 +02:00
CheckFor dism ""
2022-10-08 17:29:48 +02:00
CheckFor dos2unix "--version"
2021-08-02 15:51:01 +02:00
CheckFor driverquery ""
2022-10-08 17:29:48 +02:00
CheckFor du "--version"
CheckFor echo "--version"
2022-09-05 19:45:54 +02:00
CheckFor egrep "--version"
2022-10-08 17:29:48 +02:00
CheckFor env "--version"
CheckFor ex "--version"
CheckFor expand "--version"
CheckFor expr "--version"
CheckFor factor "--version"
CheckFor false "--version"
CheckFor fido2-assert "--version"
CheckFor fido2-cred "--version"
CheckFor fido2-token "--version"
CheckFor file "--version"
2021-08-24 21:20:33 +02:00
CheckFor find "--version"
2022-09-05 19:45:54 +02:00
CheckFor fgrep "--version"
2022-10-08 17:29:48 +02:00
CheckFor fmt "--version"
CheckFor fold "--version"
2021-08-24 21:20:33 +02:00
CheckFor ftp "--version"
2022-10-08 17:29:48 +02:00
CheckFor funzip "--version"
CheckFor gawk "--version"
CheckFor gencat "--version"
CheckFor getconf "--version"
CheckFor getopt "--version"
CheckFor gettext "--version"
2021-08-24 21:20:33 +02:00
CheckFor gcc "--version"
CheckFor gdb "--version"
2022-10-08 17:29:48 +02:00
CheckFor gh "--version"
2021-08-24 21:20:33 +02:00
CheckFor git "--version"
2022-10-08 17:29:48 +02:00
CheckFor gkill "--version"
CheckFor gmondump "--version"
2021-08-24 21:20:33 +02:00
CheckFor gpg "--version"
2022-10-08 17:29:48 +02:00
CheckFor gpg-agent "--version"
CheckFor gpgconf "--version"
CheckFor gpg-error "--version"
CheckFor gpgsplit "--version"
CheckFor gpgtar "--version"
CheckFor grep "--version"
CheckFor groups "--version"
CheckFor gzip "--version"
CheckFor head "--version"
2021-10-20 10:19:57 +02:00
CheckFor hcsdiag ""
2021-08-24 21:20:33 +02:00
CheckFor help "--version"
2022-10-08 17:29:48 +02:00
CheckFor hmac256 "--version"
CheckFor hostid "--version"
2021-08-02 15:51:01 +02:00
CheckFor hostname ""
2021-08-24 21:20:33 +02:00
CheckFor htop "--version"
2022-10-08 17:29:48 +02:00
CheckFor iconv "--version"
CheckFor id "--version"
2021-08-24 21:20:33 +02:00
CheckFor ipfs "--version"
CheckFor java "--version"
2022-10-08 17:29:48 +02:00
CheckFor join "--version"
CheckFor kill "--version"
CheckFor ldd "--version"
CheckFor less "--version"
CheckFor link "--version"
CheckFor ln "--version"
CheckFor locale "--version"
CheckFor locate "--version"
CheckFor logname "--version"
CheckFor ls "--version"
CheckFor lsattr "--version"
2021-08-02 08:39:17 +02:00
CheckFor lsb_release ""
2021-08-24 21:20:33 +02:00
CheckFor lzma "--version"
2022-10-08 17:29:48 +02:00
CheckFor mac2unix "--version"
2021-08-24 21:20:33 +02:00
CheckFor make "--version"
2021-07-26 20:09:48 +02:00
CheckFor md5sum "--version"
2022-10-08 17:29:48 +02:00
CheckFor minidumper "--version"
CheckFor mkdir "--version"
2021-07-26 20:09:48 +02:00
CheckFor mkfifo "--version"
2022-10-08 17:29:48 +02:00
CheckFor mkgroup "--version"
CheckFor mknod "--version"
CheckFor mkpasswd "--version"
CheckFor mktemp "--version"
2021-09-13 14:48:25 +02:00
CheckFor mount "--version"
2022-02-15 08:01:45 +01:00
CheckFor MpCmdRun "-h"
2021-08-24 21:20:33 +02:00
CheckFor nice "--version"
2022-10-08 17:29:48 +02:00
CheckFor nohup "--version"
2021-08-24 21:20:33 +02:00
CheckFor nroff "--version"
2021-08-02 08:39:17 +02:00
CheckFor nslookup ""
CheckFor openssl ""
2022-10-08 17:29:48 +02:00
CheckFor passwd "--version"
CheckFor paste "--version"
2021-08-24 21:20:33 +02:00
CheckFor perl "--version"
CheckFor ping "-V"
CheckFor ping6 "-V"
2022-09-27 14:06:00 +02:00
CheckFor pip "--version"
CheckFor pip3 "--version"
CheckFor pip3.8 "--version"
2022-01-07 13:30:23 +01:00
CheckFor powercfg "/?"
CheckFor powershell "--version"
2021-08-24 21:20:33 +02:00
CheckFor print ""
2021-07-26 20:09:48 +02:00
CheckFor printf "--version"
2021-08-26 15:47:55 +02:00
CheckFor python "--version"
CheckFor python3 "--version"
2022-09-27 14:02:28 +02:00
CheckFor python3.8 "--version"
2021-12-07 11:27:25 +01:00
CheckFor rasdial "--version"
2021-07-26 20:09:48 +02:00
CheckFor regedit "--version"
CheckFor replace "--version"
CheckFor robocopy "--version"
2021-08-24 21:20:33 +02:00
CheckFor rsh ""
CheckFor rsync "--version"
2021-07-26 20:09:48 +02:00
CheckFor rundll32 "--version"
2021-08-24 21:20:33 +02:00
CheckFor scp ""
CheckFor sftp ""
2022-10-08 17:29:48 +02:00
CheckFor sh "--version"
2021-07-26 20:09:48 +02:00
CheckFor sha1sum "--version"
CheckFor sha256sum "--version"
CheckFor sha512sum "--version"
2021-08-24 21:20:33 +02:00
CheckFor ssh ""
2021-08-02 08:39:17 +02:00
CheckFor ssh-keygen ""
2021-08-24 21:20:33 +02:00
CheckFor sort "--version"
CheckFor split "--version"
CheckFor strace "--version"
2021-07-26 20:09:48 +02:00
CheckFor strings "--version"
2021-08-24 21:20:33 +02:00
CheckFor strip "--version"
CheckFor sudo "--version"
2021-08-02 15:51:01 +02:00
CheckFor systeminfo ""
2021-08-24 21:20:33 +02:00
CheckFor tail "--version"
CheckFor tar "--version"
2021-08-02 15:51:01 +02:00
CheckFor taskkill ""
CheckFor tasklist ""
2021-08-24 21:20:33 +02:00
CheckFor tee "--version"
CheckFor time ""
2021-08-02 15:51:01 +02:00
CheckFor timeout ""
2021-08-24 21:20:33 +02:00
CheckFor top "-v"
2021-08-02 15:51:01 +02:00
CheckFor tskill ""
2021-11-25 17:05:34 +01:00
CheckFor typeperf ""
2021-07-26 20:09:48 +02:00
CheckFor tzsync "--version"
2021-08-24 21:20:33 +02:00
CheckFor uniq "--version"
CheckFor vi "--version"
CheckFor vim "--version"
2021-07-26 20:09:48 +02:00
CheckFor vulkaninfo "--version"
CheckFor waitfor "--version"
2021-08-02 08:39:17 +02:00
CheckFor wakeonlan ""
2021-08-24 21:20:33 +02:00
CheckFor wget "--version"
CheckFor where "--version"
2021-07-26 20:09:48 +02:00
CheckFor whatis "--version"
2021-08-24 21:20:33 +02:00
CheckFor which ""
2021-12-01 08:13:00 +01:00
CheckFor winget "--version"
2022-03-29 07:37:01 +02:00
CheckFor winsat ""
2021-07-26 20:09:48 +02:00
CheckFor whoami "--version"
2021-08-24 21:20:33 +02:00
CheckFor wput "--version"
CheckFor write ""
2021-09-02 13:09:35 +02:00
CheckFor wsl "--version"
2021-08-24 21:20:33 +02:00
CheckFor xcopy "--version"
CheckFor yes "--version"
CheckFor zip "--version"
2021-07-26 20:09:48 +02:00
CheckFor zipcloak "--version"
2021-08-02 08:39:17 +02:00
CheckFor zipdetails ""
CheckFor zipgrep ""
CheckFor zipinfo ""
CheckFor zipnote ""
CheckFor zipsplit ""
2021-08-24 21:20:33 +02:00
CheckFor zsh "--version"
2021-07-22 10:49:42 +02:00
}
try {
2022-09-27 14:02:28 +02:00
ListTools | Format-Table -property @{e='Name';width=12},@{e='Version';width=15},@{e='Path';width=70},@{e='FileSize';width=10}
2021-09-27 10:09:45 +02:00
exit 0 # success
2021-07-22 10:49:42 +02:00
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-07-22 10:49:42 +02:00
exit 1
2022-09-27 14:02:28 +02:00
}