expetrov
Goto Top

Auswertung zwischen zwei .txt file mit powershell

Hallo zusammen,

Könnt ihr bitte für mich kurz Helfen wie ich die untenstehende auswertung zwischen die zwei .txt file verfeinen kann.
Es sollte auf ca. 50 Servers überprüft werden, welche Service nach dem serverneustart nicht gestartet sind.

das problem ist, bei mir werden die Services welche nicht läufen ohne servername aufgelistet.

Es wäre sehr hilfsreich wenn es so aufgelistet wäre:

server1

InputObject
Running ShellHWDetection Shell Hardware Detection <=

Server2

InputObject
Running ShellHWDetection Shell Hardware Detection <=


Mommentan wird es bei mir so aufgelistet:
InputObject
Running ShellHWDetection Shell Hardware Detection <=
Running VaultSvc Credential Manager <=
Running Appinfo Application Information <=
Running K1TCMA Monitoring Agent for TSI Custom Sca... <=
Running klocma_os-basic Tivoli Log File Agent os-basic <=
Running ShellHWDetection Shell Hardware Detection <=
server1 <=
Server2 <=
Server3 <=
Server4 <=
Server5 <=

SCript 1 wird vor den serverneustart ausgeführt.
Script 2 wird nach dem alle servers neugestartet wurden ausgeführt.

script 1 :
$ServerListe = Get-Content "D:\Serverliste.txt"

foreach ($Server in $ServerListe ) {

$Server | Out-File D:\Result1.txt -append
Get-Service -computername "$Server" | Where-Object {$_.status -eq "running"} | out-file D:\result1.txt -append

}

script 2:
$ServerListe = Get-Content "D:\Serverliste.txt"

foreach ($Server in $ServerListe ) {

$Server | Out-File D:\Result2.txt -append
Get-Service -computername "$Server" | Where-Object {$_.status -eq "running"} | out-file D:\result2.txt -append

}

auswertung:
compare-object -referenceobject $(get-content D:\Result1.TXT) -differenceobject $(get-content D:\Result2.TXT)

Content-Key: 284660

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

Printed on: April 19, 2024 at 20:04 o'clock

Mitglied: 122990
122990 Oct 05, 2015 updated at 11:07:57 (UTC)
Goto Top
Schaust du hier rein ...
Dienste mit Powershell überprüfen

Gruß grexit