wql

How do I run the following WMI query?

How do I run the following WMI query, both programmatically to and as a one-shot deal? Can I use Visual Studio 2008, and if so what language and type of project do I setup? I'm a complete beginner at this so please provide details. Thanks! SELECT * FROM Win32_USBControllerDevice For Each as USBDevice ASSOCIATORS OF {Win32_PnPEntity.D...

Powershell WMI ROOT\MicrosoftExchangev2, and WQL where usage

(PS Version 1) PS C:\> $query = 'Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%"' PS C:\> $query Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%" PS C:\> gwmi -namespace ROOT\MicrosoftExchangev2 -query $query Get-WmiObject : Provider is not capable of the attempted operation At line:1 char:5 + gwmi <<<< -namespac...

How can I tell what WQL operators are supported on a class using powershell?

So the WQL LIKE operator isn't supported on my WMI class from this question. How do I tell ahead of time, or interactively as I write, what is/is not supported? I'd like to stick with Powershell here and avoid other solutions like wmic. ...

List of WMIEvent classes

Recently I have been learning about WMI and WQL. I found out the list of Win32 classes (from MSDN) that I can query for but I am not able to find out the list of event classes (should be the subset of the list of Win32 classes isn't it ?) Does any one have a list or some kind of cheat sheet for this? I am jsut asking this out of curiosit...

How can I improve WMI performance in .NET?

I've inherited code that makes numerous remote WMI calls. When I repeatedly pause execution and look at the call-stack it's almost always in a ManagementScope.Connect() call. A new connection seems to be made with each WQL query. Despite limited trial and error, I haven't found any big wins yet in improving the performance of the WMI ...

Returning mounted drives on server in WQL

I am trying create a simple WQL query where I only return mounted drives on a server. These are drives that do not have a drive letter associated with them. I tried the following sytnax and it does not return a result set: SELECT * FROM Win32_Volume WHERE DriveLetter = "" Here is the complete code sample in C#: string ManagementPat...

What format is this time value in?

I have a WMI query that specifies time in this format '20090219000000.000000+480' Can someone tell me what format this is, and does .NET have any built-in functionality to work with it? EDIT This time value is from a sample query that I found. I don't know what time value was used to generate it. I just need to be able to convert a ti...

Listing windows user accounts using C#

Hi, I have to list all users (both local system and domain). I tried using WQL but it takes a lot of time for the program to run. Is there any other way to get it from registry? Any help would be appreciated. ...

WQL does not support TOP - need workaround

WQL (basically SQL for WMI) does not support the TOP keyword the way Sql Server and many other RDBMSs do (though the actual keyword is different sometimes but the concept is implemented.) Is there a workaround to emulating a SELECT query to behave as though it had a TOP clause that limited the result set? Or is there some other WQL-sp...

Device driver code signing for windows XP 32 bit

I have written a device driver for a device but each time I connect the device in windows XP 32 bit, "found new hardware" wizard appears. I am signing the driver using a Comodo code signing certificate and not using the cross certificate chain to link to microsoft root authority. Nor is the driver wql certified. So my question is to di...

MSNdis_StatusMediaDisconnect and device Unique Name.

Hello, I'm using ManagementEventWatcher to watch the disconnection of network cable using System.Management. ManagementEventWatcher with the WQL: SELECT * FROM MSNdis_StatusMediaDisconnect, and the following method is fired, when EventArrived: private void ServiceNetWorkStatusWmiDisconnected(object sender, EventArrivedEventArgs args...

Can I get the ExecutablePath from a System.Management.EventArrivedEventArgs object?

I'm using a System.Management.ManagementEventWatcher to get the process ID and executable path for a started process: private void startWatcher_EventArrived(Object sender, EventArrivedEventArgs e) { String processID = e.NewEvent.Properties["ProcessID"].Value.ToString(); var searcher = new ManagementObjectSearcher(new WqlObjectQ...

WQL SELECT with optional column

I need to make a query like this: SELECT PNPDeviceID FROM Win32_NetworkAdapter WHERE AdapterTypeId = 0 Trouble is, the AdapterTypeId column isn't always present. In this case, I just want everything, like so: SELECT PNPDeviceID FROM Win32_NetworkAdapter My WQL/SQL knowledge is extremely limited. Can anybody tell me how to do th...

Constructor ManagementObject(string path) fails to parse strings obtained from querying Win32_GroupUser class (C#)

So, I WMI query a remote machine to get the members of its Administrators group: SELECT PartComponent FROM Win32_GroupUser WHERE GroupComponent = "Win32_Group.Domain='MACHINE_NAME',Name='Administrators'" It returns the PartComponent property as strings. Here's the list (names changed for security). Domain users joeblow and janedoe are...

I have a SID of a user account, and I want the SIDs of the groups it belongs to

This has to be obtained from a remote machine. The following query works not for SIDs, but for group and account names. "SELECT GroupComponent FROM Win32_GroupUser WHERE PartComponent = \"Win32_UserAccount.Domain='" + accountDomain + "',Name='" + accountName + "'\"" The Win32_Group objects it returns come in the forms of strings, and ...

How to get a count of ManagementObjects (WMI results) without enumerating through the collection in .NET

When querying for large ammount of data through WMI (say the windows events log Win32_NTLogEvent) it is very useful to know what kind of numbers you are getting yourself into before downloading all the content. Is there a way two do this? From what i know there is no "Select Count(*) FROM Win32_NTLogEvent" in WQL. From what i know the ...

When querying the Win32_NTLogEvent Class from WMI with WQL is the TimeGenerated property based on Local time of the computer or GMT?

I am writing a C# windows service that is doing some churning through the eventlog on a few domain controllers. Some of them are Windows Server 2003 and some are Windows Server 2008. Upon the service stopping I am attempting to resume where I left off in the logs. In order to do this instead of SELECT * FROM Win32_NTLogEvent WHERE --cr...

How to join in a WMI Query (WQL)

I want to get the serial number of the boot-harddisk via a WQL query. The boot-partition can be retrieved using the following query: SELECT * FROM Win32_DiskPartition where BootPartition=True The serial number is in Win32_DiskDrive: SELECT DeviceID, SerialNumber FROM Win32_DiskDrive Win32_DiskDriveToDiskPartition has the mapping o...

WMI EventLog Time interval

Hie all, I'm trying to get eventlog entries using WMI and WQL. I can get the right log with the right sourcename of itand so on, but i can make a select query to only get result for the 5 or 10 past minutes. here is my query: ...

WMI - EventLog - Time interval

Hie all, I get through WMI Evenlogs matching specific criteria like Sourcename and Description and it's ok for that part. Now i'd like to get the same thing but in the 5 or 10 last minutes. I tried to use TimeGenerated and TimeWritten form the Win32_NTLogEvent but no success here is my basic query with no time: SELECT Logfile, Messa...