2015-10-13 32 views
0

我正在使用powershell,但我有點新 所以我的問題是,我有一個文件夾充滿msi包。如果我去屬性 - >詳細信息,可以在評論部分找到描述。由於我不想單擊一切,我想用powershell列出它們。Powershell:Get-Childitem,有沒有辦法列出註釋?

Here's a Picture of the value I need

到目前爲止,我得到這個:

get-childitem c:\windows\installer\* -include *.msi 

我不能找到一個解決方案,我很感謝任何幫助。

+0

我發現[C++源(HTTP://prop.codeplex .com /)列出它們,但不是從PowerShell執行相同操作的令人滿意的方式。哎呀,甚至沒有發現VBScript這樣做,這可以轉換爲PowerShell。但是,您可以使用該程序獲取詳細信息並解析PowerShell的輸出。有點複雜,並不理想,但應該工作。如果你事先知道你想要的屬性,它甚至會有CSV輸出。 – Joey

回答

2

這個心不是我的解決方案我只是將其粘貼在這裏從這個link

下面是一些示例代碼:

http://powershell.com/cs/blogs/tobias/archive/2011/01/07/organizing-videos-and-music.aspx

假設你有一個視頻文件:C:\ video.wmv

$path = 'C:\video.wmv' 
$shell = New-Object -COMObject Shell.Application 
$folder = Split-Path $path 
$file = Split-Path $path -Leaf 
$shellfolder = $shell.Namespace($folder) 
$shellfile = $shellfolder.ParseName($file) 

您需要知道什麼是擴展屬性的ID。這將顯示所有的ID:

0..287 | Foreach-Object { '{0} = {1}' -f $_, $shellfolder.GetDetailsOf($null, $_) } 

一旦你找到你想要的,你可以這樣訪問它的一個:

$shellfolder.GetDetailsOf($shellfile, 216) 
+1

你可以在technet上檢查[get-filemetadata script](https://gallery.technet.microsoft.com/scriptcenter/get-file-meta-data-function-f9e8d804#content) –

+0

是的,我認爲這可能是OP想要什麼。 thx爲鏈接@Kayasax – Kiran

+0

哇保佑你! 這是我可以使用的東西。 – Shadowjerk

相關問題