0
我試圖輸出PowerShell的結果通過使用下面的代碼到HTML文件:PowerShell的Converto的HTML格式風格
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white}"
$a = $a + "</style>"
Get-item c:\work | select-object Name,Lastwritetime,@{label="Size" ; expression={[math]::round(((Get-childitem -force "c:\work" -recurse | measure-object length -sum).sum/1Gb),1)}}
get-childitem .....| Convertto-html -head $a | Out-File -append C:\temp\backup.htm
....
....
HTML文件的結果看起來是這樣的:
所以我的問題是:
如何在頂部只有一個Name LastTime Size
行以及如何修復窗體的長度?
感謝提示,會有超過50行'get-childitem',如何將em變成單個變量?或者最好使用數組?對不起,我沒有太多的PowerShell的經驗 –
爲什麼你需要這麼多獨立的Get-ChildItem行?展示其中的一些 - 有可能以更簡單的方式獲得所需的一切。 – KevinD
如果您確實需要對Get-ChildItem進行單獨調用,您可以執行如下操作: $ items = Get-ChildItem ...; $ items + = Get-ChildItem ...; $ items + = Get-ChildItem ...; – RickH