尝试查询WSUS服务器时的HTTP401

时间:2018-03-12 06:27:17

标签: windows powershell windows-server-2012-r2

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($WSUS_Server,$false,80)
  

请求失败,HTTP状态为401:未经授权。

两台计算机位于同一个工作组中,我已将注册表值设置为Unrestricted

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\ScriptedDiagnostics\ExecutionPolicy

为什么我会收到401错误?

1 个答案:

答案 0 :(得分:1)

您需要提供目标计算机的凭据。

您可以使用Powershell Commandlet实现此目的

$ cred =获取凭据

OR

$ password = ConvertTo-SecureString“ PlainTextPassword” -AsPlainText -Force $ cred =新对象System.Management.Automation.PSCredential(“用户名”,$ password)