我有一个包含以下行的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中运行该脚本,以便能够排除其他问题。
有人能建议我需要做些什么来修复这个安全错误吗?
发布于 2012-08-23 21:40:19
我需要将凭据传递给Get-WmiObject cmdlet。
我在这里找到了答案:Powershell Masters
发布于 2018-10-12 10:15:36
在猜测了一段时间后,缓存的凭据是我的问题。
打开windows凭据管理器:
rundll32.exe keymgr.dll,KRShowKeyMgr
删除所有缓存条目。
发布于 2021-08-06 23:52:32
要扩展Rob Bowman的答案,您可以预先收集凭据,或者在运行命令时收集凭据。
$creds = get-credential $package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'“-f $ApplicationName) -credential $creds
$package = Get-WmiObject -Class Win32_Product -ComputerName $TargetServer -Filter ("Name='{0}'“-f $ApplicationName) -credential WmiObject
https://stackoverflow.com/questions/11968210
复制相似问题