Hi,
As part of the MDT build process we set a couple of Registry Keys to tell us the status of the build (I.e in build or finished build) For logging purposes I retrieve the value of 2 keys from the registry, however when running the following command I get an exception:
1 |
Get-ItemProperty -Path HKLM:\Software\MyKey\SubKey -Name 'Value' -ErrorAction stop |
The error I receive is:
Property XXXĀ does not exist at path XXX
Where the first XXX is the -Name argument we specified I.e the registry entry, and the second XXX is the path to the registry key e.g HKLM:\Software\MyKey\Subkey.
Now, if I manually check the path that was thrown in the exception using regedit, I can see it does exist, its not a typo, and I’m not sure why it does this, seemingly only in the Task Sequence and not outside of it. The Get-ItemProperty cmdlet works fine within Windows and returns the values as expected.
Anyway to work around this issue I’ve used a different method of querying the Registry by using a Wscript.Shell object:
1 |
$MyRegValue = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\MyKey\SubKey\Value") |
Let me know if you’ve seen this issue, or know why it occurs!
John.