![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Problem formatting date I have obtained the date from particular eventlog entries but require the day and month to swap order (dd/mm/yyyy to mm/dd/yyyy) in order to be able to compare to pwdlastset obtained from ADSI - I have come up with the following but although it seems to work it provides reoccuring output - can someone offer as to why? Many Thanks $events = get-eventlog Security -newest 2000 | where {($_.EventID -eq 642) -and ($_.UserName -eq "TestDomain\Administrator")} Foreach($event in $events)#{Write-Host $Event.TimeWritten} { $EVT = "$($Event.TimeWritten)" $EVTConvertedDate = "{00:MM}/{00:dd}/{0000:yyyy} {0:hh}:{0:mm}:{0:ss}" -f ($EVT) write-host "$EVTConvertedDate" } -- jobbsy@xxxxxx |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Problem formatting date You can try ToString(): $EVT.TimeWritten.ToString("MM/dd/yyyy") or the date format operator $EVTConvertedDate = "{0:MM/dd/yyyy}" -f $EVT.TimeWritten ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I have obtained the date from particular eventlog entries but require > the day and month to swap order (dd/mm/yyyy to mm/dd/yyyy) in order to > be able to compare to pwdlastset obtained from ADSI - I have come up > with the following but although it seems to work it provides > reoccuring output - can someone offer as to why? > > Many Thanks > > $events = get-eventlog Security -newest 2000 | where {($_.EventID -eq > 642) > -and ($_.UserName -eq "TestDomain\Administrator")} > Foreach($event in $events)#{Write-Host $Event.TimeWritten} > { > $EVT = "$($Event.TimeWritten)" > $EVTConvertedDate = "{00:MM}/{00:dd}/{0000:yyyy} {0:hh}:{0:mm}:{0:ss}" > -f ($EVT) > > write-host "$EVTConvertedDate" > } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problem formatting a dvd | Vista music pictures video | |||
| date time formatting | .NET General | |||
| date formatting | PowerShell | |||
| Formatting Problem | Vista music pictures video | |||