【发布时间】:2019-10-26 10:48:42
【问题描述】:
我正在尝试使用以下命令在远程计算机上安装 Windows 更新:
$InstallSplat = @{
AcceptAll = $true
SendReport = $true
IgnoreReboot = if ($Reboot) { $false } else { $true }
PSWUSettings = @{
SmtpServer = "my mail server"
From = "myfrom <myfrom@myfrom.com>"
To = "myto <myto@myto.com>"
Port = 25
}
}
Invoke-Command -ComputerName $_ -Credential $cred -AsJob -ArgumentList $InstallSplat -ScriptBlock {
param([hashtable]$InstallSplat)
Import-Module PSWindowsUpdate
Install-WindowsUpdate @InstallSplat
$Error | out-file C:\install\installwinupdate.log -Append
}
我在$cred 中传递了一个具有域管理员权限的凭据对象,但我仍然总是收到此错误
Install-WindowsUpdate : Access denied (Ausnahme von HRESULT: 0x80070005 (E_ACCESSDENIED)) In Zeile:4 Zeichen:25
+ Install-WindowsUpdate @InstallSplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-WindowsUpdate], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,PSWindowsUpdate.GetWindowsUpdate
命令Install-WindowsUpdate 本身没有我可以使用的凭据参数。该命令需要在提升的 PowerShell 中运行,但我在计算机上启动此命令时使用提升的 PowerShell。
我还尝试使用我的$cred 创建一个New-PSSession 并运行Invoke-Command -Session $session 而不是Invoke-Command -ComputerName $_,结果相同。
有人知道这里发生了什么吗?为什么我会被拒绝访问?
它与传递$InstallSplat 没有任何关系,因为如果我根本不传递任何参数并直接在命令中写入参数及其值而不是飞溅,也会发生同样的事情。
【问题讨论】:
-
@GuentherSchmitz 好的,这绝对不是重复的。如果我没有将任何东西传递给调用命令并且根本不使用飞溅(刚刚测试过),也会发生同样的事情。
-
根据community.spiceworks.com/topic/…,这是一项安全功能。该帖子中的链接serverfault.com/questions/473991/… 显示有些人使用 JEA 完成了此操作。
-
@GuentherSchmitz 所以我不能在 RemoteMachine 上下载 WinUpdates,即使他们从 WSUS 服务器获取更新?真是可惜了
-
这就是我从帖子中读到的内容 - 可以在周一或今天晚些时候在我的环境中进行测试并向您报告
标签: powershell