我是新来的,我正在寻找一个脚本供我列出Windows更新,然后将它们放在Excel上,我有很多代码可以分开显示日期,你能帮忙吗?这是代码:
$System=Get-WmiObject -Class Win32_OperatingSystem -Computer .
$system=$System.CSName
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$updateSearcher = new-object -com "Microsoft.Update.Searcher"
$totalupdates = $updateSearcher.GetTotalHistoryCount()
$patchList=$updateSearcher.QueryHistory(0,$totalupdates)
write-host "Nombre total de patches installés sur le poste [$system] :" $patchList.Count
write-host "Préparation du classeur Excel...."
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Name = "Patches installés"
$Sheet.Cells.Item(1,1) = "Titre"
$Sheet.Cells.Item(1,2) = "Description"
$Sheet.Cells.Item(1,3) = "Date"
$Sheet.activate()
$Sheet.application.activewindow.splitrow = 1
$Sheet.application.activewindow.freezepanes = $true
$intRow = 2
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 11
$WorkBook.Font.ColorIndex = 19
$WorkBook.Font.Bold = $True
Foreach($patch in $patchList){
$HotfixID=$patch.Title
$HotfixID=$HotfixID.Split('(')
$HotfixID=$HotfixID[1]
$HotfixID=$HotfixID.Trim(')')
$Sheet.Cells.Item($intRow, 1) = $HotfixID
$Sheet.Cells.Item($intRow, 2) = $patch.Title
$Sheet.Cells.Item($intRow, 3) = $patch.Installeddate
$intRow = $intRow + 1}
答案 0 :(得分:1)
您可以在foreach循环中使用$patch.Date
获取此信息