我不是一個專家,所以我希望有人能指出我在正確的方向,我正在寫一個小腳本,通過Powershell從AD森林中收集信息並保存所有內容一個HTML表 -PowerShell添加成員和html表格
我的問題是用表格式是其不作爲我希望表格標題更具體的,這裏是我的HTML創建/ fromat表
$htmlhead = "<html>
<style>
BODY{font-family: Verdana; font-size: 10pt;}
H1{font-size: 20px;}
H2{font-size: 18px;}
H3{font-size: 16px;}
TABLE{border: 1px solid black; border-collapse: collapse; font-size: 10pt;}
TH{border: 1px solid black; background: #dddddd; padding: 5px; color: #000000;}
TD{border: 1px solid black; padding: 5px; }
td.pass{background: #7FFF00;}
td.warn{background: #FFE600;}
td.fail{background: #FF0000; color: #ffffff;}
td.info{background: #85D4FF;}
</style>
<body>
<h1 align=""center"">Active Directory Inventory Information</h1>
<h3 align=""center"">Generated: $reportDate</h3>"
雖然片段的PowerShell代碼如下
$adForest = Get-ADForest
$adForestInfo = New-Object -TypeName PsObject
$htmlBody += '<h3>Forest Details</h3>'
$adForestInfo | Add-Member -MemberType NoteProperty -Name 'Forest Name' -Value $($adForest.Name)
$adForestInfo | Add-Member -MemberType NoteProperty -Name 'Site' -Value $($adForest.Sites)
$htmlBody += $adForestInfo | ConvertTo-Html
如果我使用上面的代碼全部是好的,我有一個表森林和森林模式作爲一個頭,但如果我只用一個屬性這樣
$adForestInfo | Add-Member -MemberType NoteProperty -Name 'Forest Name' -Value $($adForest.Name)
我得到一個*代替無論我通過添加成員分配的任何屬性名稱,我不確定我在這裏做錯了什麼,並且任何幫助都將被真正地預設。
對不起,如果問題很愚蠢,但我想學習,所以最有可能我忽略了一些非常簡單的事情。
馬特,你救了我的一天:-)我真的很瘋狂,因爲我不能發現任何明顯的錯誤,但作爲boobie我都是可能的,我已經使用了這種方法,並且像魅力一樣工作! 非常感謝我給你一個upvote,但作爲我的第一篇文章,我懷疑它會出現。 – Clariollo