我尝试使用这个URI来查找特定的机器ID,这样我们就可以查询最近登录的用户。当我运行这个程序时,我会得到Defender中所有设备的输出。我被困住了不知道该何去何从
https://api.securitycenter.microsoft.com/api/machines?$filter=computerDnsName eq '计算机名在此”
我尝试使用这个URI来查找特定的机器ID,这样我们就可以查询最近登录的用户。当我运行这个程序时,我会得到Defender中所有设备的输出。我被困住了不知道该何去何从
https://api.securitycenter.microsoft.com/api/machines?$filter=computerDnsName eq '计算机名在此”
3条答案
按热度按时间lsmepo6l1#
找到机器ID并使用此API -https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/get-machine-log-on-users?view=o365-worldwide
https://api.securitycenter.microsoft.com/api/machines/'machine id '/logonuser
ogsagwnx2#
要根据设备名称查找ID,请使用此API调用。
https://api.securitycenter.microsoft.com/api/machines?$filter=computerDnsName eq“此处显示设备名称”。一旦你得到了设备名,你就可以用这个来查找登录的用户。
https://api.securitycenter.microsoft.com/api/machines/id
eqfvzcg83#
经过进一步调查,似乎更有可能的问题,一些id:s不匹配的值在UI中发现只影响一些设备,可能已注册多次,由于被克隆(我们使用SCCM)。我认为对于大多数设备来说,这是预期的
这里的问题是你从这个API中获得的机器的id:https://api.securitycenter.microsoft.com/api/machines,可能与您在其他API中需要的ID不同:所以我认为这是一个有效的问题,到目前为止,我不确定答案。
在powershell中,这是可行的:
这将给予你和id说(005067aa02b68b884f2c2cf3ba2e678b8c717299),但不一定是你想要的id,没有“机器id”返回,“aadDeviceId”不能使用,它有时也是空的。返回的id有时与Defender GUI中列出的“Device id”(第二个查询所需的id)不相同。如果是这种情况,查询将返回空结果:
如果有人有一个工作的例子,我会很有兴趣看到它,并尝试自己。这个API也有同样的问题:https://api.securitycenter.microsoft.com/api/machines/{id}/software。我不知道如何可靠地获得正确的id,除了从GUI复制它。这似乎是API中的一个bug,或者我遗漏了一些明显的东西。
我已经在Github上打开了这个问题:https://github.com/MicrosoftDocs/microsoft-365-docs/issues/12717#issuecomment-1708068386