随笔分类 -  Powershell--Date/Time

摘要:以下是一段创建DateTime集合的脚本片段。只需要指定年和月,脚本将会针对该月的每一天创建一个DateTime对象:$month = 8$year = 20131..[DateTime]::DaysInMonth($year,$month) | ForEach-Object { Get-Date... 阅读全文
posted @ 2015-05-10 16:05 dongdonggeorge 阅读(421) 评论(0) 推荐(0) 编辑
摘要:1. (get-date -Format 'R') -replace '(?i)[a-z]{3},\s([0-9]{2})\s([a-z]{3})\s([0-9]{4})\s.*', '$2-$1-$3'May-19-20142. (get-date -Format 'R').substring... 阅读全文
posted @ 2015-05-10 16:04 dongdonggeorge 阅读(921) 评论(0) 推荐(0) 编辑
摘要:# 获取最小的日期(通常用于做日期计算)Get-Date 0# 获取当前日期Get-Date# 获取当前日期的年(Get-Date).Year# 获取当前日期的月(Get-Date).Month# 获取当前日期的日(Get-Date).Day# 获取从今年起的天数(Get-Date).DayOfYe... 阅读全文
posted @ 2015-05-10 16:03 dongdonggeorge 阅读(260) 评论(0) 推荐(0) 编辑
摘要:https://technet.microsoft.com/library/ee692801.aspx 阅读全文
posted @ 2015-05-10 16:02 dongdonggeorge 阅读(192) 评论(0) 推荐(0) 编辑
摘要:在WMI中使用Win32_NTLogEvent查询出来的日志生成时间timegenerated类似于“20130820162350.350000+480“,这种时间格式很特殊,经查是DMTF时间格式字符串,在PowerShell中与其它时间类型进行比较就需要对其进行转换,将DMTF字符串转DateT... 阅读全文
posted @ 2015-05-10 16:00 dongdonggeorge 阅读(673) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示