PowerShell/scripts/list-cli-tools.ps1

335 lines
8.8 KiB
PowerShell
Raw Normal View History

2023-10-31 12:33:36 +01:00
<#
2021-07-22 10:49:42 +02:00
.SYNOPSIS
2023-05-17 07:56:18 +02:00
Lists command-line tools
2021-10-04 21:29:23 +02:00
.DESCRIPTION
2023-05-17 07:56:18 +02:00
This PowerShell script lists installed command-line interface (CLI) tools (sorted alphabetically by name).
2021-07-22 10:49:42 +02:00
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./list-cli-tools.ps1
2021-09-29 21:50:10 +02:00
2023-10-10 15:17:37 +02:00
CLI-Tool Version Location
-------- ------- --------
at 10.0.19041.1 C:\WINDOWS\system32\at.exe (31K)
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
#>
2023-10-10 15:17:37 +02:00
function Bytes2String([int64]$bytes) {
if ($bytes -lt 1000) { return "$bytes bytes" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)K" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)MB" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)GB" }
$bytes /= 1000
return "$($Bytes)TB"
}
function ListTool([string]$Name, [string]$VersionArg) {
2021-07-22 20:04:58 +02:00
try {
2023-06-02 13:46:16 +02:00
$Info = Get-Command $Name -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-11-21 21:42:41 +01: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) {
2023-06-02 13:46:16 +02:00
$Size = (Get-Item "$Path").Length
2021-07-22 20:04:58 +02:00
} else {
2023-06-02 13:46:16 +02:00
$Size = 0
2021-07-22 20:04:58 +02:00
}
2023-10-10 15:17:37 +02:00
New-Object PSObject -Property @{ 'CLI-Tool'=$Name; Version=$Version; Location="$Path ($(Bytes2String $Size))" }
2021-07-22 20:04:58 +02:00
} catch {
return
}
2021-07-22 10:49:42 +02:00
}
2023-05-17 07:56:18 +02:00
function ListTools {
ListTool 7z "-version"
ListTool ant "-v"
ListTool apt "--version"
ListTool apt-get "--version"
ListTool amixer "--version"
ListTool aplay "--version"
ListTool apropos "--version"
ListTool ar "--version"
ListTool arch "--version"
ListTool arecord "--version"
ListTool arp ""
ListTool at ""
ListTool attrib ""
2023-09-26 16:46:33 +02:00
ListTool auditpol ""
2023-05-17 07:56:18 +02:00
ListTool awk "--version"
ListTool b2sum "--version"
ListTool base32 "--version"
ListTool base64 "--version"
ListTool basename "--version"
ListTool basenc "--version"
ListTool bash "--version"
ListTool bc "--version"
2023-09-26 16:46:33 +02:00
ListTool bcdboot ""
2023-05-17 07:56:18 +02:00
ListTool bcdedit ""
2023-09-26 16:46:33 +02:00
ListTool bitsadmin ""
2023-05-17 07:56:18 +02:00
ListTool bunzip2 "--version"
ListTool bzcat "--version"
ListTool bzip2 "--version"
ListTool bzip2recover "--version"
ListTool captoinfo "-V"
ListTool cat "-version"
ListTool cc "--version"
ListTool chattr "--version"
ListTool chcon "--version"
ListTool chcpu "--version"
ListTool chdsk ""
2023-09-26 16:46:33 +02:00
ListTool chglogon ""
ListTool chgport ""
ListTool chgusr ""
2023-05-17 07:56:18 +02:00
ListTool chgrp "--version"
ListTool chmod "--version"
ListTool chkntfs ""
ListTool chmem "--version"
2023-09-26 16:46:33 +02:00
ListTool choice "/?"
2023-05-17 07:56:18 +02:00
ListTool chown "--version"
ListTool chpasswd "--version"
ListTool chroot "--version"
ListTool choco "--version"
ListTool cipher ""
ListTool cksum "--version"
ListTool clang "--version"
ListTool clear "-V"
ListTool cmake "--version"
ListTool cmd ""
2023-09-26 16:46:33 +02:00
ListTool cmdkey "/list"
2023-05-17 07:56:18 +02:00
ListTool cmp "--version"
ListTool column "--version"
ListTool comp ""
ListTool compact ""
ListTool cp "--version"
ListTool cpack "--version"
2023-09-26 16:46:33 +02:00
ListTool cscript ""
2023-05-17 07:56:18 +02:00
ListTool csplit "--version"
ListTool ctest "--version"
ListTool curl "--version"
2023-10-06 12:51:34 +02:00
ListTool curl.exe "--version"
2023-05-17 07:56:18 +02:00
ListTool cut "--version"
ListTool cygcheck "--version"
ListTool cygpath "--version"
ListTool d2u "--version"
ListTool dash "--version"
ListTool date ""
ListTool dd "--version"
ListTool delgroup "--version"
ListTool deluser "--version"
ListTool df "--version"
ListTool diff "--version"
ListTool diff3 "--version"
ListTool dir "--version"
ListTool dircolors "--version"
ListTool dirname "--version"
ListTool dism ""
ListTool dmidecode "--version"
ListTool dos2unix "--version"
2023-09-26 16:46:33 +02:00
ListTool doskey "/?"
2023-05-31 09:26:09 +02:00
ListTool dotnet "--info"
2023-05-17 07:56:18 +02:00
ListTool driverquery ""
ListTool du "--version"
ListTool echo "--version"
ListTool egrep "--version"
ListTool emacs "--version"
ListTool env "--version"
2023-09-26 16:46:33 +02:00
ListTool eventcreate "/?"
2023-05-17 07:56:18 +02:00
ListTool ex "--version"
ListTool expand "--version"
ListTool expr "--version"
ListTool factor "--version"
ListTool false "--version"
ListTool fido2-assert "--version"
ListTool fido2-cred "--version"
ListTool fido2-token "--version"
ListTool file "--version"
ListTool find "--version"
ListTool fish "--version"
ListTool fgrep "--version"
ListTool fmt "--version"
ListTool fold "--version"
ListTool ftp "-?"
ListTool funzip "--version"
ListTool gawk "--version"
ListTool gencat "--version"
ListTool getconf "--version"
ListTool getopt "--version"
ListTool gettext "--version"
ListTool gcc "--version"
ListTool gdb "--version"
ListTool gh "--version"
ListTool git "--version"
ListTool gkill "--version"
ListTool gmondump "--version"
ListTool gpg "--version"
ListTool gpg-agent "--version"
ListTool gpgconf "--version"
ListTool gpg-error "--version"
ListTool gpgsplit "--version"
ListTool gpgtar "--version"
2023-06-15 10:15:08 +02:00
ListTool gradle "--version"
2023-05-17 07:56:18 +02:00
ListTool grep "--version"
ListTool groups "--version"
ListTool gzip "--version"
ListTool head "--version"
ListTool hcsdiag ""
ListTool help "--version"
ListTool hmac256 "--version"
ListTool hostid "--version"
ListTool hostname ""
ListTool htop "--version"
ListTool icacls "--version"
ListTool iconv "--version"
ListTool id "--version"
ListTool ipfs "--version"
ListTool java "--version"
2023-05-20 09:25:06 +02:00
ListTool jcli "version"
2023-05-24 16:07:03 +02:00
ListTool join "--version"
ListTool jhead "-V"
2023-05-17 07:56:18 +02:00
ListTool kill "--version"
ListTool ldd "--version"
ListTool less "--version"
ListTool link "--version"
ListTool ln "--version"
ListTool locale "--version"
ListTool locate "--version"
ListTool logname "--version"
ListTool ls "--version"
ListTool lsattr "-V"
ListTool lsb_release ""
ListTool lzma "--version"
ListTool mac2unix "--version"
ListTool make "--version"
ListTool mbr2gpt ""
ListTool md5sum "--version"
ListTool minidumper "--version"
ListTool mkdir "--version"
ListTool mkfifo "--version"
ListTool mkgroup "--version"
ListTool mknod "--version"
ListTool mkpasswd "--version"
ListTool mktemp "--version"
ListTool mount "--version"
ListTool MpCmdRun "-h"
ListTool nano "--version"
ListTool netsh ""
ListTool netstat ""
ListTool nice "--version"
ListTool nohup "--version"
ListTool nroff "--version"
ListTool nslookup ""
ListTool openssl ""
ListTool pandoc "--version"
ListTool passwd "--status"
ListTool paste "--version"
ListTool perl "--version"
ListTool ping "-V"
ListTool ping6 "-V"
ListTool pip "--version"
ListTool pip3 "--version"
ListTool pip3.8 "--version"
2024-01-16 07:13:08 +01:00
ListTool pnputil "/?"
2023-05-17 07:56:18 +02:00
ListTool powercfg "/?"
ListTool powershell "--version"
ListTool print ""
ListTool printf "--version"
ListTool pro "--version"
ListTool python "--version"
ListTool python3 "--version"
ListTool python3.8 "--version"
ListTool rasdial "--version"
ListTool regedit "--version"
ListTool replace "--version"
ListTool robocopy "--version"
ListTool route ""
2023-09-26 16:46:33 +02:00
ListTool rpcping ""
2023-05-17 07:56:18 +02:00
ListTool rsh ""
ListTool rsync "--version"
ListTool rundll32 "--version"
ListTool scp ""
2023-09-26 16:46:33 +02:00
ListTool setx ""
2023-05-17 07:56:18 +02:00
ListTool sftp ""
ListTool sh "--version"
ListTool sha1sum "--version"
ListTool sha256sum "--version"
ListTool sha512sum "--version"
ListTool ssh "-V"
ListTool ssh-keygen ""
ListTool smartctl "--version"
ListTool sort "--version"
ListTool split "--version"
ListTool strace "--version"
ListTool strings "--version"
ListTool strip "--version"
ListTool sudo "--version"
ListTool systeminfo ""
ListTool tail "--version"
ListTool tar "--version"
ListTool taskkill ""
ListTool tasklist ""
ListTool tcpdump "--version"
ListTool tee "--version"
2023-07-30 20:53:54 +02:00
ListTool terraform "--version"
2023-05-17 07:56:18 +02:00
ListTool time ""
ListTool timeout ""
2023-06-02 13:36:50 +02:00
ListTool top "--version"
2023-05-17 07:56:18 +02:00
ListTool tskill ""
ListTool typeperf ""
ListTool tzsync "--version"
2023-06-16 11:51:52 +02:00
ListTool unbound "-V"
2023-05-17 07:56:18 +02:00
ListTool uniq "--version"
ListTool vi "--version"
ListTool vim "--version"
ListTool vulkaninfo "--version"
ListTool w32tm "/?"
ListTool waitfor "--version"
2023-06-02 13:25:58 +02:00
ListTool wakeonlan "-v"
2023-05-17 07:56:18 +02:00
ListTool wget "--version"
ListTool where "--version"
ListTool whatis "--version"
ListTool which ""
ListTool winget "--version"
ListTool winsat ""
ListTool whoami "--version"
ListTool wput "--version"
ListTool write ""
ListTool wsl "--version"
ListTool xcopy "--version"
ListTool yes "--version"
ListTool zip "--version"
ListTool zipcloak "--version"
ListTool zipdetails ""
ListTool zipgrep ""
ListTool zipinfo ""
ListTool zipnote ""
ListTool zipsplit ""
ListTool zsh "--version"
2021-07-22 10:49:42 +02:00
}
try {
2023-10-10 15:17:37 +02:00
ListTools | Format-Table -property @{e='CLI-Tool';width=14},@{e='Version';width=17},@{e='Location';width=90}
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-11-21 21:42:41 +01:00
}