Problem when working with loaded registry hive


hi all, 

i'm working on project copy registry entries hklm hive can inventoried using sccm. i've spent quite bit of time trying figure out best way this, since keys exist in hkcu branch of registry.

here i've got far:

if (test-path -path c:\users\user.dom)  {  reg load 'hklm\tempuser' c:\users\user.dom\ntuser.dat      if (test-path -literalpath "hklm:\tempuser\software\smith micro\vzam - verizon wireless\devicemdn")  {$key = (get-item -literalpath "hklm:\tempuser\software\smith micro\vzam - verizon wireless\devicemdn")   $meid = (get-item -path $key).property   $number = (get-itemproperty -path $key -name $meid).$meid  }    write-host "meid $meid"   write-host "number $number"      [gc]::collect()    reg unload 'hklm\tempuser'    new-item -path "hklm:\software\" -name "inventory"  new-itemproperty -path "hklm:\software\inventory" -name "meid" -value $meid -propertytype "string" -force  new-itemproperty -path "hklm:\software\inventory" -name "phone number" -value $number -propertytype "string" -force    }
problem works fine if don't use $key variable , manually enter path on each line. once try use $key variable error message path doesn't exist. can't seem figure out why happening.

hi matt,

please try replace

$key = (get-item -literalpath "hklm:\tempuser\software\smith micro\vzam - verizon wireless\devicemdn") in script posted

$key = "hklm:\tempuser\software\smith micro\vzam - verizon wireless\devicemdn".

in addition, please note "this fail if there more 1 value present" mike mentioned above.

if have feedback on our support, please click here.

best regards,

anna

technet community support


we trying better understand customer views on social support experience, participation in interview project appreciated if have time.
helping make community forums great place.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client