0
我有以下PowerShell腳本中,我可以運行從Office 365分離多個結果到不同的線路
$Results = @()
$MailboxUsers = get-mailbox -resultsize unlimited
$Statistics = $MailboxUsers | Get-MailboxStatistics | select *
$Licenses = Get-MsolUser | select *
$Permissions = $MailboxUsers | Get-MailboxPermission | select *
foreach($user in $mailboxusers)
{
$UPN = $user.userprincipalname
$Properties = @{
Name = $user.name
UPN = $UPN
Alias = $user.alias
RecipientTypeDetails = $user.RecipientTypeDetails
Identity = ($Permissions | where {$_.Identity -eq ($user).DisplayName}).Identity
User = ($Permissions | where {$_.Identity -eq ($user).DisplayName}).User
AccessRights = ($Permissions | where {$_.Identity -eq ($user).DisplayName}).AccessRights
IsInherited = ($Permissions | where {$_.Identity -eq ($user).DisplayName}).IsInherited
Deny = ($Permissions | where {$_.Identity -eq ($user).DisplayName}).Deny
IsLicensed = ($Licenses | where {$_.UserPrincipalName -eq ($user).UserPrincipalName}).IsLicensed
TotalItemSize = ($Statistics | where {$_.DisplayName -eq ($user).DisplayName}).TotalItemSize
ItemCount = ($Statistics | where {$_.DisplayName -eq ($user).DisplayName}).ItemCount
License = ($Licenses | where {$_.UserPrincipalName -eq ($user).UserPrincipalName}).Licenses.AccountSkuId
}
$Results += New-Object psobject -Property $properties
}
$results | sort name | fl
但是獲得良好的混合報告,當我運行此,5個對象身份, 用戶,AccessRights,IsInherited和拒絕都示出混合到相同的輸出多個結果。
即使我最後一行改成這樣:
$results | sort name | Out-GridView
這也顯示了相同的5個對象身份,用戶,AccessRights,IsInherited和拒絕都聚集在一起。
我所尋找的是分離的5個對象身份,用戶,AccessRights,IsInherited和拒絕到不同的線路,併爲其餘對象,只是重複例如名稱,UPN,許可,將RecipientTypeDetails,TotalItemSize,別名,IsLicensed和ItemCount中將每個結果旁邊被重複在5個對象身份,用戶,AccessRights,IsInherited and Deny。
這樣我可以做更多的事情與輸出,把它放入Excel例如,並按摩結果。