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:
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)
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)
Please also mark the comments that contributed to the solution of the article
Content-Key: 559364
Url: https://administrator.de/contentid/559364
Printed on: May 4, 2024 at 07:05 o'clock
2 Comments
Latest comment
$Updates | ft @{n='Folgende Windows Updates wurden installiert:';e={$_.Title}} -AutoSize -Wrap | out-string