简体   繁体   English

在包含文件夹中所有文件的版本号的inPowesShell中创建.txt文件

[英]Create .txt file inPowesShell containing Version number for all files in folder

Good afternoon, 下午好,

Although I've been programming in VBA for 20 years, I'm on Week 2 with PowerShell, so please be patient! 尽管我已经在VBA中编程了20年,但是我正在使用PowerShell进行第2周的学习,所以请耐心等待!

I want to use a PowerShell script to create a txt file containing details for all .dll files greater than 15000 bytes within the specfied folder thus: 我想使用PowerShell脚本创建一个txt文件,其中包含指定文件夹内大于15000字节的所有.dll文件的详细信息:

$MySourceFolderName = "C:\PetesStuff\01 Backup"

$MyOutputFile = "C:\PSOutputA.txt"

get-childitem $MySourceFolderName -recurse |where-object {$_.length -gt 15000} | where-object {$_.extension -eq ".dll"} |
    sort-object -property Length -descending | Format-Table Name, Length -auto| Out-File -filepath  $MyOutputFile

So far, this works, but I also want to include the File version, which can't be accessed in the same way that Name and Length can. 到目前为止,这是可行的,但我还想包括文件版本,该版本不能以与名称和长度相同的方式访问。

Can anyone help me out, please? 有人可以帮我吗?

Thanks in advance 提前致谢

Pete 皮特

Ok, can do! 好,可以! What you want is Get-Command (I don't know why, but I do know it works). 您想要的是Get-Command(我不知道为什么,但是我知道它可以工作)。 We can put it in a little impromptu hash table in the Format-Table command. 我们可以将其放在Format-Table命令中的即席哈希表中。 Also, I'm going to move the second Where statement to a -filter so the provider filters that for you, and toss in some aliases because this is such a very long line. 另外,我将第二条Where语句移至-filter,以便提供程序为您过滤该语句,并输入一些别名,因为这行很长。

GCI $MySourceFolderName -recurse -Filter "*.dll" | ?{$_.length -gt 15000} | sort -property Length -descending |
    FT Name, Length, @{l="File Version";e={(Get-Command $_.FullName).FileVersionInfo.FileVersion}} -auto| Out-File -filepath  $MyOutputFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 列出文件夹中最大行数的.txt文件(文件),然后列出最小行数的txt文件(文件) - List .txt file (files) with maximum number of lines in a folder and then txt file (files) with minimum number of lines 根据文件内容重命名文件夹中的所有txt文件 - Rename all txt files in a folder based on file content 使用 PowerShell 脚本根据 txt 文件中的文件/文件夹结构移动所有位于一个文件夹中的文件 - Move files that are all in one folder based on file/folder structure in txt file using PowerShell script 创建文本文件,其中包含特定类型的所有文件及其文件大小的列表 - Create text file containing a list of all files of a certain type with their filesize 如何使用Powershell获取文件夹中所有文件夹名称而不是子文件夹中文件/子文件夹的.txt文件? - How to get a .txt file of all folders names inside a folder but not the files/subfolders inside the child folders using powershell? 从2个txt文件创建导入文件 - Create import file from 2 txt files powershell 基于 csv 文件创建 txt 文件 - powershell create txt files based on csv file 如何将文件夹中的所有文件输出到一个文件 - How to output all files in a folder to a file 将所有文件重命名为.txt - RENAME ALL FILES TO .txt 在 PowerShell 列表中创建一个 txt 文件,列出所有正在运行的服务 - create a txt file in PowerShell list of all running services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM