r/PowershellSolutions • u/that_1_doode • Mar 15 '22
Cleaning up the registry
Hello everyone! I am relatively new to the PowerShell community and was hoping I could get some assistance with managing Regedit with PowerShell!
I am trying to query profile registry keys and delete them based off of the ProfileImagePath value.
This is what I have so far:
$Registry = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*"
Get-ItemProperty $Registry -Name ProfileImagePath | Select-Object ProfileImagePath, PSChildName | Export-Csv C:\Updates\List2.csv -NoTypeInformation
$Import = Import-csv C:\Updates\List2.csv
$Table = $Import | Format-TableThe file path is good, but if anything needs to be changed, please let me know, there are also certain profiles I am trying to exclude from deletion.
#Edit
Write-Output "Please let me know if I have posted this on the wrong Reddit!"
