Compare commits
2 Commits
2e093f6856
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b45ccef74 | |||
| b67f1c8c9a |
32
windows/appchk.ps1
Normal file
32
windows/appchk.ps1
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Define the registry paths for 32-bit and 64-bit applications
|
||||||
|
$registryPaths = @(
|
||||||
|
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall",
|
||||||
|
"HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Initialize an array to store application information
|
||||||
|
$applications = @()
|
||||||
|
|
||||||
|
# Loop through each registry path
|
||||||
|
foreach ($registryPath in $registryPaths) {
|
||||||
|
# Get the registry keys for each application
|
||||||
|
$keys = Get-ChildItem -Path $registryPath
|
||||||
|
foreach ($key in $keys) {
|
||||||
|
# Get the application properties
|
||||||
|
$app = Get-ItemProperty -Path $key.PSPath
|
||||||
|
# Add the application information to the array
|
||||||
|
$applications += [PSCustomObject]@{
|
||||||
|
Name = $app.DisplayName
|
||||||
|
Version = $app.DisplayVersion
|
||||||
|
Publisher = $app.Publisher
|
||||||
|
InstallDate = $app.InstallDate
|
||||||
|
Size = $app.EstimatedSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Filter out applications with no name
|
||||||
|
$applications = $applications | Where-Object { $_.Name -ne $null }
|
||||||
|
|
||||||
|
# Display the applications
|
||||||
|
$applications | Select-Object Name, Version, Publisher, InstallDate, Size | Format-Table -AutoSize
|
||||||
@ -189,7 +189,6 @@ function Get-Duplicates {
|
|||||||
|
|
||||||
if ($dup_files.Count -gt 1) {
|
if ($dup_files.Count -gt 1) {
|
||||||
$dups_hash[$entry.key] = $dup_files | Sort-Object -Property Creation -Descending
|
$dups_hash[$entry.key] = $dup_files | Sort-Object -Property Creation -Descending
|
||||||
#$dup_files = $dups_hash[$entry.key]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dups_hash
|
$dups_hash
|
||||||
@ -214,14 +213,18 @@ function Show-Duplicates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "Found duplicate $($num_dups): $($entry.Key)"
|
Write-Output "Found duplicate $(Format-NumberWithCommas $num_dups): $($entry.Key)"
|
||||||
|
|
||||||
for ($i = 0; $i -lt $dup_files.Count; $i++) {
|
for ($i = 0; $i -lt $dup_files.Count; $i++) {
|
||||||
|
# only count disk space of removals
|
||||||
|
if ($i -gt 0) {
|
||||||
$total_dup_size += $dup_files[$i].Size
|
$total_dup_size += $dup_files[$i].Size
|
||||||
|
}
|
||||||
Write-Output "$($hash_num): $($dup_files[$i].ToString())"
|
Write-Output "$($hash_num): $($dup_files[$i].ToString())"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "Found $num_dups duplicate file hashes."
|
Write-Output "Found $(Format-NumberWithCommas $num_dups) duplicate file hashes."
|
||||||
ShowSizes "Duplicate Files Size" $total_dup_size
|
ShowSizes "Duplicate Files Size" $total_dup_size
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +285,7 @@ function DeleteDuplicateFile {
|
|||||||
Write-Output "Deleting File: $($File.Name) $(Format-NumberWithCommas $File.fileSizeInKB) KB"
|
Write-Output "Deleting File: $($File.Name) $(Format-NumberWithCommas $File.fileSizeInKB) KB"
|
||||||
BackupDuplicateFile -file $File -backupDirectory $backup_dir
|
BackupDuplicateFile -file $File -backupDirectory $backup_dir
|
||||||
# Force delete a read-only or protected file
|
# Force delete a read-only or protected file
|
||||||
Write-Output " ... would deleting: $($File.FullName)"
|
Write-Output " ... deleting: $($File.FullName)"
|
||||||
Remove-Item -Path $File.FullName -Force
|
Remove-Item -Path $File.FullName -Force
|
||||||
Write-Output " - removed from: $($File.Directory)"
|
Write-Output " - removed from: $($File.Directory)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user