I have the script where it captures blank profile paths in the profile list. I am not sure how to call the array and delete the whole key. It is saying path is not found as it is trying to run it from c:\windows\system32
how do i get it to go through the different paths it might have ? Right now I am just testing by blanking out one profile path
$Profiles = get-childitem “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”
$ProfileData = @()
foreach($Profile in $Profiles){
$ThisProfileInfo = $null$ThisProfileInfo = @{Name=$Profile.Name; ProfilePath=$Profile.GetValue("ProfileImagePath")} if (!($ThisProfileInfo.ProfilePath)) { $ProfileData += $ThisProfileInfo
}
}
$ProfileData
ForEach-Object{Remove-Item -Path ($Object.name)}