2016-04-01 23 views
0

ile birlikte csv'deki tüm işletim sistemlerini bir sistemdeki tüm dosyalarda dolaşan ve her satırda bir dosya içeren bir metin dosyası çalıştırmaya çalışıyorum. İsim, dizin, boyut, sürüm ve son değiştirilme ihtiyacım var. Bu kod aşağıda Version 5'de çalışıyor (bu erişim engellendi eğer hata verir) ... ama sürüm 2 .... her satırı ararpowershell, sürüm

Get-ChildItem -Path . -Recurse | 
    foreach-object { 
     [pscustomobject]@{ 
      Name = $_.fullname; 
      DateModified = $_.LastWriteTime; 
      Version = $_.VersionInfo.FileVersion; 
      Length = $_.length; 
     } 
    } | Export-Csv -Path "c:\workingfiles\post.csv" -NoTypeInformation 

gibi:

"False","False","False","System.Collections.Hashtable+KeyCollection","System.Collections.Hashtable+ValueCollection","System.Object","4" 

2. versiyonda ihtiyacım olanı nasıl alabilirim? (Yükseltmek mümkün değildir)

-ken

cevap

1

yerine pscustomobject için hashtable döküm, New-Object -Property çağırır:

Get-ChildItem -Path . -Recurse |ForEach-Object { 
    New-Object psobject -Property @{ 
     Name = $_.FullName; 
     DateModified = $_.LastWriteTime; 
     Version = $_.VersionInfo.FileVersion; 
     Length = $_.Length; 
    } 
} | Export-Csv -Path "c:\workingfiles\post.csv" -NoTypeInformation