forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-cli-tools.ps1
executable file
·339 lines (334 loc) · 8.99 KB
/
list-cli-tools.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<#
.SYNOPSIS
Lists command-line tools
.DESCRIPTION
This PowerShell script lists installed command-line interface (CLI) tools (sorted alphabetically by name).
.EXAMPLE
PS> ./list-cli-tools.ps1
Tool Name Version Installation Path
--------- ------- -----------------
7z 23.01 /usr/bin/7z (38 bytes)
...
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
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) {
try {
$Info = Get-Command $Name -ErrorAction Stop
$Path = $Info.Source
if ("$($Info.Version)" -eq "0.0.0.0") {
if ("$VersionArg" -ne "") {
$Result = Invoke-Expression "$Path $VersionArg"
if ("$Result" -match '\d+.\d+\.\d+') {
$Version = "$($Matches[0])"
} elseif ("$Result" -match '\d+\.\d+') {
$Version = "$($Matches[0])"
} else {
$Version = ""
}
} else {
$Version = ""
}
} else {
$Version = $Info.Version
}
if (Test-Path "$Path" -pathType leaf) {
$Size = (Get-Item "$Path").Length
} else {
$Size = 0
}
New-Object PSObject -Property @{ 'Tool Name'=$Name; 'Version'=$Version; 'Installation Path'="$Path ($(Bytes2String $Size))" }
} catch {
return
}
}
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 "--version"
ListTool at ""
ListTool attrib ""
ListTool auditpol ""
ListTool awk "--version"
ListTool b2sum "--version"
ListTool base32 "--version"
ListTool base64 "--version"
ListTool basename "--version"
ListTool basenc "--version"
ListTool bash "--version"
ListTool bc "--version"
ListTool bcdboot ""
ListTool bcdedit ""
ListTool bitsadmin ""
ListTool bunzip2 "--version"
ListTool bzcat "--version"
ListTool bzip2 "--version"
ListTool bzip2recover "--version"
ListTool captoinfo "-V"
ListTool cat "-version"
ListTool cc "--version"
ListTool certutil "/?"
ListTool chattr "--version"
ListTool chcon "--version"
ListTool chcpu "--version"
ListTool chdsk ""
ListTool chglogon ""
ListTool chgport ""
ListTool chgusr ""
ListTool chgrp "--version"
ListTool chmod "--version"
ListTool chkntfs ""
ListTool chmem "--version"
ListTool choice "/?"
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 ""
ListTool cmdkey "/list"
ListTool cmp "--version"
ListTool column "--version"
ListTool comp ""
ListTool compact ""
ListTool cp "--version"
ListTool cpack "--version"
ListTool cscript ""
ListTool csplit "--version"
ListTool ctest "--version"
ListTool curl "--version"
ListTool curl.exe "--version"
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"
ListTool doskey "/?"
ListTool dotnet "--info"
ListTool driverquery ""
ListTool du "--version"
ListTool echo "--version"
ListTool egrep "--version"
ListTool emacs "--version"
ListTool env "--version"
ListTool eventcreate "/?"
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"
ListTool gradle "--version"
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 ip "help"
ListTool ipfs "--version"
ListTool java "--version"
ListTool jcli "version"
ListTool join "--version"
ListTool jhead "-V"
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 nmap "--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"
ListTool pnputil "/?"
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 ""
ListTool rpcping ""
ListTool rsh ""
ListTool rsync "--version"
ListTool rundll32 "--version"
ListTool sc.exe "/?"
ListTool scp ""
ListTool setx ""
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"
ListTool terraform "--version"
ListTool time ""
ListTool timeout ""
ListTool top "--version"
ListTool tskill ""
ListTool typeperf ""
ListTool tzsync "--version"
ListTool unbound "-V"
ListTool uniq "--version"
ListTool vi "--version"
ListTool vim "--version"
ListTool vssadmin "/?"
ListTool vulkaninfo "--version"
ListTool w32tm "/?"
ListTool waitfor "--version"
ListTool wakeonlan "-v"
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"
}
try {
ListTools | Format-Table -property @{e='Tool Name';width=15},@{e='Version';width=15},@{e='Installation Path';width=90}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}