Bit di una domanda semplice ma come faccio a selezionare una colonna specifica nel codice seguente?mostra solo una colonna nel risultato?
Voglio solo mostrare la colonna TIME e nient'altro. Cerco di mettere in tempo FORMAT_TABLE ma semplicemente popola con il tempo più volte senza in realtà che mostra il tempo ..
$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
}
RISULTATO: voglio solo Mostra la colonna TEMPO
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! Ecco perché mi stava confondendo! come si trova il nome esatto delle colonne C.B.? – lara400
Inoltre, utilizzare 'Get-WinEvent'. Il 'Get-EventLog' è per [retrocompatibilità] (http://technet.microsoft.com/en-us/library/hh849682.aspx) (vedere la sezione Note). Oh, e quindi è TimeCreated, non TimeGenerated. – vonPryz
in questo modo: '(Get-EventLog -logname system) [0] | fl * 'restituisce un elenco di tutte le proprietà per un singolo registro eventi. Si trova anche 'timewritten', ma IIRC quello che si vede per default nel formato PowerShell' Timegenerated' –