如何使用 Select-Object 属性展开 power shell 命令中的所有字段 [英] How to use Select-Object property to expand all the fields in the power shell command

查看:64
本文介绍了如何使用 Select-Object 属性展开 power shell 命令中的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Get-ChildItem -Path E:\Server_Data\data\2015 -Recurse –File -include "*.txt","*.csv" | Where-Object {$_.Name -like "*transaction*"} | Select-Object -ExpandProperty FullName,LastWriteTime

我正在尝试使用 Get-ChildItemSelect-Object 属性列出文件夹中的所有文件.当我尝试使用 FullName 变量列出完全限定的文件名时,文件名被截断.尝试使用 -ExpandProperty 获取完全限定的文件名.它适用于一个字段,但如果我尝试同时列出 FullName 和 LastWriteTime,则它不起作用.

I'm trying to list all files in a folder using Get-ChildItem and Select-Object property. When I try to use FullName variable to list the fully qualified file name, the file name is getting truncated. Tried to use -ExpandProperty to get fully qualified file name. It works for one field but if I try to list both FullName and LastWriteTime, it's not working.

power shell 命令的输出将在 MS SQL Server 中用于将文件名加载到特定表中.

The output from the power shell command will be used in MS SQL Server to load the file names into a specific table.

请为我的目的建议正确的语法.感谢您的帮助!

Please suggest proper syntax for my purpose. Appreciate your help!

推荐答案

Get-ChildItem -Path E:\Server_Data\main.sweetbeam.net\data\2015 -Recurse –File -include "*.txt","*.csv" | Where-Object {$_.Name -like "*transaction*"} | Select-Object @{Name="test";Expression={$_.FullName + "`t" + $_.LastWriteTime}} | Select-Object -ExpandProperty test

合并这两个字段并根据我的目的使用派生字段.

Merged the two fields and used the derived field for my purpose.

这篇关于如何使用 Select-Object 属性展开 power shell 命令中的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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