首页 > 解决方案 > 如果可能,寻求有关完成此 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

标签: powershellreportingserver-administration

解决方案


推荐阅读