我有一个包含以下行的 Powershell 脚本:
$package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'" -f $ApplicationName)
我按照此答案中的步骤操作,以便在服务器之间启用 Powershell 远程处理:remoting security steps
当我从 Powershell ISE(在提升的管理窗口中)运行脚本时,出现以下错误:
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:14
+ Get-WmiObject <<<< win32_bios -computername d-vasbiz01
+ CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
我需要能够在 ISE 中运行该脚本,以便解决其他问题。
任何人都可以建议我需要做什么来修复此安全错误吗?
最佳答案
我需要将凭据传递给 Get-WmiObject cmdlet。
我在这里找到了答案:Powershell Masters
关于Powershell Get-WmiObject 访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11968210/