Win7上的WMI问题
有人知道为什么下面的简单 Powershell 脚本在 Windows XP 下运行良好,但在 Windows 7 下运行不佳吗?
获取 WmiObject -Class win32_logonsession | %{ get-wmiobject -Query "Associators of {Win32_logonSession.LogonID=$($_.LogonId)} where AssocClass = Win32_LoggedOnUser Role=Dependent" }
在 Windows 7 下,它不会列出任何交互式帐户,仅列出本地系统的会话帐户、网络服务等。但是在 XP 下它会返回所有帐户的信息。
一直在 MSDN 和 Google 上查找,但尚未找到答案。
Anyone understand why the simple Powershell script below works fine under Windows XP but not under Windows 7?
Get-WmiObject -Class win32_logonsession | %{ get-wmiobject -Query "Associators of {Win32_logonSession.LogonID=$($_.LogonId)} where AssocClass = Win32_LoggedOnUser Role=Dependent" }
Under Windows 7 it doesn't list any interactive accounts, only sessions for the local system account, network service etc. However under XP it returns information for all accounts.
Have been looking on MSDN and Google however haven't found an answer as yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题似乎是在幕后发生了双跳,Windows 7 下的 WMI 试图通过针对 AD 的匿名绑定来查找用户帐户详细信息。我们只接受经过身份验证的查询,因此这会默默地失败。
将跳过 WMI 并尝试使用 LSA 函数进行 pinvoke 以使其正常工作。
Seems the problem is that behind the scenes a double hop is occurring and WMI under Windows 7 is trying to find the user account details with an anonymous bind against AD. We only accept authenticated queries so this silently fails.
Going to give WMI a skip and try to pinvoke with LSA functions to get this to work.