Need to read the registry value from HKEY_USER.

Hi

I am new to powershell, so if you see any simple mistake dont get mad 

I have to run a query against a list of computers to get the registry value of HKEY_USER

#the file contains the Computer Name and SID

$name = Get-Content -Path "C:\Temp\Powershell Scripts\ComputerList.csv"

$ComputerName=$name.split(",")[0]
$SID=$name.split(",")[1]
$SID.Length

## so far I am able to get the ComputerName and the SID and tested it with echo

#created a NEW PSDRIVE for HKU

New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS

### List all the PS drives - to verify it and it worked
Get-PSDrive

##Now I want to query a REG HIVE with the SID I read from the file

Get-ItemProperty -Path 'HKU\$SID\Software\.............'|select <Key>  -> This does not work

Get-ItemProperty -Path 'HKU:\S-1-5-21-329068152-12144XXXXX\Software\Select <KEY> -> This works

When i try to pass the $SID, it says it cannot find the path. However When i type it in manually i am able to get into the hive. Any Advice?

Parents
No Data
Reply Children
No Data