按月将Windows日志导出至CSV文件

# 这个月的第一天
#..........................................到这里之前是取当年第一天
#(Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month - 2)
# 这个月的最后一天
#......................................................................到这里之前是次年第一天
#(Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month - 1).AddDays(-1)

$lognames = "Application","Security","System"
$lastmonthfirstday = (Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month - 2)
$lastmonthlastday = (Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month - 1).AddDays(-1)
foreach($logname in $lognames) {
    Get-EventLog -ComputerName $env:COMPUTERNAME -LogName $logname -After $lastmonthfirstday -Before $lastmonthlastday | Export-Csv -Path ("C:\EventLog\" + $lastmonthfirstday.Year + "_" + $lastmonthfirstday.Month + "_" + $env:COMPUTERNAME + "_" + $logname + ".CSV")
}
时间: 2024-08-08 09:37:31

按月将Windows日志导出至CSV文件的相关文章

oracle导出多CSV文件的靠谱的

oracle导出多CSV文件的问题 ---------------------------------------------------------------------- 用ksh脚本从oracle数据库中导出80w数据到csv文件,如用户给定名字为a.csv(文件最大4000行记录),则自动生产文件为a_1.csv,a_2.csv,...., a_200.csv 我已经实现了一个方法,但80w要导5小时,用户没法接受.如下: sqlplus -s user/pwd @${SqlDir}/

原创 Datareader 导出为csv文件方法

DataReader 是游标只读数据, 如果是大数据导出,用Datatable 将耗费巨大内存资源.因为Datatable 其实就是内存中的一个数据表 代码如下 /// <summary> /// SqlDataReader 生成csv文件 /// </summary> /// <param name="fileNameCsv">文件名(包含文件路径)</param> /// <param name="dr"&g

淘宝助理导出的csv文件使用的是什么编码,您猜?

今天下午用Java读取从淘宝助理 V4.3 Beta1导出的csv文件,出现中文乱码情况. 一看就是文件编码引起的,不清楚淘宝助理导出的csv文件使用了什么编码,到百度搜索了一下,看到一些相关文章,但测试发现都没有解决这个问题. 最后,我抱着试试看的态度,使用了 utf-16 ,我晕,正常显示中文了. 关于 utf-16 这种编码,这么多看来我还是第一次使用,之前最常用的是 gb2312 和 utf-8 之间的转换. 下面是一个简单的例子: try { DataInputStream in =

R: 导入 csv 文件,导出到csv文件,;绘图后导出为图片、pdf等

################################################### 问题:导入 csv 文件 如何从csv文件中导入数据,?参数怎么设置?常用参数模板是啥? 解决方案: yuan <- read.csv(file = "C:/Users/Administrator/Desktop/test1.csv",header = TRUE,sep = ",",dec = ".", stringsAsFactors

es实战之数据导出成csv文件

从es将数据导出分两步: 查询大量数据 将数据生成文件并下载 本篇主要是将第二步,第一步在<es实战之查询大量数据>中已讲述. csv vs excel excel2003不能超过65536, excel2007及以上版本支持1048576条数据.excel支持的数据量有限,并且生生成文件的速度比较慢. csv具有支持写入量大,文件较小的优点. 故选择csv作为导出文件类型. 导出文件的几种方式: 将数据从es中查询出来,在这个大前提下,对比导出文件的速度. 由前端处理 直接将数据返回给前端,

Vue之将前端的筛选结果导出为csv文件

有导入就有导出哈!这里继导入之后记录一下导出的实现过程. 1.按钮部分: <el-button class="filter-item" style="margin-left: 10px;" type="success" native-type="submit" @click="exportAll()" icon="el-icon-plus"> 导出 </el-butto

2017年4月8日Office 365 使用CSV文件导入邮件组

国内版 第一步: Import-Module msonline Connect-MsolService 输入用户名密码 第二步: Get-MsolUser" 第三步: Set-ExecutionPolicy unrestricted $cred = Get-Credential $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/Power

Postgresql 将查询结果导出至csv文件

1.将查询结果导入某张表 create table file1( a integer, b character(5) ); insert into file1(a,b) select a,b from view 2.导出 导出之前为防止中文乱码,设置一下数据库编码 set client_encoding='GBK'; 使用copy 命令 执行命令copy file1to '/home/file.csv' with csv header;

DataTable内容导出为CSV文件

CSVHelper.cs内容: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Web; 6 using System.Threading; 7 using System.IO; 8 using System.Data; 9 using System.Windows.Forms; 10 11 namespace IMSCommo