ASSOCIATORS OF 语句中的 ObjectPath 是否有任何限制? [英] Are there any restrictions on ObjectPath in ASSOCIATORS OF statement?

查看:35
本文介绍了ASSOCIATORS OF 语句中的 ObjectPath 是否有任何限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们以下面的请求为例:

{Win32_DiskPartition.DeviceID="Disk #2, Partition #0"} 的关联,其中 AssocClass = Win32_LogicalDiskToPartition

它工作正常并返回带有(在我的情况下)一个逻辑磁盘 F: 的相应列表.但是,如果我更改此查询中指定对象的方法,例如,这样:

ASSOCIATORS OF {Win32_DiskPartition.DiskIndex=2},其中 AssocClass = Win32_LogicalDiskToPartition

我收到无效的对象路径"错误(在 PowerShell 中).字段 DiskIndex 肯定存在(请求SELECT * FROM Win32_DiskPartition WHERE DiskIndex=2"返回驻留在我的磁盘 #2 上的唯一一个分区),那么这样的请求有什么问题?我还尝试使用 Win32_DiskPartition 类的其他一些字段,但它们都没有在ASSOCIATORS OF"请求中工作.Internet 中的任何地方(即 google 发送给我的地方)都没有关于 ObjectPath 的任何限制的信息.此外,我发现了一篇是

{ObjectPath} 的关联者

所以你只能将一个有效的对象传递给这个句子.

Let's take for example the following request:

ASSOCIATORS OF {Win32_DiskPartition.DeviceID="Disk #2, Partition #0"} WHERE AssocClass = Win32_LogicalDiskToPartition

It works fine and returns the corresponding list with (in my case) one logical disk, F:. However if I change the method of specifying the object in this query, for example, this way:

ASSOCIATORS OF {Win32_DiskPartition.DiskIndex=2} WHERE AssocClass = Win32_LogicalDiskToPartition

I get the "Invalid object path" error (in PowerShell). The field DiskIndex is definitely there (the request "SELECT * FROM Win32_DiskPartition WHERE DiskIndex=2" returns the one and only partition that resides on my disk #2), so what's wrong with such request? I also tried using some other fields of Win32_DiskPartition class, but none of them worked in the "ASSOCIATORS OF" request. Anywhere in the Internet (that is, where google sent me) there is no information about any restrictions on the ObjectPath. Moreover, I found one article where the author explicitly says:

This qualifier can be any property from the source WMI class

So, what's wrong with this request modification?

解决方案

The ObjectPath is a string that uniquely identifies a instance of a class, and is conformed by the key property of the WMI Class, so you cannot use any property to build a ObjectPath. in this case the Object Path of the Win32_DiskPartition uses the DeviceID property which is the Key property for this class.

The basic syntax for the ASSOCIATORS OF is

ASSOCIATORS OF {ObjectPath}

So you only can pass a valid object pass to this sentence.

这篇关于ASSOCIATORS OF 语句中的 ObjectPath 是否有任何限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆