Functions/Registry/Get-RegUsers.ps1

Function Get-RegUsers
    {
    [CmdletBinding()]
    Param()
    Process
        {
        # Get Profiles from Registry
        $ProfileReg = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\hivelist").psobject.properties | where {$_.Name -like "\Registry\User\S-1-5-21*" -and $_.Name -notlike "*_Classes"} | select Name,Value
    
        # Output Names and Sids
        Foreach ($Profile in $ProfileReg)
            {
            [pscustomobject]([ordered]@{
                Name = ($Profile.Value -split '\\')[4]
                SID = ($Profile.Name -split '\\')[-1]
                Path = $Profile.Value
                })
            }
        } 
    }