I needed to register serveral OCX files and wanted to be able to check if the result was succesfull, so my automation script could continue.
I found out that HKEY_CLASSES_ROOT didn’t exist as a PS drive, thus it needed to be created (thank you Lior Elia for your blog post on this subject). Normally this gives some output, which I didn’t need, so I added | Out-Null to the line of creating the PSDrive.
Then I needed a way to check if the item was succesfully registered. It appeared that I needed to search the registry for a certain value, because the registered item is added to a subkey of HKEY_CLASSES_ROOT\TypeLib.
I found this script on the Microsoft technet gallery, by Rohn Edwards, which is very usefull for this task.
So now I needed to combine this into 1 script and add my own knowledge to be able to register the OCX files (it also works for DLL files), and then check if they have an entry in the HKEY_CLASSES_ROOT\TypeLib registry path.
You can download my script here. Note that you need to enter the name of the OCX or DLL file manually.