我正在尝试借助 wmi 和 powershell 远程处理来监控 Windows 机器。我成功地通过非管理员用户帐户启动了与该机器的远程会话,但现在我在运行 WMI 查询时遇到了问题。我的用户属于以下组(我关注了这个答案为该用户设置帐户):
[192.168.173.206]: PS C:\Users\lpu\Documents> Get-ADPrincipalGroupMembership $env:username | Format-table name
name
----
Domain Users
Performance Monitor Users
Distributed COM Users
Remote Management Users
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
[192.168.173.206]: PS C:\Users\lpu\Documents> os_caption
Get-WmiObject : Access denied
At line:2 char:6
+ (Get-WmiObject -class Win32_OperatingSystem).Caption
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
答案1
正如我的同事告诉我的,我需要关闭用户帐户控制。
你可以使用以下命令来执行此操作,我从这个答案:
New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force
Restart-Computer