# Powershell array delete Name path

**URL:** <https://forums.powershell.org/t/powershell-array-delete-name-path/19082>\
**Category:** PowerShell Help\
**Created:** [April 13, 2022, 8:31pm UTC](https://forums.powershell.org/t/powershell-array-delete-name-path/19082 "2022-04-13T20:31:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmoore5553](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@mmoore5553](https://forums.powershell.org/u/mmoore5553)\
**Post date:** [April 13, 2022, 8:31pm UTC](https://forums.powershell.org/t/powershell-array-delete-name-path/19082/1 "2022-04-13T20:31:57Z")

</div>

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)}

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 13, 2022, 9:36pm UTC](https://forums.powershell.org/t/powershell-array-delete-name-path/19082/2 "2022-04-13T21:36:59Z")

</div>

mmoore5553,  
Welcome to the forum. 👋🏽

I’m not exactly sure what your actual issue is but your code could be simplified to this I think:

```auto
$ProfileList = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'

$ProfileData = 
foreach ($Profile in $ProfileList) {
    [PSCustomObject]@{
        Name = $Profile.Name
        ProfileImagePath = $Profile.GetValue('ProfileImagePath')
    }
}
$ProfileData

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:18pm UTC](https://forums.powershell.org/t/powershell-array-delete-name-path/19082/3 "2024-05-16T20:18:05Z")

</div>


