如果可能,寻求有关完成此 Wsus 脚本的帮助

问题描述

为澄清而编辑:目标在我想要完成的内容中进行了概述。现在我不知道我是否朝着正确的方向前进。简而言之,

  1. 我的做法正确吗? (示例是否可以使用单个脚本还是我需要多个脚本?在 powershell 中执行此操作是否有更好的过程?)
  2. 我如何利用这里的资源实现我的目标?它只做我正在寻找的一部分。列出应进行更新的计算机的部分以及我遇到困难的所述计算机上的更新状态。
  3. 我不希望人们写这篇文章,而是帮我弄清楚。我无法想象我是第一个满足这些需求的人,只是还没有找到类似的帮助脚本。

背景故事: 在过去的几周里,我一直在自学 Powershell 以实现 wsus 报告目标。我到处搜索,试图找到一个我可以修改以满足我的需要的脚本,但我觉得我有限的技能使这变得困难。 目标:预先批准 我正在尝试生成需要批准的更新列表。 (这有效)但是对于每个更新,我想列出应该获取此更新的服务器以及更新状态。示例:server1/server2/server3 需要更新 KB12345 并且安装状态等于 X。我只是对处理此问题的最佳方法感到困惑。我可以导出为不同的文件格式。列出“需要批准多少更新”的第一部分的 TXT 和计算机状态部分的 excel。我开始玩电脑,但我无法过滤它,所以我可以得到工作站与服务器。它列出了所有内容。 目标:验证安装状态 我想在我们的维护窗口期间/之后运行第二次检查,以便我们可以确认所有安装正确,并且该报告记录在我们的审计需求变更请求中。 我尝试过的事情: 检查每台计算机以查看更新是否使用不同的脚本安装需要很长时间,并且依赖于可用的工作站。服务器没什么大不了的,因为它们总是在运行。如果 wsus 没有及时更新,我们可以在本地与服务器进行比较,但我需要能够运行它,以便我可以报告本月的工作站。 (我只关心每月应用的更新。不是未完成的或以前的更新。)

我想把它分成两个脚本。一个执行批准列表,另一个在与文本文件中的 KB# 列表进行比较后运行。

我觉得这有点矫枉过正,但我​​们今年的 SOX 审计有任何小问题或担忧都受到了疯狂的审查。 #注意我的脚本中的“清理”是 ISEprofile 的本地函数,它会在每次运行时清除所有内容。投入生产时将其删除。

Cleanup
[void][reflection.assembly]::LoadWithPartialName(“Microsoft.UpdateServices.Administration”)
#Connect to the WSUS Server and create the wsus object
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘wsus’,$False,"8530")

#Variables
#Wsus Variables
$Arrivaldate = ”01/12/2021"
#ApprovedStatus could be the following:Any,declined,hasstaleupdateapprovals,latestrevisionapproved,notapproved
$ApprovedStatus = "notapproved"
$InstallationStatus = "NotInstalled"
#Logging Variables
$Logpath = "D:\scripts\ps1\Testing\Logs\Monthlyupdatelist.txt"



#Create a computer scope object
$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
#Create UpdateScope
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope

#Find all clients using the computer target scope
#$wsus.GetComputerTargets($computerscope)
#$Wsus.GetComputerStatus($computerscope,[ Microsoft.UpdateServices.Administration.UpdateSources]::All)

#Find updates based on scope below. Run $updatescope alone to see all the items you can filter by.
$updatescope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::$ApprovedStatus
$updatescope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::$InstallationStatus
$updatescope.FromArrivalDate = [datetime]$Arrivaldate

Start-Transcript -Path $Logpath
#This lists how many updates are set in "all updates"
Write-Host "Number of Updates this month to approve:"$wsus.GetUpdateCount($updatescope)

$wsus.GetUpdateStatus($updatescope,$False)

#List out the updates for the month
$Updatelist = $wsus.GetUpdates($updatescope) 
$Updatelist | Select Title,UpdateClassificationTitle,KnowledgebaseArticles,ProductTitles,ArrivalDate,IsApproved,IsDeclined 


Stop-Transcript

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...