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:

1
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)

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

143127
Lösung 143127 20.03.2020 aktualisiert um 12:48:03 Uhr
Goto Top
1
$Updates | ft @{n='Folgende Windows Updates wurden installiert:';e={$_.Title}} -AutoSize -Wrap | out-string  
MarciMarc85
MarciMarc85 20.03.2020 um 13:48:49 Uhr
Goto Top
Vielen Dank. Genau so funktioniert es !