我想在从powershell脚本运行的DataGridView中显示输出:
$domain1Groups = (Get-ADuser -identity $var_userName.Text -server domain1 -Properties MemberOf).MemberOf -Replace 'CN=', '' -Replace ',.*', ''
$domain2Groups = (Get-ADuser -identity $var_userName.Text -server domain2 -Properties MemberOf).MemberOf -Replace 'CN=', '' -Replace ',.*', ''
$domain3Groups = (Get-ADuser -identity $var_userName.Text -server domain3 -Properties MemberOf).MemberOf -Replace 'CN=', '' -Replace ',.*', ''
使用这个脚本,我在powershell中得到一个列表,其中1列包含该域的所有成员。
尝试使用.ItemsSource,但在DataGridView中看不到任何内容
$var_comboBox.Add_SelectionChanged({
$item = $var_comboBox.SelectedItem.Content
if ($item -eq "domain1")
{$var_DataGridView.ItemsSource = $domain1Groups
}elseif
($item -eq "domain2" )
{$var_DataGridView.ItemsSource = "$domain2Groups"
}
else{
($item -eq "domain3" )
$var_DataGridView.ItemSource = "$domain3Groups"
}})
I also want a customized Column that displays the text "Member Of"
1条答案
按热度按时间mcvgt66p1#
如果像这样定义
DataGrid
:...您应该能够如下设置
ItemsSource
属性: