Get-EventLog - 轻松过滤“今天”? [英] Get-EventLog - easily filter by 'today'?

查看:180
本文介绍了Get-EventLog - 轻松过滤“今天”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想快速检查今天发生的事件(即从午夜起的任何事情); Powershell里现在有没有别名/内置的帮助?



我正在做这样的事情:

  get-eventlog system -sourcedisk-after([datetime] '01 / 01/2015')
但是,当然,我不得不更改日期字符串。



[另外:datetime构造函数似乎坚持使用美国的日期格式(mm / dd / yyyy) - 尽管我的Windows Locale是英国的?]

解决方案

DateTime 类有一个静态属性今天将会精确地返回你需要的东西:

  get -eventlog系统-sourcedisk-after([datetime] ::今天)


I want to quickly check for events that happened today (that is: anything from midnight onwards); is there 'today' alias/built-in in Powershell to help out with this ?

I'm currently doing something like this:

get-eventlog system  -source "disk" -after ([datetime] '01/01/2015')

But of course I keep having to change the date string.

[ Also: that datetime constructor appears to insist on a US date-format (mm/dd/yyyy) only - despite the fact that my Windows Locale is UK ?]

解决方案

The DateTime class has a static Property Today which will return exactly what you need:

get-eventlog system  -source "disk" -after ([datetime]::Today)

这篇关于Get-EventLog - 轻松过滤“今天”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆