wmi-query

Get CPU usage for each core using the windows command line

╄→гoц情女王★ 提交于 2020-01-04 10:06:33
问题 Is it possible to print the current CPU usage for each core in the system? This is what I have so far using powershell: Get-WmiObject -Query "select Name, PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor" 回答1: It can be be done using the following powershell command: (Get-WmiObject -Query "select Name, PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor") | foreach-object { write-host "$($_.Name): $($_.PercentProcessorTime)" }; Also you could create a file

Access Denied - get-wmiobject win32_service (Powershell)

匆匆过客 提交于 2019-12-25 09:44:23
问题 11/13/2013 11:35:37 TRCW1 using local computer 11/13/2013 11:35:37 TRCE1 System.Management.ManagementException: Access denied at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext() at Microsoft.PowerShell.Commands.GetWmiObjectCommand.BeginProcessing() Code (inside a loop of server names): $error.clear() #clear any prior errors, otherwise same error may repeat over-and-over

SQL Server Alert using WMI Event ERROR

风格不统一 提交于 2019-12-25 06:44:27
问题 I want to execute a job when ever a file is dropped into a particular folder. I found some articles that showed me how I can do it on SQL Server. I created a alert type: WMI Event Alert For the name space its the SQL instance which comes automatically as \\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER On the Query section - I wrote the below query , SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'CIM_DataFile' AND TargetInstance.Name = ‘c:\\TestFolder\’ ` The

Detect SD card using WMI Query

隐身守侯 提交于 2019-12-25 04:50:49
问题 I have a query that return USB devices attached in: SelectQuery sq = new SelectQuery("select DeviceID, Model from Win32_DiskDrive where InterfaceType='USB'"); ManagementObjectCollection MOC = new ManagementObjectSearcher(sq).Get(); But it doesn't retrieve the SD card information. How do i can retrieve this SD cards information using WMI queries? 回答1: i modified "select DeviceID, Model from Win32_DiskDrive where InterfaceType='USB'" removing "where InterfaceType='USB" 来源: https://stackoverflow

Querying process by CommandLine

耗尽温柔 提交于 2019-12-25 03:07:15
问题 I'm trying to do the following query in WMI: SELECT ProcessID from Win32_Process where CommandLine='C:\Windows\system32\calc.exe' But I got an "Invalid query" error. I also tried with: SELECT ProcessID from Win32_Process where CommandLine='C:\\Windows\\system32\\calc.exe' And still get the same error, also I tried to change the single quotes to double quotes but it didn't work. Does anybody know if its possible to do that query? 回答1: Yes and No. Depends on how calc.exe is spawned. For

Querying process by CommandLine

左心房为你撑大大i 提交于 2019-12-25 03:07:00
问题 I'm trying to do the following query in WMI: SELECT ProcessID from Win32_Process where CommandLine='C:\Windows\system32\calc.exe' But I got an "Invalid query" error. I also tried with: SELECT ProcessID from Win32_Process where CommandLine='C:\\Windows\\system32\\calc.exe' And still get the same error, also I tried to change the single quotes to double quotes but it didn't work. Does anybody know if its possible to do that query? 回答1: Yes and No. Depends on how calc.exe is spawned. For

How to query Folder Size in remote computer through WMI and C#

穿精又带淫゛_ 提交于 2019-12-24 04:15:08
问题 How to query Folder Size in remote computer through WMI and C#. I need to find the each User's folder size in C:\Users in remote System through WMI. I tried Win32_Directory , CMI_DataFile but not able to find the desired answer. Please help!! 回答1: To get the size of a folder using the WMI, you must iterate over the files using the CIM_DataFile class and then get the size of each file from the FileSize property. Try this sample (this code is not recursive, I leave such task for you). using

How to get WMI object from a WMI object reference?

痴心易碎 提交于 2019-12-23 04:41:19
问题 Similar to this question except that no answer was given with regards to the main question of getting an object from reference. For example: PS C:\Users\admin> Get-WmiObject -Namespace $namespace -Class $class ... IsActive : 1 oA: \\.\ROOT\abc\abc\ABC:abc.xyz="tst2" oB : \\.\ROOT\abc\abc\ABC:abc.xyz="tst3" PSComputerName : admin-test2 oA and oB are references and therefore come up as strings in powershell. Is there a way I can get the object they represent using WMI query in powershell? 回答1:

List all physical printers using WMI query in Inno Setup

為{幸葍}努か 提交于 2019-12-22 00:45:32
问题 I'm trying to get the list of physical printer's name, that are connected to Windows, based on an answer from Query available RAM in Inno Setup. But just get: "Send To OneNote 16". Here is my query: Query := 'SELECT Name FROM Win32_Printer'; Printer := WbemQuery(WbemServices, Query); if not VarIsNull(Printer) then begin Log(Format('Printers=%s', [Printer.Name])); end; 回答1: You have to iterate the result set: var Query: string; WbemLocator, WbemServices, WbemObjectSet: Variant; Printer:

WMI Process Watching uses too much CPU! Any better method?

萝らか妹 提交于 2019-12-19 04:14:33
问题 I need to watch when certain processes are started or stopped on a Windows machine. I'm currently tapped into the WMI system and querying it every 5 seconds, but this causes a CPU spike every 5 seconds because WMI is WMI. Is there a better way of doing this? I could just make a list of running processes and attach an Exited event to them through the System.Diagnostics Namespace, but there is no Event Handler for creation. 回答1: This is not exactly how you'd do it in the real world but should