[英]List .txt file (files) with maximum number of lines in a folder and then txt file (files) with minimum number of lines
[英]Create .txt file inPowesShell containing Version number for all files in folder
下午好,
盡管我已經在VBA中編程了20年,但是我正在使用PowerShell進行第2周的學習,所以請耐心等待!
我想使用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
到目前為止,這是可行的,但我還想包括文件版本,該版本不能以與名稱和長度相同的方式訪問。
有人可以幫我嗎?
提前致謝
皮特
好,可以! 您想要的是Get-Command(我不知道為什么,但是我知道它可以工作)。 我們可以將其放在Format-Table命令中的即席哈希表中。 另外,我將第二條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.