How can I query Windows registry keys from Linux? - linux

I am developing a Linux auditing application that, among other things, has to retrieve installed software and licenses from a Windows machine. The application MUST be agent-free.
wmi-client actually does implement what I want, I tryed to query applications and it worked just fine:
# LAUNCHING WMIC PLUGIN
my $cmd = "wmic -U ".$username."%".$password." //".$hostname." \"select Name, Version from Win32_Product\"";
my $output = `$cmd`;
print "INSTALLED SOFTWARE:\n";
print "$output";
Now my question is, how can I retrieve the Product Key for certain applications? I know that sometimes they are stored in the Registry Key, can I query them through WMI?
EDIT: Just found that on a website:
http://social.technet.microsoft.com/Forums/en/winserverGP/thread/5cd1b80a-2f90-4d46-bf65-dba52dcf0c56
WQL queries are based on certain WMI classes which offer a set of properties.
The WMI registry actions instead are based on the "StdRegProv" in the "Default" namespace and certain methods have to be called to get a result. That means a registry query bases WMI filter is not possible.
So it looks like WQL cannot interrogate Registry Keys, what can I do then? Any ideas?

I do not have any experience using it on non-Windows clients, but there is DBD::WMI.

Related

installation OP5 Monitor / Nagios:

In the case of implementation of the monitoring database oracle control method requires a standard application username and password explicitly. How to bypass the need to enter in clear text password to log into the database oracle, which is visible in the screen OP5 Monitor and Nagios configuration file system.?
There are several possibilities.
Generic solution
Use the $USERnn$ macros, which are defined in resources.cfg. More information on how to use this feature: https://kb.op5.com/display/DOC/Macros#Macros-Custommacros
The USER macros are not visible in the graphical user interface, but can be read by anyone having access to the resources.cfg configuration file.
For Naemon documentation on user macros see http://www.naemon.org/documentation/usersguide/macrolist.html#user
Specific solution for the check_oracle plugin (if that is what you are using)
Specify the credentials in an auth file. From the help text for the plugin:
-f <auth-file> can be used instead of -u <username> -p <password>. If both
options are used the <auth-file> will override -u/-p. The <authfile> should
be a textfile (readable by the nrpe-user) containing two rows. File format:
username=<username>
password=<password>
Solution specific to OP5 Monitor
Use custom variables prefixed with OP5SECRET. Unfortunately, these are not very well documented, but take a look at the Standalone VMware ESXi virtualization host management pack which uses this feature.
Full disclosure: I work as Development Team Lead at OP5.

WMI Query to detect the Microsoft office architecture installed in a Windows 7 machine

I am working in SCCM,while installing SAP Bussiness object Analysis ,MS Office is one of the prerequest.I need to add a condition in Task sequence to check the version of MS office architecture before installing SAP.
I got registery path to check that "HKLM\SOFTWARE\Microsoft\Office\15.0\Outlook"
BITNESS =x64 or x86. if the machine don't have outlook this wont work.
So i need a WMI query to check the bitness or a any other registry path to check the bitness of office . please help
I wouldn't bother with a WMI query, just create a task sequence for deploying SAP and use conditions to determine if Office is installed or not. It'll be much easier in the short term.
I would do this outside of the task sequence. How I will do is:
Method 1:
- Create device collection based on the condition (I would prefer using hardware inventory data to filter)
- deploy the SAP Application/package to the 'correct' collection
Method 2:
For application type of deployment, there are 'Requirement' settings on the deployment type. What you need to do is to create a registry based Global Condition (almost clicks-and-types-and-clicks) and attach this to the SAP application deployment type.
If you are not familiar with Global Condition, below is an official document link URL which will get you started:
https://technet.microsoft.com/en-us/library/gg682048.aspx

Oracle error when executing sqlplus: "SP2-1503: Unable to initialize Oracle call interface"

I'm struggling with the following error when starting up sqlplus as my regular user - say "scott".
$ sqlplus
SP2-1503: Unable to initialize Oracle call interface
SP2-0152: ORACLE may not be functioning properly
Environment is:
Oracle 11.2.0.2
OpenSuse Linux 11.1 (64bit)
Misc other detail:
Oracle installed and running on localhost
No tnsnames issues as can run sqlplus as oracle admin user
Database up and listener started (11.2.0.2 install).
user scott in database admin group (/etc/group)
user scott references correct 11.2.0.2 installation
This is most bizarre as I can happily run sqlplus as the oracle user (say "oraadmin") and user scott is registered in the oracle admin group. Additionally, I had no such problems with my previous Oracle install (10.2.0.7). My ~scott's $ORACLE_HOME references the 11.2.0.2 installation.
Comparing my 11.2.0.2 and 10.2.0.7 environments, I've noticed several libraries (including $ORACLE_HOME/lib/libsqlplus.so) have group read-only permissions (744) so have chmod'ded these.
Other than that, my $ORACLE_HOME/lib, $ORACLE_HOME/bin, $ORACLE_HOME/oracore and $ORACLE_HOME/rdbms all seem reasonable with sensible permissons.
N.B: There's a plethora of stuff on-line but, as is often the case, there's a lot of case-specific issues and mainly around different versions of Windows. Focusing mainly on comparing my envs. Besides, as far as I can tell, this question doesn't yet exist on SO so could be useful to start collating answers by environment. I'll report back any sensible findings.
If it is Windows 7, You can right click on SQL Plus or whatever software you using, I use Crystal Reports.
so to you would have to right click and Run as Administrator.
it fixed for me.
Fixed my particular issue...
User scott's $PATH still contained the ora11.1.0.7 bin. So, on starting sqlplus, I was running the ora11.1.0.7 sqlplus client against the 11.2.0.2 server. Think there may be more to it than that (i.e. I'd probably expect that client to work with that server) but that is the hub of the problem.
In my defence, my.bashrc sets the $PATH correctly so not yet sure what preempts it with the 11.1.0.7 version. Guess the sensible rule of thumb is to add my $ORACLE_HOME/bin to the front of the $PATH to ensure mine is found first, despite what else is set by whatever other environment config, as in
export PATH=$ORACLE_HOME/bin:$PATH
Yours, a little embarrassed but hopefully will be of help again to someone.
Some of the more useful sites...
Various Windows environments:
https://forums.oracle.com/forums/thread.jspa?threadID=338426
https://www.administrator.de/Zugriff_auf_OracleDB_(10i)_per_sql_plus_von_WTS_2003_(Servicepack_2).html
http://www.orafaq.com/forum/t/100549/2/
Linux environments:
http://databaseoracle.blogspot.com/2006/11/permitting-user-on-unix-linux-to-use.html
In Windows i found the solution ---
Assign the "Create global objects" user right to the non-Administrator account.
Go to Administrative Tools, and then click Local Security Policy.
Expand Local Policies, and then click User Rights Assignment.
In the right pane, double-click Create global objects.
In the Local Security Policy Setting dialog box, click Add.
In the Select Users or Group dialog box, click the user account that you want to add, click Add, and then click OK.
Click OK.

Forced using the PSSessionOption -NoMachineProfile BUT SPFarm.Local is null

I am currently writing a Powershell module to provide functions for installing / operating SharePoint 2007.
One of my scripts checks the health of SharePoint servers farm.
So I use Remote Powershell : using New-PSSession.
In my Virtualized test farm (Windows server 2003, same domain, same admin...), the New-PSSession cmdlet failed :
After googling it, the only solution I saw was to use the NoMachineProfile option :
That solved my problem.
Now the problem :
I need to use SharePoint object : SPFarm.Local (on all servers)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[Microsoft.SharePoint.Administration.SPFarm]::Local
This code works locally (on all servers)
But when I run it remotely (using the NoMachineProfile option), SPFarm.Local is null !
I Suppose (I cannot check it) it is because SharePoint uses some registry values that are not loaded because of the NoMachineProfile option.
So :
1 - Do you think SPFarm.Local is null because of the NoMachineProfile option ?
2 - Do you know how can I solve the first problem without using the -NoMachineProfile option ?
Thx a lot !
I believe your problem is related to the PowerShell Multi-Hop (Diagram below of what a multi-hop operation is) issue Which was discussed here... PowerShell is not able to perform a multi-hop operation by default, because your credential are not being passed to the next server... Since you are trying to contact different SP servers in the farm from a remote host. I would recommend reading the following blog entry related to multi-hop scenarios and following his instructions to correct your issue.
Using CredSSP for multi-hop authentication
http://www.ravichaganti.com/blog/?p=1230
I know this diagram mentions file server but it’s the same basic principle.

Hklm/Init on Windows CE 6.0

I've been trying to make my application run at startup on windows CE 6.0, unfortunately since the device (YFAtlas4) is customized by manufacturer I'm unable to place shortcut in \Windows\Startup. (for some misterious reasons)
So now I'm trying to place path to my application in Hklm\Init registry key, and here's my problem: I's there a way to place absolute path there ? In every example that I've seen there's only application name, and my application has to be instaled in \ResidentFlash\ folder.
Did you try to put the full path there?
There should not be any problem doing so.
If you edit your registry using code, then the string you want to store is L"\\ResidentFlash\\AppName.exe". Alternatively, in case you have an ActiveSync connection with the device you can use a remote registry editor and not mess with the double backslashes.
Also, since you are using the HKLM\Init functionality - make sure your application calls SignalStarted so other programs that are dependent on it can start as well.
A fully qualified path should be supported jusy fine. Be aware that if the path has a space in it, you'll need to quote delimit it. Also, if it's a Compact Framework app, it's not as simple as just adding your app to the Init key - often that will fail. See this blog entry on getting CF apps working with the Init key.

Resources