wmi

Invoking functions with `out` arguments, passing arguments by reference in JScript

一笑奈何 提交于 2020-01-04 09:07:31
问题 I'm using following code in JScript (WSH) to connect to local registry using WMI: var registry = GetObject('winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv'); and that works. Then I have to determine if I'm allowed to delete key without really trying to delete it (e.g. perform a non-destructive check). I looked over docs and found that I need StdRegProv.CheckAccess() method. Problem is that CheckAccess returns result as out argument and I could not find VBScript's

Correlate Physical Device ID to Volume Device ID

点点圈 提交于 2020-01-04 04:23:06
问题 I'm trying to utilize WMI via PowerShell to run through SAN storage on remote servers to grab the Windows disk management volume label. The only way I've found to do this is to correlate the volume device id ( \\?\Volume{34243...} with the physical disk device ID ( \\.\PHYSICALDRIVE01 ). However, I haven't been able to find out how to link those two fields together. Is this possible with WMI? 回答1: For volumes that were assigned a drive letter you can correlate disks and volumes like this: Get

MSMQ WMI Query Failing Due to Missing Performance Counters

萝らか妹 提交于 2020-01-04 02:34:11
问题 When trying to execute the following query from powershell: Get-WmiObject -query "Select * from Win32_PerfRawData_MSMQ_MSMQQueue" I receive the error: Get-WmiObject : Invalid query At line:1 char:14 + Get-WmiObject <<<< -query "Select * from Win32_PerfRawData_MSMQ_MSMQQueue" + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand I have diagnosed this to the performance

How do I parse data from a Get-WMIObject query into a string?

风格不统一 提交于 2020-01-03 18:37:11
问题 I have the following line of code... get-wmiobject -class win32_computersystem | select-object username It returns (redacted with placeholders)... @{username=DOMAIN\jsmith} What needs to be done to remove the padding and give me a "plain" readout of DOMAIN\jsmith ? For bonus points, how do I parse that value into just jsmith ? 回答1: You need to expand the property to get the value of username instead of a custom object with the property username . Try get-wmiobject -class win32_computersystem

How to obtain a registry value from a remote machine if I don't know its type? (C#)

假装没事ソ 提交于 2020-01-03 08:48:14
问题 Depending on what value type is stored, I have to use one of the following methods: GetBinaryValue GetDWORDValue GetExpandedStringValue GetMultiStringValue GetStringValue I would like not to have to try all five if all I know about a value is the hive, the key, and the value name. Is there a way to do that? I'm using WMI, but if the only way is by using the advapi32.dll method, I'm open to that. 回答1: You can use the StdRegProv.EnumValues method to enumerate values of the key, find out the

Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?

扶醉桌前 提交于 2020-01-03 05:03:41
问题 I need to get a list of SQL server instances present on a computer, get a list of databases in each instance, and then determine how much space each database is taking up. I can easily grab the instance names from the registry, but I don't have access to query the tables to get the names of the databases. Is there another way of doing this, maybe though WMI? 回答1: After some digging around, I finally found the WMI Class that will get my the info I need. On a server where I have 3 instances of

Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?

时光怂恿深爱的人放手 提交于 2020-01-03 05:03:08
问题 I need to get a list of SQL server instances present on a computer, get a list of databases in each instance, and then determine how much space each database is taking up. I can easily grab the instance names from the registry, but I don't have access to query the tables to get the names of the databases. Is there another way of doing this, maybe though WMI? 回答1: After some digging around, I finally found the WMI Class that will get my the info I need. On a server where I have 3 instances of

check if WMI namespace exists from c#

依然范特西╮ 提交于 2020-01-03 04:17:07
问题 I want to check if a certain feature is installed on a certain machine. I have a powershell code that checks this, and now I want to check this from .net code. I can see that in the cmdlet, the code checks if there is an invalid namespace error. When searching the web, I found the following code: ManagementClass myClass = new ManagementClass(scope, path, getOptions); try { myClass.get(); } catch (System.Management.Exception ex) { if (ex.ErrorCode == ManagementStatus.InvalidNamespace) { return

Why does applying a static IP address via WMI work just once?

青春壹個敷衍的年華 提交于 2020-01-03 00:54:30
问题 I'm about to write a simple network configuration tool which can either set IP address and so on statically or let it be set automatically (DHCP), all by means of WMI. Unfortunately, setting the address statically works just once! So when you run the test function below once, everything works perfect (don't forget a breakpoint at // DYNAMIC!). But at the second time and when you check the results in the control panel's properties page of the network adapter IP address and subnet mask remain

Is it possible to determine the Win32_DiskDrive SerialNumber of the Environment.SpecialFolder.System drive?

一笑奈何 提交于 2020-01-02 17:36:01
问题 I've been going around in circles for a bit now, can't seem to find the answer on google either. As the title says, if i get the current drive letter windows is running on, let's say like this: Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System)); Can i then determine its Win32_DiskDrive SerialNumber? I cannot find a way to link them. That is the manufacturer's S/N not the VolumeSerialNumber. Thanks in advance 回答1: You can use ManagmentObjectSearch combined with