Today I come with this simple tutorial about how to show logs from the last day.
The command is very simple and can be used with PowerShell and administrator command shell like this:
1 | Get-EventLog Application -After (Get-Date).AddDays(-1) |
This command is built from Get-EventLog and parse by Get-Date, see options:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Get-EventLog [-LogName] [-ComputerName <String[]>] [-Newest ] [-After ] [-Before ] [-UserName <String[]>] [[-InstanceId] <Int64[]>] [-Index <Int32[]>] [-EntryType <String[]>] [-Source <String[]>] [-Message ] [-AsBaseObject] [] Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Month <Int32>] [-Day <Int32>] [-Hour <Int32>] [-Minute <Int32>] [-Second <Int32>] [-Millisecond <Int32>] [-DisplayHint <DisplayHintType>] [-UFormat <String>] [<CommonParameters>] |
About AddDays is not the only option you can use it.
You can get all of these options using this command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | PS C:\WINDOWS\system32> [DateTime]::Now |Get-Member -MemberType Method TypeName: System.DateTime Name MemberType Definition ---- ---------- ---------- Add Method datetime Add(timespan value) AddDays Method datetime AddDays(double value) AddHours Method datetime AddHours(double value) AddMilliseconds Method datetime AddMilliseconds(double value) AddMinutes Method datetime AddMinutes(double value) AddMonths Method datetime AddMonths(int months) AddSeconds Method datetime AddSeconds(double value) AddTicks Method datetime AddTicks(long value) AddYears Method datetime AddYears(int value) CompareTo Method int CompareTo(System.Object value), int Comp... Equals Method bool Equals(System.Object value), bool Equal... GetDateTimeFormats Method string[] GetDateTimeFormats(), string[] GetD... GetHashCode Method int GetHashCode() GetObjectData Method void ISerializable.GetObjectData(System.Runt... GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCo... IsDaylightSavingTime Method bool IsDaylightSavingTime() Subtract Method timespan Subtract(datetime value), datetime ... ToBinary Method long ToBinary() ToBoolean Method bool IConvertible.ToBoolean(System.IFormatPr... ToByte Method byte IConvertible.ToByte(System.IFormatProvi... ToChar Method char IConvertible.ToChar(System.IFormatProvi... ToDateTime Method datetime IConvertible.ToDateTime(System.IFor... ToDecimal Method decimal IConvertible.ToDecimal(System.IForma... ToDouble Method double IConvertible.ToDouble(System.IFormatP... ToFileTime Method long ToFileTime() ToFileTimeUtc Method long ToFileTimeUtc() ToInt16 Method int16 IConvertible.ToInt16(System.IFormatPro... ToInt32 Method int IConvertible.ToInt32(System.IFormatProvi... ToInt64 Method long IConvertible.ToInt64(System.IFormatProv... ToLocalTime Method datetime ToLocalTime() ToLongDateString Method string ToLongDateString() ToLongTimeString Method string ToLongTimeString() ToOADate Method double ToOADate() ToSByte Method sbyte IConvertible.ToSByte(System.IFormatPro... ToShortDateString Method string ToShortDateString() ToShortTimeString Method string ToShortTimeString() ToSingle Method float IConvertible.ToSingle(System.IFormatPr... ToString Method string ToString(), string ToString(string fo... ToType Method System.Object IConvertible.ToType(type conve... ToUInt16 Method uint16 IConvertible.ToUInt16(System.IFormatP... ToUInt32 Method uint32 IConvertible.ToUInt32(System.IFormatP... ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatP... ToUniversalTime Method datetime ToUniversalTime() |