Trochę prostego pytania, ale jak wybrać konkretną kolumnę w poniższym kodzie?wyświetla tylko jedną kolumnę w wyniku?
Chcę tylko pokazać kolumnę TIME i nic więcej. Staram i umieścić w FORMAT_TABLE czas, ale to po prostu zapełnia z czasem wiele razy bez faktycznie wskazujące czas ..
$server_event = Get-Content -Path "c:\Temp\Servers.txt"
foreach($servers in $server_event)
{
$event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select -First 1
$event
}
WYNIK: Chcę tylko pokazać kolumnie Czas
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
78858 Jun 01 07:19 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
46221 Jun 01 07:20 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
214480 Jun 01 07:46 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
461238 Jun 01 07:18 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
70889 Jun 01 07:17 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
52397 Jun 01 07:19 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.
42219 Jun 01 07:40 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Uniprocessor Free.
ahhh ........ TimeGenerated! Właśnie dlatego mnie to dezorientowało! jak znaleźć dokładną nazwę kolumn C.B.? – lara400
Zamiast tego należy użyć 'Get-WinEvent'. 'Get-EventLog' jest dla [kompatybilności wstecznej] (http://technet.microsoft.com/en-us/library/hh849682.aspx) (patrz sekcja Uwagi). Aha, i to jest TimeCreated, a nie TimeGenerated. – vonPryz
w ten sposób: '(Get-EventLog -logname system) [0] | fl * 'zwraca listę wszystkich właściwości dla pojedynczego zdarzenia. Znajdziesz także 'timewritten', ale IIRC to domyślny format PowerShell' 'Timegenerated' –