Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell导出CSV但更改标题名称_Powershell_Get Childitem_Export Csv - Fatal编程技术网

Powershell导出CSV但更改标题名称

Powershell导出CSV但更改标题名称,powershell,get-childitem,export-csv,Powershell,Get Childitem,Export Csv,我肯定错过了一些非常简单的东西,但由于我在Powershell方面缺乏经验,所有可用的资源都是非常深入的答案 我有下面的代码,这是一个csv文件与目录的文件名,修改日期和创建日期。这是为了排除作为此目录子目录的某些文件路径 以下是我试图做的:在csv输出时,将LastWriteTime头和CreationTime头更改为不同的标记,即修改的时间或其他标记 我必须做什么来转换此代码以修改标题?我见过创建数组然后导出值的答案,但我觉得这是一个过于复杂的方法。更改csv标题最简单的方法是什么 Get-

我肯定错过了一些非常简单的东西,但由于我在Powershell方面缺乏经验,所有可用的资源都是非常深入的答案

我有下面的代码,这是一个csv文件与目录的文件名,修改日期和创建日期。这是为了排除作为此目录子目录的某些文件路径

以下是我试图做的:在csv输出时,将LastWriteTime头和CreationTime头更改为不同的标记,即修改的时间或其他标记

我必须做什么来转换此代码以修改标题?我见过创建数组然后导出值的答案,但我觉得这是一个过于复杂的方法。更改csv标题最简单的方法是什么

Get-ChildItem -path $pathlocation -recurse  |
 where {$_.fullname -notlike $PathsToExclude -and $_.PSIsContainer -eq $false} |
  Select-Object Name, LastWriteTime, CreationTime |
  Export-CSV -path $anotherpath -notypeinformation
当前csv标题显示>“名称”、“LastWriteTime”、“CreationTime”

我希望标题显示“文件”、“修改日期”、“上载日期”


提前谢谢你

解决方案使用选择对象作为表达式,例如:

Get-ChildItem -path $pathlocation -recurse |
 where {$_.fullname -notlike $PathsToExclude -and $_.PSIsContainer -eq $false} |
  Select-Object -Property @{Name = 'File'; Expression = {$_.Name}},@{Name = 'Modify Date'; Expression = {$_.LastWriteTime}},@{Name = 'Upload Date'; Expression = {$_.CreationTime}} |
  Export-CSV -path $anotherpath -notypeinformation

有关详细信息

请查看使用
选择对象
选择并更改所需的标题。非常感谢!我在使用封装的表达式时遇到了一些问题,但使用您的术语,我现在明白了我的错误所在。非常感谢