我想使用powershell腳本來計算代碼計數。如何在哈希表的末尾添加鍵/值對?
我在網絡中發現了一個腳本,並試圖在最後添加總行。
我已經添加了列
$ CountHash.Add( 「合計」,$總計)
末。
Param([string]$path,
[string]$outputFile,
[string]$include = "*.*",
[string]$exclude = "")
Clear-Host
$Files=Get-ChildItem -re -in $include -ex $exclude $path
[email protected]{}
$Total=0
Foreach ($File in $Files) {
#Write-Host "Counting $File.FullName"
$fileStats = Get-Content $File.FullName | Measure-Object -line
$linesInFile = $fileStats.Lines
$CountHash.Add($File.FullName,$linesInFile)
$Total += $linesInFile
}
$CountHash.Add("Total",$Total)
$CountHash
但是,當我顯示$ CountHash,它顯示在中間的「總計」鍵。通過在最後添加Add不能確保它在最後添加。
如何在哈希表的末尾添加鍵/值對?
更新:我將這個哈希表導出爲csv文件,但總行數在中間。
我已更新我的問題。對不起,我不只是顯示它 – Samselvaprabu 2012-08-08 10:24:57