0
我想顯示幾個Windows服務的狀態爲System.Windows.Forms.PropertyGrid。在Powershell中使用自定義PSObjects創建PropertyGrid?
我嘗試使用,而不是的selectedObjectsSelectedObject,但我想不出如何修復輸出。
$certificate = (Get-ChildItem cert:\LocalMachine\My\ -ErrorAction SilentlyContinue).Subject
$hostname = New-Object PSObject
$hostname | Add-Member Noteproperty sName "Hostname"
$hostname | Add-Member Noteproperty sValue (hostname)
$hostname | Add-Member Noteproperty sReadOnly $True
$cert = New-Object PSObject
$cert | Add-Member Noteproperty sName "Certificate"
$cert | Add-Member Noteproperty sValue ($certificate -imatch $hostname.sValue)
$dot3sv = New-Object PSObject
$dot3sv | Add-Member Noteproperty sName "Dot3svService"
$dot3sv | Add-Member Noteproperty sValue ((Get-Service -Name dot3svc).Status -eq "Running")
$eap = New-Object PSObject
$eap | Add-Member Noteproperty sName "EAPService"
$eap | Add-Member Noteproperty sValue ((Get-Service -Name EapHost).Status -eq "Running")
$PropertyGrid1 = New-Object System.Windows.Forms.PropertyGrid
$PropertyGrid1.Dock = [System.Windows.Forms.DockStyle]::Fill
$PropertyGrid1.SelectedObjects = @($cert, $dot3sv, $eap)
這是我目前的形式輸出:
[+] Default Text I'd like to change
[0] | @{sName="Certificate",sValue=True}
[1] | @{sName="Dot3svService",sValue=True}
[2] | @{sName="EAPService",sValue=True}
我怎樣可以得到下面的顯示?
[+] Status
Certificate | True
Dot3svService | True
EAPService | True
感謝您的意見!
完美!謝謝! _Out-GridView_ [here](http://technet.microsoft.com/zh-cn/library/ff730930.aspx)上的更多詳細信息 – Franquis