As part of an Oracle DB server upgrade, I am trying to query all PCs that may not have a particular version of the Oracle client installed (Oracle makes this process as hard as possible to automate, unless you script SQL+ queries, which is not an option). I have fuddled around for two weeks trying to put something together but I just can’t seem to get the output that I want.
What I really need the script to do is:
- Query HKLM\Software\Oracle and recurse through the hive and find all instances of the “ORACLE_HOME” reg key, and then pull the path variable from that key
- Test the path/s found in step one for the oci.dll file
- If oci.dll exists, pull the file version
- Export to a txt or csv that includes host name and oci.dll version info
I have used/tested variations of the following reg query to pull path info:
reg query \$HOST_NAME\HKLM\Software\Oracle /s | Select-String “ORACLE_HOME” | %{$_.Line.Split(" ")} | Select-String -Pattern c:
I also have used variations of get-itemproperty to pull ‘FileVersion’ from the ‘VersionInfo’ script property on oci.dll, but can’t get the two script chunks to work together.
One of the main issues I have run into is parsing out the path from the reg keys; I can only seem to dump the entire line which I end up having to split out the path using ‘-pattern’.
End game, this is going to be executed on ~2000 PCs and I wanted to try to avoid skipping the reg query piece and doing a recursive search against c:\oracle, c:\ora, C:\app & c:\orant which are the 4 most common paths where the oci.dll file resides (this has recently become an option since I can’t seem to get the reg query piece to work how I want it).
Any help would be greatly appreciated!