尝试锻炼为什么以下功能(从GUI按钮执行)不会将所有输出放在GUI列表视图中的同一行上。函数中的每个命令都将输出一行放在上一个命令的列表视图中。尝试管道命令,变量和数组没有成功。
Function Get-MailboxSizeQuotasTool {
Get-Mailbox $WPFinputbox.Text |
Select-Object @{Name='Display Name';Expression={$_.DisplayName}},
@{Name='Prohibit Send Quota';Expression={$_.ProhibitSendQuota}},
@{Name='Use Database Defaults';Expression={$_.UseDatabaseQuotaDefaults}},
@{Name='Archive Quota';Expression={$_.ArchiveQuota}}
Get-MailboxStatistics $WPFinputbox.Text |
Select-Object @{Name='Mailbox Size';Expression={$_.TotalItemSize}}
Get-MailboxStatistics $WPFinputbox.Text -Archive |
Select-Object @{Name='Archive Size';Expression={$_.TotalItemSize}}
}
$WPFokbutton.Add_Click({
$WPFlist.Items.Clear()
Start-Sleep -Milliseconds 840
Get-MailboxSizeQuotasTool -Identity $WPFinputbox.Text |
% {$WPFlist.AddChild($_)}
})
答案 0 :(得分:1)
您的函数输出3个具有不同属性的不同对象。您需要在单个对象中合并信息:
Function Get-MailboxSizeQuotasTool {
$mailbox = Get-Mailbox $WPFinputbox.Text
New-Object -Type PSObject -Property @{
'Display Name' = $mailbox.DisplayName
'Prohibit Send Quota' = $mailbox.ProhibitSendQuota
'Use Database Defaults' = $mailbox.UseDatabaseQuotaDefaults
'Archive Quota' = $mailbox.ArchiveQuota
'Mailbox Size' = Get-MailboxStatistics $WPFinputbox.Text |
Select-Object -Expand TotalItemSize
'Archive Size' = Get-MailboxStatistics $WPFinputbox.Text -Archive |
Select-Object -Expand TotalItemSize
}
}