windowsweep 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI-INTEGRATION-GUIDE.md +203 -0
- package/CHANGELOG.md +124 -0
- package/LICENSE +21 -21
- package/README.md +88 -49
- package/VERSION +1 -1
- package/lib/actions.ps1 +212 -209
- package/lib/config.ps1 +108 -99
- package/lib/constants.ps1 +103 -89
- package/lib/fs.ps1 +189 -180
- package/lib/log.ps1 +140 -140
- package/lib/safety.ps1 +541 -493
- package/lib/scan.ps1 +109 -94
- package/lib/ui.ps1 +275 -235
- package/modules/android_avd.ps1 +36 -36
- package/modules/app_caches.ps1 +58 -58
- package/modules/browsers.ps1 +33 -33
- package/modules/build_tools.ps1 +35 -35
- package/modules/crash_trap.ps1 +89 -89
- package/modules/disk_usage.ps1 +49 -49
- package/modules/docker.ps1 +93 -93
- package/modules/editors.ps1 +150 -150
- package/modules/globals_audit.ps1 +236 -0
- package/modules/health.ps1 +101 -101
- package/modules/installed_programs.ps1 +118 -0
- package/modules/menu.ps1 +63 -61
- package/modules/notify.ps1 +60 -0
- package/modules/orphaned_appdata.ps1 +189 -0
- package/modules/personal.ps1 +126 -124
- package/modules/pkg_managers.ps1 +73 -69
- package/modules/projects.ps1 +160 -143
- package/modules/release_helpers.ps1 +438 -434
- package/modules/reports.ps1 +212 -212
- package/modules/runner.ps1 +242 -190
- package/modules/self_test_extra.ps1 +537 -86
- package/modules/startup_audit.ps1 +126 -0
- package/modules/system_admin.ps1 +220 -220
- package/modules/test_runners.ps1 +24 -24
- package/modules/walkthrough.ps1 +80 -79
- package/modules/windows_user.ps1 +118 -112
- package/package.json +4 -3
- package/windowsweep.ps1 +322 -296
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# globals_audit.ps1 - section 22: globally installed packages, read-only.
|
|
2
|
+
# Lists what npm, pnpm, yarn, bun and deno installed globally, flags the ones nothing has referenced for
|
|
3
|
+
# N+ days, and prints the exact uninstall command. It NEVER removes anything, in any mode: several of these
|
|
4
|
+
# roots (nvm4w, AppData\npm, pnpm\global, .bun, .deno\bin) are protected subtrees by design.
|
|
5
|
+
|
|
6
|
+
# Never proposed as a candidate: the tool itself and the package managers everything else depends on.
|
|
7
|
+
$Script:WS_GLOBAL_KEEP = @('npm', 'corepack', 'pnpm', 'yarn', 'windowsweep')
|
|
8
|
+
|
|
9
|
+
function Get-GlobalPackageRoots {
|
|
10
|
+
<# .SYNOPSIS Existing global install roots, one row per manager. Style: node_modules (packages) | bin (shims). #>
|
|
11
|
+
$P = $Script:P
|
|
12
|
+
$rows = @()
|
|
13
|
+
$npmRoot = ''
|
|
14
|
+
if (Test-CommandPresent 'npm') {
|
|
15
|
+
try {
|
|
16
|
+
$out = & npm root -g 2>$null
|
|
17
|
+
$line = ($out | Select-Object -Last 1)
|
|
18
|
+
if ($line) { $npmRoot = $line.Trim() }
|
|
19
|
+
} catch { $null = $_ }
|
|
20
|
+
}
|
|
21
|
+
if (-not $npmRoot) { $npmRoot = Join-Path $P.A 'npm\node_modules' }
|
|
22
|
+
$fixed = @(
|
|
23
|
+
@('npm', $npmRoot, 'node_modules'),
|
|
24
|
+
@('yarn', "$($P.L)\Yarn\Data\global\node_modules", 'node_modules'),
|
|
25
|
+
@('bun', "$($P.U)\.bun\install\global\node_modules", 'node_modules'),
|
|
26
|
+
@('deno', "$($P.U)\.deno\bin", 'bin')
|
|
27
|
+
)
|
|
28
|
+
foreach ($f in $fixed) {
|
|
29
|
+
if (Test-DirPresent $f[1]) { $rows += [pscustomobject]@{ Manager = $f[0]; Root = (Get-FullPath $f[1]); Style = $f[2] } }
|
|
30
|
+
}
|
|
31
|
+
# Version-managed and store-style roots are globs: one root per installed Node version / pnpm version.
|
|
32
|
+
$globs = @()
|
|
33
|
+
$globs += @(@('npm', "$($P.A)\nvm\v*\node_modules"))
|
|
34
|
+
if ($env:NVM_HOME) { $globs += @(@('npm', (Join-Path $env:NVM_HOME 'v*\node_modules'))) }
|
|
35
|
+
$globs += @(@('pnpm', "$($P.L)\pnpm\global\*\node_modules"))
|
|
36
|
+
foreach ($g in $globs) {
|
|
37
|
+
$hits = @()
|
|
38
|
+
try { $hits = @(Get-Item -Path $g[1] -Force -ErrorAction SilentlyContinue | Where-Object { $_ -is [IO.DirectoryInfo] } | ForEach-Object { $_.FullName }) } catch { $hits = @() }
|
|
39
|
+
foreach ($h in $hits) { $rows += [pscustomobject]@{ Manager = $g[0]; Root = (Get-FullPath $h); Style = 'node_modules' } }
|
|
40
|
+
}
|
|
41
|
+
$seen = New-Object System.Collections.Generic.HashSet[string]([StringComparer]::OrdinalIgnoreCase)
|
|
42
|
+
return @($rows | Where-Object { $seen.Add($_.Root) })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Get-PackageBinNames {
|
|
46
|
+
<# .SYNOPSIS Command names a package.json 'bin' field installs: a string means one bin named after the package. #>
|
|
47
|
+
param([object] $Manifest, [string] $Name)
|
|
48
|
+
$out = @()
|
|
49
|
+
if ($null -eq $Manifest) { return $out }
|
|
50
|
+
$bin = $Manifest.bin
|
|
51
|
+
if ($null -eq $bin) { return $out }
|
|
52
|
+
if ($bin -is [string]) { return @(($Name -split '/')[-1]) }
|
|
53
|
+
foreach ($p in $bin.PSObject.Properties) { $out += $p.Name }
|
|
54
|
+
return $out
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function Get-GlobalPackages {
|
|
58
|
+
<# .SYNOPSIS Packages under one global root. Reads each package.json (top level only) - never walks a global tree. #>
|
|
59
|
+
param([pscustomobject] $RootRow)
|
|
60
|
+
$rows = @()
|
|
61
|
+
if ($RootRow.Style -eq 'bin') {
|
|
62
|
+
foreach ($e in (Get-ChildEntries $RootRow.Root)) {
|
|
63
|
+
if ($e -is [IO.DirectoryInfo]) { continue }
|
|
64
|
+
if ($e.Extension -eq '.cmd') { continue }
|
|
65
|
+
$idle = [int][math]::Floor(([datetime]::UtcNow - (Get-NewestTimestampUtc $e)).TotalDays)
|
|
66
|
+
$rows += [pscustomobject]@{ Manager = $RootRow.Manager; Name = [IO.Path]::GetFileNameWithoutExtension($e.Name)
|
|
67
|
+
Version = ''; Path = (Remove-LongPrefix $e.FullName); Bytes = [long]$e.Length; Idle = $idle
|
|
68
|
+
Bins = @([IO.Path]::GetFileNameWithoutExtension($e.Name)) }
|
|
69
|
+
}
|
|
70
|
+
return $rows
|
|
71
|
+
}
|
|
72
|
+
$dirs = @()
|
|
73
|
+
foreach ($e in (Get-ChildEntries $RootRow.Root)) {
|
|
74
|
+
if (-not ($e -is [IO.DirectoryInfo]) -or (Test-ReparsePoint $e)) { continue }
|
|
75
|
+
if ($e.Name -eq '.bin') { continue }
|
|
76
|
+
if ($e.Name.StartsWith('@')) {
|
|
77
|
+
foreach ($s in (Get-ChildEntries (Remove-LongPrefix $e.FullName))) {
|
|
78
|
+
if ($s -is [IO.DirectoryInfo]) { $dirs += [pscustomobject]@{ Name = ($e.Name + '/' + $s.Name); Dir = (Remove-LongPrefix $s.FullName) } }
|
|
79
|
+
}
|
|
80
|
+
continue
|
|
81
|
+
}
|
|
82
|
+
$dirs += [pscustomobject]@{ Name = $e.Name; Dir = (Remove-LongPrefix $e.FullName) }
|
|
83
|
+
}
|
|
84
|
+
foreach ($d in $dirs) {
|
|
85
|
+
$manifest = $null
|
|
86
|
+
$mf = Join-Path $d.Dir 'package.json'
|
|
87
|
+
if (Test-PathPresent $mf) { try { $manifest = @(Read-JsonFile $mf)[0] } catch { $manifest = $null } }
|
|
88
|
+
$version = ''
|
|
89
|
+
if ($manifest -and $manifest.version) { $version = [string]$manifest.version }
|
|
90
|
+
# The newest of the package's own top-level entries: a global node_modules is far too big to walk.
|
|
91
|
+
$newest = [datetime]::MinValue
|
|
92
|
+
foreach ($c in (Get-ChildEntries $d.Dir)) { $t = Get-NewestTimestampUtc $c; if ($t -gt $newest) { $newest = $t } }
|
|
93
|
+
if ($newest -eq [datetime]::MinValue) { $newest = [datetime]::UtcNow }
|
|
94
|
+
$rows += [pscustomobject]@{ Manager = $RootRow.Manager; Name = $d.Name; Version = $version; Path = $d.Dir
|
|
95
|
+
Bytes = [long](Get-DirectoryBytes $d.Dir); Idle = [int][math]::Floor(([datetime]::UtcNow - $newest).TotalDays)
|
|
96
|
+
Bins = @(Get-PackageBinNames -Manifest $manifest -Name $d.Name) }
|
|
97
|
+
}
|
|
98
|
+
return $rows
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function Get-ProjectPackageIndex {
|
|
102
|
+
<# .SYNOPSIS What the project roots reference: dependency names, script text and local .bin command names.
|
|
103
|
+
Only manifests touched inside the idle window count - an ancient project does not keep a global alive. #>
|
|
104
|
+
param([string[]] $Roots, [int] $Days, [int] $MaxDepth = 4, [int] $MaxFiles = 2000)
|
|
105
|
+
$names = New-Object System.Collections.Generic.HashSet[string]([StringComparer]::OrdinalIgnoreCase)
|
|
106
|
+
$bins = New-Object System.Collections.Generic.HashSet[string]([StringComparer]::OrdinalIgnoreCase)
|
|
107
|
+
$script = New-Object System.Text.StringBuilder
|
|
108
|
+
$seen = 0
|
|
109
|
+
foreach ($root in $Roots) {
|
|
110
|
+
$stack = New-Object System.Collections.Generic.Stack[object]
|
|
111
|
+
$stack.Push(@($root, 0))
|
|
112
|
+
while ($stack.Count -gt 0 -and $seen -lt $MaxFiles) {
|
|
113
|
+
$item = $stack.Pop()
|
|
114
|
+
$dir = [string]$item[0]; $depth = [int]$item[1]
|
|
115
|
+
foreach ($e in (Get-ChildEntries $dir)) {
|
|
116
|
+
if (Test-ReparsePoint $e) { continue }
|
|
117
|
+
if ($e -is [IO.DirectoryInfo]) {
|
|
118
|
+
if ($e.Name -eq 'node_modules') {
|
|
119
|
+
foreach ($b in (Get-ChildEntries (Join-Path (Remove-LongPrefix $e.FullName) '.bin'))) { $null = $bins.Add([IO.Path]::GetFileNameWithoutExtension($b.Name)) }
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
if ($Script:WS_NEVER_ENTER -contains $e.Name -or $e.Name.StartsWith('.')) { continue }
|
|
123
|
+
if ($depth -lt $MaxDepth) { $stack.Push(@((Remove-LongPrefix $e.FullName), $depth + 1)) }
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
126
|
+
if ($e.Name -ne 'package.json') { continue }
|
|
127
|
+
$seen++
|
|
128
|
+
if ([int][math]::Floor(([datetime]::UtcNow - (Get-NewestTimestampUtc $e)).TotalDays) -ge $Days) { continue }
|
|
129
|
+
$m = $null
|
|
130
|
+
try { $m = @(Read-JsonFile (Remove-LongPrefix $e.FullName))[0] } catch { $m = $null }
|
|
131
|
+
if ($null -eq $m) { continue }
|
|
132
|
+
foreach ($field in @('dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies')) {
|
|
133
|
+
if ($m.$field) { foreach ($p in $m.$field.PSObject.Properties) { $null = $names.Add($p.Name) } }
|
|
134
|
+
}
|
|
135
|
+
if ($m.scripts -and $script.Length -lt 200000) {
|
|
136
|
+
foreach ($p in $m.scripts.PSObject.Properties) { $null = $script.Append(' ').Append([string]$p.Value) }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return [pscustomobject]@{ Names = $names; Bins = $bins; ScriptText = $script.ToString().ToLowerInvariant(); Scanned = $seen }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function Get-GlobalPackageVerdict {
|
|
145
|
+
<# .SYNOPSIS Pure verdict for one global package: keep | candidate, plus whether a project shadows its command.
|
|
146
|
+
Candidate needs all three: idle past the window, never referenced, and not a package manager we protect. #>
|
|
147
|
+
param([pscustomobject] $Package, [pscustomobject] $Index, [int] $Days)
|
|
148
|
+
$short = ($Package.Name -split '/')[-1]
|
|
149
|
+
$shadowed = $false
|
|
150
|
+
foreach ($b in @($Package.Bins)) { if ($Index.Bins.Contains($b)) { $shadowed = $true } }
|
|
151
|
+
if ($Script:WS_GLOBAL_KEEP -contains $short -or $Script:WS_GLOBAL_KEEP -contains $Package.Name) {
|
|
152
|
+
return [pscustomobject]@{ Verdict = 'keep'; Reason = 'package manager / this tool'; Shadowed = $shadowed }
|
|
153
|
+
}
|
|
154
|
+
if ($Index.Names.Contains($Package.Name)) { return [pscustomobject]@{ Verdict = 'keep'; Reason = 'a recent project depends on it'; Shadowed = $shadowed } }
|
|
155
|
+
foreach ($b in @($Package.Bins)) {
|
|
156
|
+
if ($b -and $Index.ScriptText.Contains($b.ToLowerInvariant())) { return [pscustomobject]@{ Verdict = 'keep'; Reason = "a recent project script runs '$b'"; Shadowed = $shadowed } }
|
|
157
|
+
}
|
|
158
|
+
if ($Package.Idle -lt $Days) { return [pscustomobject]@{ Verdict = 'keep'; Reason = "touched $($Package.Idle) days ago"; Shadowed = $shadowed } }
|
|
159
|
+
return [pscustomobject]@{ Verdict = 'candidate'; Reason = "nothing referenced it and it is $($Package.Idle) days old"; Shadowed = $shadowed }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function Get-GlobalUninstallCommand {
|
|
163
|
+
<# .SYNOPSIS The exact command that removes one global package for its manager. #>
|
|
164
|
+
param([string] $Manager, [string] $Name)
|
|
165
|
+
switch ($Manager) {
|
|
166
|
+
'npm' { return "npm uninstall -g $Name" }
|
|
167
|
+
'pnpm' { return "pnpm remove -g $Name" }
|
|
168
|
+
'yarn' { return "yarn global remove $Name" }
|
|
169
|
+
'bun' { return "bun remove -g $Name" }
|
|
170
|
+
'deno' { return "deno uninstall $Name" }
|
|
171
|
+
default { return "# remove $Name manually" }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function Get-Targets22 {
|
|
176
|
+
<# .SYNOPSIS Informational rows only. Section 22 declares NO deletable target: these roots are protected. #>
|
|
177
|
+
$t = @()
|
|
178
|
+
foreach ($r in (Get-GlobalPackageRoots)) { $t += (New-Target 22 "$($r.Manager) global root" $r.Root -Kind cmd -Note 'read-only audit; this section never deletes') }
|
|
179
|
+
if ($t.Count -eq 0) { $t += (New-Target 22 'global package roots' '(none detected)' -Kind cmd -Note 'read-only audit; this section never deletes') }
|
|
180
|
+
return $t
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function Invoke-Section22 {
|
|
184
|
+
$ws = $Script:WS
|
|
185
|
+
Write-SectionIntro @(
|
|
186
|
+
'What npm, pnpm, yarn, bun and deno installed globally, and which of those nothing has referenced lately.',
|
|
187
|
+
"A package is a candidate only when it is $($ws.Days)+ days old AND no project touched recently names it.",
|
|
188
|
+
'This section never uninstalls anything - it prints the command and leaves the decision to you.'
|
|
189
|
+
)
|
|
190
|
+
$roots = @(Get-GlobalPackageRoots)
|
|
191
|
+
if ($roots.Count -eq 0) { Write-Info 'no global package roots found'; return }
|
|
192
|
+
Write-Info ('roots: ' + (($roots | ForEach-Object { "$($_.Manager) -> $($_.Root)" }) -join ' '))
|
|
193
|
+
$packages = @()
|
|
194
|
+
foreach ($r in $roots) { $packages += @(Get-GlobalPackages -RootRow $r) }
|
|
195
|
+
if ($packages.Count -eq 0) { Write-Info 'no globally installed packages found'; return }
|
|
196
|
+
$projectRoots = @(Get-ProjectScanRoots)
|
|
197
|
+
$index = Get-ProjectPackageIndex -Roots $projectRoots -Days $ws.Days
|
|
198
|
+
Write-Note "checked $($index.Scanned) project manifest(s) under: $($projectRoots -join ' ')"
|
|
199
|
+
$lines = @("global packages audit - $(Get-Date -Format 'yyyy-MM-dd HH:mm') - idle window $($ws.Days) days", '')
|
|
200
|
+
$kept = @(); $cand = @()
|
|
201
|
+
foreach ($p in ($packages | Sort-Object Bytes -Descending)) {
|
|
202
|
+
$v = Get-GlobalPackageVerdict -Package $p -Index $index -Days $ws.Days
|
|
203
|
+
$row = [pscustomobject]@{ Package = $p; Verdict = $v }
|
|
204
|
+
if ($v.Verdict -eq 'candidate') { $cand += $row } else { $kept += $row }
|
|
205
|
+
}
|
|
206
|
+
Write-Section 'Kept'
|
|
207
|
+
Write-UiLine (" {0,-34} {1,-10} {2,10} {3,6} {4}" -f 'PACKAGE', 'VERSION', 'SIZE', 'IDLE', 'WHY') 'White'
|
|
208
|
+
foreach ($r in $kept) {
|
|
209
|
+
$line = " {0,-34} {1,-10} {2,10} {3,5}d {4}" -f $r.Package.Name, $r.Package.Version, (Format-Bytes $r.Package.Bytes), $r.Package.Idle, $r.Verdict.Reason
|
|
210
|
+
Write-UiLine $line 'Gray'; $lines += ('kept ' + $line.Trim())
|
|
211
|
+
}
|
|
212
|
+
Write-Section 'Candidates - nothing recent referenced these'
|
|
213
|
+
if ($cand.Count -eq 0) { Write-Info 'none' } else {
|
|
214
|
+
Write-UiLine (" {0,-34} {1,-10} {2,10} {3,6} {4}" -f 'PACKAGE', 'VERSION', 'SIZE', 'IDLE', 'NOTE') 'White'
|
|
215
|
+
$total = [long]0
|
|
216
|
+
foreach ($r in $cand) {
|
|
217
|
+
$note = ''
|
|
218
|
+
if ($r.Verdict.Shadowed) { $note = 'a project installs this command locally' }
|
|
219
|
+
$line = " {0,-34} {1,-10} {2,10} {3,5}d {4}" -f $r.Package.Name, $r.Package.Version, (Format-Bytes $r.Package.Bytes), $r.Package.Idle, $note
|
|
220
|
+
Write-UiLine $line 'Yellow'; $lines += ('candidate ' + $line.Trim())
|
|
221
|
+
$total += $r.Package.Bytes
|
|
222
|
+
}
|
|
223
|
+
Write-Info ('candidates hold ' + (Format-Bytes $total))
|
|
224
|
+
Write-Section 'Remove them yourself with'
|
|
225
|
+
$lines += ''; $lines += 'uninstall commands:'
|
|
226
|
+
foreach ($r in $cand) {
|
|
227
|
+
$cmd = Get-GlobalUninstallCommand -Manager $r.Package.Manager -Name $r.Package.Name
|
|
228
|
+
Write-Plain " $cmd"; $lines += " $cmd"
|
|
229
|
+
}
|
|
230
|
+
Write-Note 'windowsweep does not run these: a global package can be a command you rely on rarely.'
|
|
231
|
+
}
|
|
232
|
+
if (-not $ws.NoReport) {
|
|
233
|
+
$out = Join-Path $ws.ReportsDir ('global-packages-' + $ws.Stamp + '.txt')
|
|
234
|
+
try { [IO.File]::WriteAllLines($out, $lines); Write-Note "list saved: $out" } catch { $null = $_ }
|
|
235
|
+
}
|
|
236
|
+
}
|
package/modules/health.ps1
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
# health.ps1 - section 0: read-only system health report.
|
|
2
|
-
|
|
3
|
-
function Get-Targets00 { return @() }
|
|
4
|
-
|
|
5
|
-
function Get-HiberfilInfo {
|
|
6
|
-
$p = Join-Path $Script:P.SD '\hiberfil.sys'
|
|
7
|
-
$size = [long]0
|
|
8
|
-
# Get-Item cannot open the hibernation file without elevation, but FileInfo reads its size from the directory entry.
|
|
9
|
-
try { $f = New-Object IO.FileInfo($p); if ($f.Exists) { $size = [long]$f.Length } } catch { $size = 0 }
|
|
10
|
-
$state = 'unknown'
|
|
11
|
-
try {
|
|
12
|
-
$a = (& powercfg.exe /a 2>$null) -join ' '
|
|
13
|
-
if ($a -match 'Hibernate' -and $a -notmatch 'Hibernation has not been enabled') { $state = 'available' } else { $state = 'off' }
|
|
14
|
-
} catch { $null = $_ }
|
|
15
|
-
return [pscustomobject]@{ Path = $p; Bytes = $size; State = $state }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function Get-DiskImageFiles {
|
|
19
|
-
<# .SYNOPSIS Docker Desktop / WSL virtual disks (they grow but never shrink on their own). #>
|
|
20
|
-
$L = $Script:P.L
|
|
21
|
-
$out = @()
|
|
22
|
-
foreach ($root in @((Join-Path $L 'Docker\wsl'), (Join-Path $L 'Packages'))) {
|
|
23
|
-
if (-not (Test-DirPresent $root)) { continue }
|
|
24
|
-
try { $out += Get-ChildItem -LiteralPath $root -Recurse -Filter '*.vhdx' -File -Depth 4 -ErrorAction SilentlyContinue } catch { $null = $_ }
|
|
25
|
-
}
|
|
26
|
-
return $out
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function Get-BlockingApps {
|
|
30
|
-
<# .SYNOPSIS Running apps whose caches this tool skips while they run. #>
|
|
31
|
-
$map = [ordered]@{ chrome = 'Chrome'; msedge = 'Edge'; brave = 'Brave'; firefox = 'Firefox'; vivaldi = 'Vivaldi'; opera = 'Opera'; Code = 'VS Code'; Cursor = 'Cursor'; Windsurf = 'Windsurf'; Discord = 'Discord'; slack = 'Slack'; 'ms-teams' = 'Teams'; Zoom = 'Zoom'; Spotify = 'Spotify'; Postman = 'Postman'; Figma = 'Figma'; Notion = 'Notion' }
|
|
32
|
-
$out = @()
|
|
33
|
-
foreach ($k in $map.Keys) { if (Test-ProcessRunning @($k)) { $out += $map[$k] } }
|
|
34
|
-
return $out
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function Invoke-Section00 {
|
|
38
|
-
$ws = $Script:WS
|
|
39
|
-
Write-SectionIntro @('Read-only snapshot of the machine: nothing is changed here.')
|
|
40
|
-
try {
|
|
41
|
-
$os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop
|
|
42
|
-
Write-Kv 'Windows:' "$($os.Caption) $($os.Version) (build $($os.BuildNumber))"
|
|
43
|
-
$up = (Get-Date) - $os.LastBootUpTime
|
|
44
|
-
Write-Kv 'Uptime:' ("{0}d {1}h {2}m" -f $up.Days, $up.Hours, $up.Minutes)
|
|
45
|
-
Write-Kv 'RAM:' ("{0} total, {1} free" -f (Format-Bytes ($os.TotalVisibleMemorySize * 1KB)), (Format-Bytes ($os.FreePhysicalMemory * 1KB)))
|
|
46
|
-
} catch { Write-Kv 'Windows:' $ws.OsCaption }
|
|
47
|
-
Write-Kv 'PowerShell:' "$($PSVersionTable.PSVersion) ($($PSVersionTable.PSEdition))"
|
|
48
|
-
$adm = 'no'
|
|
49
|
-
if ($ws.IsAdmin) { $adm = 'yes' } elseif (Test-CanElevate) { $adm = 'no (your account can elevate: --elevate)' } else { $adm = 'no (standard user; admin sections need an administrator)' }
|
|
50
|
-
Write-Kv 'Elevated:' $adm
|
|
51
|
-
$dev = 'not decided yet'
|
|
52
|
-
if ($null -ne $ws.Developer) { if ($ws.Developer) { $dev = "on ($($ws.DeveloperSource))" } else { $dev = "off ($($ws.DeveloperSource))" } }
|
|
53
|
-
Write-Kv 'Developer mode:' $dev
|
|
54
|
-
$hints = @(Get-ToolchainHints)
|
|
55
|
-
if ($hints.Count -gt 0) { Write-Kv 'Dev tooling found:' ($hints -join ', ') }
|
|
56
|
-
Write-UiLine '' 'Gray'
|
|
57
|
-
Show-DriveTable
|
|
58
|
-
try {
|
|
59
|
-
$sys = New-Object IO.DriveInfo($Script:P.SD)
|
|
60
|
-
$pct = 100.0 * $sys.AvailableFreeSpace / $sys.TotalSize
|
|
61
|
-
if ($sys.AvailableFreeSpace -lt 10GB -or $pct -lt 10) { Write-Warn ("system drive has only {0} free ({1:N1}%) -
|
|
62
|
-
} catch { $null = $_ }
|
|
63
|
-
Write-UiLine '' 'Gray'
|
|
64
|
-
$h = Get-HiberfilInfo
|
|
65
|
-
if ($h.Bytes -gt 0) { Write-Kv 'hiberfil.sys:' ("{0} (hibernation {1}) - section 15 can shrink or remove it (admin)" -f (Format-Bytes $h.Bytes), $h.State) } else { Write-Kv 'hiberfil.sys:' 'absent (hibernation off)' }
|
|
66
|
-
try {
|
|
67
|
-
foreach ($pf in (Get-CimInstance Win32_PageFileUsage -ErrorAction Stop)) { Write-Kv 'pagefile:' ("{0} {1} allocated" -f $pf.Name, (Format-Bytes ($pf.AllocatedBaseSize * 1MB))) }
|
|
68
|
-
} catch { $null = $_ }
|
|
69
|
-
foreach ($img in (Get-DiskImageFiles)) { Write-Kv 'disk image:' ("{0} {1} (section 20 compacts it, admin)" -f $img.FullName, (Format-Bytes $img.Length)) }
|
|
70
|
-
if (Test-CommandPresent 'wsl.exe') {
|
|
71
|
-
try {
|
|
72
|
-
$raw = & wsl.exe --list --verbose 2>$null
|
|
73
|
-
$txt = (($raw | ForEach-Object { [string]$_ }) -join "`n") -replace "`0", ''
|
|
74
|
-
$lines = @($txt -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ -and $_ -notmatch '^NAME' })
|
|
75
|
-
if ($lines.Count -gt 0) { Write-Kv 'WSL distros:' (($lines | ForEach-Object { ($_ -replace '\s+', ' ') }) -join ' | ') }
|
|
76
|
-
} catch { $null = $_ }
|
|
77
|
-
}
|
|
78
|
-
Write-UiLine '' 'Gray'
|
|
79
|
-
try { $n = @(Get-CimInstance Win32_StartupCommand -ErrorAction Stop).Count; Write-Kv 'Startup items:' "$n (
|
|
80
|
-
try {
|
|
81
|
-
$ss = (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy' -ErrorAction Stop).'01'
|
|
82
|
-
$ssText = 'off'
|
|
83
|
-
if ($ss -eq 1) { $ssText = 'on' }
|
|
84
|
-
Write-Kv 'Storage Sense:' $ssText
|
|
85
|
-
} catch { $null = $_ }
|
|
86
|
-
try {
|
|
87
|
-
$la = (& fsutil.exe behavior query disablelastaccess 2>$null) -join ' '
|
|
88
|
-
if ($la -match '=\s*(\d)') {
|
|
89
|
-
$v = [int]$Matches[1]
|
|
90
|
-
$laText = 'disabled - idle age uses write/creation times (
|
|
91
|
-
if ($v -eq 1 -or $v -eq 3) { $laText = 'enabled - last-access times are reliable' }
|
|
92
|
-
Write-Kv 'Last-access tracking:' $laText
|
|
93
|
-
}
|
|
94
|
-
} catch { $null = $_ }
|
|
95
|
-
$blocking = @(Get-BlockingApps)
|
|
96
|
-
if ($blocking.Count -gt 0) {
|
|
97
|
-
Write-UiLine '' 'Gray'
|
|
98
|
-
Write-Warn ("running now, their caches will be skipped until closed: " + ($blocking -join ', '))
|
|
99
|
-
}
|
|
100
|
-
Add-Freed 0
|
|
101
|
-
}
|
|
1
|
+
# health.ps1 - section 0: read-only system health report.
|
|
2
|
+
|
|
3
|
+
function Get-Targets00 { return @() }
|
|
4
|
+
|
|
5
|
+
function Get-HiberfilInfo {
|
|
6
|
+
$p = Join-Path $Script:P.SD '\hiberfil.sys'
|
|
7
|
+
$size = [long]0
|
|
8
|
+
# Get-Item cannot open the hibernation file without elevation, but FileInfo reads its size from the directory entry.
|
|
9
|
+
try { $f = New-Object IO.FileInfo($p); if ($f.Exists) { $size = [long]$f.Length } } catch { $size = 0 }
|
|
10
|
+
$state = 'unknown'
|
|
11
|
+
try {
|
|
12
|
+
$a = (& powercfg.exe /a 2>$null) -join ' '
|
|
13
|
+
if ($a -match 'Hibernate' -and $a -notmatch 'Hibernation has not been enabled') { $state = 'available' } else { $state = 'off' }
|
|
14
|
+
} catch { $null = $_ }
|
|
15
|
+
return [pscustomobject]@{ Path = $p; Bytes = $size; State = $state }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Get-DiskImageFiles {
|
|
19
|
+
<# .SYNOPSIS Docker Desktop / WSL virtual disks (they grow but never shrink on their own). #>
|
|
20
|
+
$L = $Script:P.L
|
|
21
|
+
$out = @()
|
|
22
|
+
foreach ($root in @((Join-Path $L 'Docker\wsl'), (Join-Path $L 'Packages'))) {
|
|
23
|
+
if (-not (Test-DirPresent $root)) { continue }
|
|
24
|
+
try { $out += Get-ChildItem -LiteralPath $root -Recurse -Filter '*.vhdx' -File -Depth 4 -ErrorAction SilentlyContinue } catch { $null = $_ }
|
|
25
|
+
}
|
|
26
|
+
return $out
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function Get-BlockingApps {
|
|
30
|
+
<# .SYNOPSIS Running apps whose caches this tool skips while they run. #>
|
|
31
|
+
$map = [ordered]@{ chrome = 'Chrome'; msedge = 'Edge'; brave = 'Brave'; firefox = 'Firefox'; vivaldi = 'Vivaldi'; opera = 'Opera'; Code = 'VS Code'; Cursor = 'Cursor'; Windsurf = 'Windsurf'; Discord = 'Discord'; slack = 'Slack'; 'ms-teams' = 'Teams'; Zoom = 'Zoom'; Spotify = 'Spotify'; Postman = 'Postman'; Figma = 'Figma'; Notion = 'Notion' }
|
|
32
|
+
$out = @()
|
|
33
|
+
foreach ($k in $map.Keys) { if (Test-ProcessRunning @($k)) { $out += $map[$k] } }
|
|
34
|
+
return $out
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Invoke-Section00 {
|
|
38
|
+
$ws = $Script:WS
|
|
39
|
+
Write-SectionIntro @('Read-only snapshot of the machine: nothing is changed here.')
|
|
40
|
+
try {
|
|
41
|
+
$os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop
|
|
42
|
+
Write-Kv 'Windows:' "$($os.Caption) $($os.Version) (build $($os.BuildNumber))"
|
|
43
|
+
$up = (Get-Date) - $os.LastBootUpTime
|
|
44
|
+
Write-Kv 'Uptime:' ("{0}d {1}h {2}m" -f $up.Days, $up.Hours, $up.Minutes)
|
|
45
|
+
Write-Kv 'RAM:' ("{0} total, {1} free" -f (Format-Bytes ($os.TotalVisibleMemorySize * 1KB)), (Format-Bytes ($os.FreePhysicalMemory * 1KB)))
|
|
46
|
+
} catch { Write-Kv 'Windows:' $ws.OsCaption }
|
|
47
|
+
Write-Kv 'PowerShell:' "$($PSVersionTable.PSVersion) ($($PSVersionTable.PSEdition))"
|
|
48
|
+
$adm = 'no'
|
|
49
|
+
if ($ws.IsAdmin) { $adm = 'yes' } elseif (Test-CanElevate) { $adm = 'no (your account can elevate: --elevate)' } else { $adm = 'no (standard user; admin sections need an administrator)' }
|
|
50
|
+
Write-Kv 'Elevated:' $adm
|
|
51
|
+
$dev = 'not decided yet'
|
|
52
|
+
if ($null -ne $ws.Developer) { if ($ws.Developer) { $dev = "on ($($ws.DeveloperSource))" } else { $dev = "off ($($ws.DeveloperSource))" } }
|
|
53
|
+
Write-Kv 'Developer mode:' $dev
|
|
54
|
+
$hints = @(Get-ToolchainHints)
|
|
55
|
+
if ($hints.Count -gt 0) { Write-Kv 'Dev tooling found:' ($hints -join ', ') }
|
|
56
|
+
Write-UiLine '' 'Gray'
|
|
57
|
+
Show-DriveTable
|
|
58
|
+
try {
|
|
59
|
+
$sys = New-Object IO.DriveInfo($Script:P.SD)
|
|
60
|
+
$pct = 100.0 * $sys.AvailableFreeSpace / $sys.TotalSize
|
|
61
|
+
if ($sys.AvailableFreeSpace -lt 10GB -or $pct -lt 10) { Write-Warn ("system drive has only {0} free ({1:N1}%) - the sections below list what can be reclaimed" -f (Format-Bytes $sys.AvailableFreeSpace), $pct) }
|
|
62
|
+
} catch { $null = $_ }
|
|
63
|
+
Write-UiLine '' 'Gray'
|
|
64
|
+
$h = Get-HiberfilInfo
|
|
65
|
+
if ($h.Bytes -gt 0) { Write-Kv 'hiberfil.sys:' ("{0} (hibernation {1}) - section 15 can shrink or remove it (admin)" -f (Format-Bytes $h.Bytes), $h.State) } else { Write-Kv 'hiberfil.sys:' 'absent (hibernation off)' }
|
|
66
|
+
try {
|
|
67
|
+
foreach ($pf in (Get-CimInstance Win32_PageFileUsage -ErrorAction Stop)) { Write-Kv 'pagefile:' ("{0} {1} allocated" -f $pf.Name, (Format-Bytes ($pf.AllocatedBaseSize * 1MB))) }
|
|
68
|
+
} catch { $null = $_ }
|
|
69
|
+
foreach ($img in (Get-DiskImageFiles)) { Write-Kv 'disk image:' ("{0} {1} (section 20 compacts it, admin)" -f $img.FullName, (Format-Bytes $img.Length)) }
|
|
70
|
+
if (Test-CommandPresent 'wsl.exe') {
|
|
71
|
+
try {
|
|
72
|
+
$raw = & wsl.exe --list --verbose 2>$null
|
|
73
|
+
$txt = (($raw | ForEach-Object { [string]$_ }) -join "`n") -replace "`0", ''
|
|
74
|
+
$lines = @($txt -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ -and $_ -notmatch '^NAME' })
|
|
75
|
+
if ($lines.Count -gt 0) { Write-Kv 'WSL distros:' (($lines | ForEach-Object { ($_ -replace '\s+', ' ') }) -join ' | ') }
|
|
76
|
+
} catch { $null = $_ }
|
|
77
|
+
}
|
|
78
|
+
Write-UiLine '' 'Gray'
|
|
79
|
+
try { $n = @(Get-CimInstance Win32_StartupCommand -ErrorAction Stop).Count; Write-Kv 'Startup items:' "$n (section 25 lists them all; change them in Task Manager > Startup - this tool never does)" } catch { $null = $_ }
|
|
80
|
+
try {
|
|
81
|
+
$ss = (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy' -ErrorAction Stop).'01'
|
|
82
|
+
$ssText = 'off'
|
|
83
|
+
if ($ss -eq 1) { $ssText = 'on' }
|
|
84
|
+
Write-Kv 'Storage Sense:' $ssText
|
|
85
|
+
} catch { $null = $_ }
|
|
86
|
+
try {
|
|
87
|
+
$la = (& fsutil.exe behavior query disablelastaccess 2>$null) -join ' '
|
|
88
|
+
if ($la -match '=\s*(\d)') {
|
|
89
|
+
$v = [int]$Matches[1]
|
|
90
|
+
$laText = 'disabled - idle age uses write/creation times (keeps more)'
|
|
91
|
+
if ($v -eq 1 -or $v -eq 3) { $laText = 'enabled - last-access times are reliable' }
|
|
92
|
+
Write-Kv 'Last-access tracking:' $laText
|
|
93
|
+
}
|
|
94
|
+
} catch { $null = $_ }
|
|
95
|
+
$blocking = @(Get-BlockingApps)
|
|
96
|
+
if ($blocking.Count -gt 0) {
|
|
97
|
+
Write-UiLine '' 'Gray'
|
|
98
|
+
Write-Warn ("running now, their caches will be skipped until closed: " + ($blocking -join ', '))
|
|
99
|
+
}
|
|
100
|
+
Add-Freed 0
|
|
101
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# installed_programs.ps1 - section 24: installed programs nothing has modified for N+ days. Report only.
|
|
2
|
+
#
|
|
3
|
+
# It NEVER runs an uninstaller, in any mode. Windows keeps no reliable "last launched" record, so the number
|
|
4
|
+
# reported is "not modified", derived from the files under InstallLocation - never described as "unused".
|
|
5
|
+
|
|
6
|
+
function Get-WingetIdMap {
|
|
7
|
+
<# .SYNOPSIS One winget call, parsed once: normalised program name -> package id. Empty when winget is absent. #>
|
|
8
|
+
$map = @{}
|
|
9
|
+
if (-not (Test-CommandPresent 'winget')) { return $map }
|
|
10
|
+
$lines = @()
|
|
11
|
+
try { $lines = @(& winget list --disable-interactivity 2>$null) } catch { return $map }
|
|
12
|
+
foreach ($line in $lines) {
|
|
13
|
+
$text = [string]$line
|
|
14
|
+
# "Name Id Version Source" with runs of spaces between columns; ids never contain a space.
|
|
15
|
+
if ($text -notmatch '^(.+?)\s\s+([^\s]+)\s\s+') { continue }
|
|
16
|
+
$name = ConvertTo-MatchToken $Matches[1]
|
|
17
|
+
$id = $Matches[2]
|
|
18
|
+
if ($name.Length -lt 3 -or $id -eq 'Id') { continue }
|
|
19
|
+
if (-not $map.ContainsKey($name)) { $map[$name] = $id }
|
|
20
|
+
}
|
|
21
|
+
return $map
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Get-InstallLocationIdleDays {
|
|
25
|
+
<# .SYNOPSIS Days since the newest LAST-WRITE at depth <= 2 under an install folder, or -1 when unknowable.
|
|
26
|
+
Deliberately NOT Get-NewestTimestampUtc, which the cleanup sections use: that takes the newest of write,
|
|
27
|
+
access and creation, and last-access is live on this machine - measured 2026-09-04, every install folder
|
|
28
|
+
read as 0 days idle that way (Git, Gpg4win, RustDesk, Malwarebytes all 0d) while last-write gave 120d,
|
|
29
|
+
203d, 163d and 148d. This section asks "not modified", so last-write is the matching question. #>
|
|
30
|
+
param([string] $Location, [int] $MaxEntries = 4000)
|
|
31
|
+
if ([string]::IsNullOrWhiteSpace($Location)) { return -1 }
|
|
32
|
+
$root = Get-FullPath ($Location.Trim().Trim('"').TrimEnd('\'))
|
|
33
|
+
if (-not $root -or -not (Test-DirPresent $root)) { return -1 }
|
|
34
|
+
$newest = [datetime]::MinValue
|
|
35
|
+
$seen = 0
|
|
36
|
+
$stack = New-Object System.Collections.Generic.Stack[object]
|
|
37
|
+
$stack.Push(@($root, 0))
|
|
38
|
+
while ($stack.Count -gt 0 -and $seen -lt $MaxEntries) {
|
|
39
|
+
$item = $stack.Pop()
|
|
40
|
+
foreach ($e in (Get-ChildEntries ([string]$item[0]))) {
|
|
41
|
+
$seen++
|
|
42
|
+
if (Test-ReparsePoint $e) { continue }
|
|
43
|
+
if ($e -is [IO.DirectoryInfo]) {
|
|
44
|
+
if ([int]$item[1] -lt 2) { $stack.Push(@((Remove-LongPrefix $e.FullName), [int]$item[1] + 1)) }
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
if ($e.LastWriteTimeUtc -gt $newest) { $newest = $e.LastWriteTimeUtc }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if ($newest -eq [datetime]::MinValue) { return -1 }
|
|
51
|
+
return [int][math]::Floor(([datetime]::UtcNow - $newest).TotalDays)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function Get-ProgramRemovalHint {
|
|
55
|
+
<# .SYNOPSIS The command that removes a program: winget when it knows it, otherwise its own UninstallString. #>
|
|
56
|
+
param([pscustomobject] $Row, [hashtable] $WingetMap)
|
|
57
|
+
$key = ConvertTo-MatchToken $Row.DisplayName
|
|
58
|
+
if ($WingetMap.ContainsKey($key)) { return "winget uninstall --id $($WingetMap[$key])" }
|
|
59
|
+
if ($Row.UninstallString) { return $Row.UninstallString }
|
|
60
|
+
return '(no uninstall command recorded - remove it from Settings > Apps)'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function Get-Targets24 {
|
|
64
|
+
<# .SYNOPSIS Informational only. Section 24 declares nothing deletable: Program Files is protected. #>
|
|
65
|
+
return @((New-Target 24 'Installed programs (registry)' 'HKLM + HKCU Uninstall hives' -Kind cmd -Note 'report only; this section never runs an uninstaller'))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Invoke-Section24 {
|
|
69
|
+
$ws = $Script:WS
|
|
70
|
+
Write-SectionIntro @(
|
|
71
|
+
'Programs whose files nothing has modified for a long time, largest first, with the command that removes',
|
|
72
|
+
'each one. Windows keeps no reliable record of when a program last RAN, so this is "not modified", not',
|
|
73
|
+
'"not used" - check the list before acting. This section never runs an uninstaller.'
|
|
74
|
+
)
|
|
75
|
+
$rows = @(Get-InstalledProgramRows | Where-Object { $_.SystemComponent -ne 1 })
|
|
76
|
+
if ($rows.Count -eq 0) { Write-Warn 'no uninstall entries could be read'; return }
|
|
77
|
+
Write-Note "$($rows.Count) installed program(s) found; measuring the ones with an install folder"
|
|
78
|
+
$winget = Get-WingetIdMap
|
|
79
|
+
$scored = @()
|
|
80
|
+
foreach ($r in $rows) {
|
|
81
|
+
$idle = Get-InstallLocationIdleDays -Location $r.InstallLocation
|
|
82
|
+
if ($idle -lt $ws.Days) { continue }
|
|
83
|
+
$scored += [pscustomobject]@{ Row = $r; Idle = $idle; Bytes = ([long]$r.EstimatedSizeKb * 1024) }
|
|
84
|
+
}
|
|
85
|
+
$lines = @("installed programs not modified for $($ws.Days)+ days - $(Get-Date -Format 'yyyy-MM-dd HH:mm')", '')
|
|
86
|
+
if ($scored.Count -eq 0) {
|
|
87
|
+
Write-Info "no installed program has been untouched for $($ws.Days)+ days"
|
|
88
|
+
} else {
|
|
89
|
+
Write-UiLine (" {0,-44} {1,-14} {2,10} {3,6} {4}" -f 'PROGRAM', 'VERSION', 'SIZE', 'IDLE', 'PUBLISHER') 'White'
|
|
90
|
+
foreach ($s in ($scored | Sort-Object Bytes -Descending)) {
|
|
91
|
+
$size = 'unknown'
|
|
92
|
+
if ($s.Bytes -gt 0) { $size = Format-Bytes $s.Bytes }
|
|
93
|
+
$line = " {0,-44} {1,-14} {2,10} {3,5}d {4}" -f $s.Row.DisplayName, $s.Row.DisplayVersion, $size, $s.Idle, $s.Row.Publisher
|
|
94
|
+
Write-UiLine $line 'Gray'
|
|
95
|
+
$lines += $line.Trim()
|
|
96
|
+
$lines += (' remove with: ' + (Get-ProgramRemovalHint -Row $s.Row -WingetMap $winget))
|
|
97
|
+
}
|
|
98
|
+
Write-Section 'Remove one yourself with'
|
|
99
|
+
foreach ($s in ($scored | Sort-Object Bytes -Descending | Select-Object -First 10)) {
|
|
100
|
+
Write-Plain (' ' + (Get-ProgramRemovalHint -Row $s.Row -WingetMap $winget))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
Write-Section 'Store apps (not system packages)'
|
|
104
|
+
$appx = @()
|
|
105
|
+
try { $appx = @(Get-AppxPackage -ErrorAction SilentlyContinue | Where-Object { -not $_.IsFramework -and $_.SignatureKind -ne 'System' }) } catch { $appx = @() }
|
|
106
|
+
if ($appx.Count -eq 0) { Write-Info 'none found' } else {
|
|
107
|
+
foreach ($a in ($appx | Sort-Object Name)) {
|
|
108
|
+
Write-UiLine (" {0,-52} {1}" -f $a.Name, $a.Version) 'Gray'
|
|
109
|
+
$lines += ("store {0} {1}" -f $a.Name, $a.Version)
|
|
110
|
+
$lines += (' remove with: Remove-AppxPackage -Package ' + $a.PackageFullName)
|
|
111
|
+
}
|
|
112
|
+
Write-Note 'remove one with: Remove-AppxPackage -Package <PackageFullName>'
|
|
113
|
+
}
|
|
114
|
+
if (-not $ws.NoReport) {
|
|
115
|
+
$out = Join-Path $ws.ReportsDir ('installed-programs-' + $ws.Stamp + '.txt')
|
|
116
|
+
try { [IO.File]::WriteAllLines($out, $lines); Write-Note "list saved: $out" } catch { $null = $_ }
|
|
117
|
+
}
|
|
118
|
+
}
|