Powershell Get-WmiObject 访问被拒绝

标签 powershell tfs

我有一个包含以下行的 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/

相关文章:

tfs - 如何仅在本地删除 TFS 项目?

tfs - 指定为 TFS 测试代理执行编码的 UI 测试的顺序

visual-studio - 从文本文件更新 TFS 构建定义

windows - 使用 Powershell 的 Invoke-Command 调用带参数的批处理文件

powershell - 修改 “tf history”命令以仅生成未合并的变更集

html - 自动化 (IE ComObject) 填充文本框

arrays - 如何使用 Powershell 简化多维数组?

datetime - 如何向 PowerShell 和输出的各行添加时间戳?

git - 在 Azure DevOps 中发布的 Git 分支未在 VS2013 或 Git 命令行中显示

windows - 为什么没有安装 MSTest.exe?