marcimarc85
Goto Top

Ausgabe in Powershell für Mailversand formatieren

Ich habe ein Powershellscript, was ausstehende Windows Updates per Aufgabenplanung installiert und den Server neustartet. Das Script kann auch eine Mail verschicken. Aktuell steht dort nur drin, dass der Server nach Updates neu gestartet wurde. Wie kann ich die gefundenen Updates so ausgeben lassen (write-host), dass sie in der MAil dann untereineander aufgelistet werden und die Spalte "Title" umbenannt wird in "Folgende Windows Updates wurden installiert"?

Die Abfrage ist:

$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsInstalled=0 and Type='Software'").Updates)   
$Updates | Select-Object Title

Die Ausgabe davon:

Title

2020-01 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4535104)
2020-02 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4538124)
2020-02 Preview of Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4538158)
Windows Malicious Software Removal Tool x64 - March 2020 (KB890830)
2020-03 Servicing Stack Update for Windows Server 2012 R2 for x64-based Systems (KB4540725)
2020-03 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4541509)
2020-03 Preview of Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4541334)


Wunsch wäre:

Folgende Windows Updates wurden installiert:

2020-01 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4535104)
2020-02 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4538124)
2020-02 Preview of Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4538158)
Windows Malicious Software Removal Tool x64 - March 2020 (KB890830)
2020-03 Servicing Stack Update for Windows Server 2012 R2 for x64-based Systems (KB4540725)
2020-03 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4541509)
2020-03 Preview of Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4541334)

Content-Key: 559364

Url: https://administrator.de/contentid/559364

Printed on: April 24, 2024 at 13:04 o'clock

Mitglied: 143127
Solution 143127 Mar 20, 2020 updated at 11:48:03 (UTC)
Goto Top
$Updates | ft @{n='Folgende Windows Updates wurden installiert:';e={$_.Title}} -AutoSize -Wrap | out-string  
Member: MarciMarc85
MarciMarc85 Mar 20, 2020 at 12:48:49 (UTC)
Goto Top
Vielen Dank. Genau so funktioniert es !