"Not Found" error occurred while trying to fetch "NumberOfEnabledCore" value from "Win32_Processor" class of WMI - wmi

I am trying to extract "NumberOfEnabledCore" value from "Win32_Processor" class of WMI. When I have executed "Get-WmiObject -class Win32_Processor | Select *" in Powershell in Windows 8.1, I am getting error as "Not Found".
However, when I ran the same script in Windows 10, I am getting value for "NumberOfEnabledCore".
Can someone please assist on this WMI script behavior?
Thanks.
Ref: https://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx

Related

Why is C++ WMI Not Fetching Data? Error: 0xC0000005

I'm quite new to WMI, I'm following this guide here.
So I pasted that code in the guide and ran it without any issues using the provided query. But when I changed the query to SELECT State FROM Win32_Service I get no data, just the error code 0xC0000005, which I believe is a permissions error?
That same query above works just fine in the PowerShell using the following command:
Get-WmiObject -Query "select State from Win32_Service"
What I've tried
winrm quickconfig
So what gives? Why am I having trouble querying the WMI from my C++ code?
EDIT: I found the line that's causing the crash. I'm not sure why it's crashing though.
wcout << vtProp.bstrVal << endl;
I missed this line of code
hr = pclsObj->Get(L"State", 0, &vtProp, 0, 0);
Change the first argument to the property whose value you'd like to retrieve.

How to assign Static IP based on MAC Address using powershell/script in Windows?

I would like to write up a script to assign static IP based on mac addresses, as I am having trouble with "USB to ethernet" adapters lose it's IP settings and assign to different interface Names.
I am running on windows 10 environment and have found a wmi script online that I think might work.
Code I am using:
wmic nicconfig where macaddress="0F:98:90:D6:42:92" call EnableStatic ("192.168.1.1"), ("255.255.255.0")
Error output:
"Invalid format.
Hint: = [, ]."
Thanks
Something like this
$netAdapter = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.MACAddress -eq '0F:98:90:D6:42:92'}
$netAdapter.EnableStatic("192.168.1.1", "255.255.255.0")

How can we get a CPU temperature through WMI?

I installed WMI code creator from here, and I'm wondering how we can use it to get the CPU temperature.
The application gives many options (as shown below), but I am not sure where I have to click to get the CPU temperature.
I went to the description of WMI code creator and saw the following:
The WMI Code Creator tool allows you to generate VBScript, C#, and VB
.NET code that uses WMI to complete a management task such as querying
for management data, executing a method from a WMI class, or receiving
event notifications using WMI.
Namespace: root\wmi
Path: MSAcpi_ThermalZoneTemperature
To run this (using wmic) from the Windows command line (cmd.exe) the command would be:
wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CriticalTripPoint, CurrentTemperature
Attention: the results are in Kelvin * 10, so you need to divide the result by 10, and then subtract 273.15 to get °Celsius.
More information:
WUtils.com : MSAcpi_ThermalZoneTemperature Properties
Wikipedia : Kelvin (and conversion to/from °C and °F)
Wikipedia : Windows Management Instrumentation (WMI)
MSDN : WMI Command Line (WMIC)
Tech Advisor : What's the Best CPU Temperature?
SpeedFan : Fan & Temperature control utility (Freeware)
systeminformation: systeminformation npm package (for nodejs)
For those looking for a PowerShell solution:
Get-CimInstance -Namespace root/wmi -ClassName MsAcpi_ThermalZoneTemperature -Filter "Active='True' and CurrentTemperature<>2732" -Property InstanceName, CurrentTemperature |
Select-Object InstanceName, #{n='CurrentTemperatureC';e={'{0:n0} C' -f (($_.CurrentTemperature - 2732) / 10.0)}}
The WMI/CIM filter here is only looking for active sensors that aren't returning 0 C as the temperature. My system returns several sensors with that value and I assume they're just disabled or otherwise non-functional. The InstanceName property should give you an approximate idea where the sensor is located. In my systems, even though the property is supposed to be in tenths of degrees K, it's always reporting in whole degree values and it appears to round the -273.15 C absolute zero to -273.2. Other systems or sensors may vary.
Note that you must be an administrator to query the MsAcpi_ThermalZoneTemperature class.
My HP laptop has HP specific WMI objects that contains temperature in Celcius units and fan RPM speed objects.
Running this WMIC command in administrator mode will retrieve them:
wmic /NAMESPACE:\\root\HP\InstrumentedBIOS path HPBIOS_BIOSNumericSensor get Name,CurrentReading
Adding for syntax for looping it every 5 seconds:
FOR /L %G IN (1,1,100) DO wmic /NAMESPACE:\\root\HP\InstrumentedBIOS path HPBIOS_BIOSNumericSensor get Name,CurrentReading && PING localhost -l 0 -n 5 >NUL
On my Dell-Laptop I could get the CPU-Temperature in Celsius like this:
$data = Get-WMIObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2"
#($data)[0].HighPrecisionTemperature

"Key Not Found" error in LevelDB

I'm using levelDb in my program.
Now sometimes (I can't say whe exactly and in what frequency) When I'm using Db->Get()
I'm getting a "key not found" error despite the key exists.
When I'm using the iterator,
I'm able to retrieve the key.
I'm using Linux OS Centos 6.6 , C++ Interface
Any explanation or a lead to why I may be getting this error would be appreciated.

Task Scheduler 1.0: What does this error mean

I am working with the windows Task Scheduler 1.0 in win32 c++ & I am attempting to create & save a new task. Everything goes fine until I go to save the task by using the following function:
IPersistFile :: Save( NULL, TRUE );
The error that is returned is 0x8007052e
I have search & searched msdn but I cannot find a defintion for this error. Do you know that the HRESULT error with the value 0x8007052e means?
Some other info that might be important. I am using Windows 7, using a admin user & attempting to schedule a Daily task/trigger.
Using Visual Studios Error Lookup tool I find that it means "Logon failure: unknown user name or bad password. "
In fact, just Googling for that error code returns exactly the same information.
The HRESULT code 0x8007052e is very easy to decode. It consist from three parts
8xxxxxxx - means failure (error)
x007xxxx - means the facility 7
xxxx052e - meane the error code 0x52e=1326
If you open the WinError.h file you will easy find that FACILITY_WIN32 is 7.
So you have just a standard Win32 error with the code 0x52e=1326. If you search in WinError.h for 1326 you will find ERROR_LOGON_FAILURE with the description
Logon failure: unknown user name or
bad password.