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:
1
2
3
4
2
3
4
$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)
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 559364
Url: https://administrator.de/forum/ausgabe-in-powershell-fuer-mailversand-formatieren-559364.html
Ausgedruckt am: 05.04.2025 um 08:04 Uhr
2 Kommentare
Neuester Kommentar

1
$Updates | ft @{n='Folgende Windows Updates wurden installiert:';e={$_.Title}} -AutoSize -Wrap | out-string