[英]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.