2016-11-11 4 views
0

私は完全なメールボックスアクセスを持つすべてのユーザーの一覧を取得するためにPowerShellスクリプトを使用しており、1つのオブジェクト単位で制限する必要があります。しかし、私自身の変更は、正しい結果をもたらすことはなかった、スクリプトがまだすべてのユーザーで実行されている:オブジェクト単位で実行パイプラインを制限する

Get-Mailbox -ResultSize Unlimited | 
    Get-MailboxPermission | 
    where {$_.OrganizationalUnit -eq “Contoso.com/Users/test/" -and $_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | 
    Select -first 1 | 
    Select Identity,User,@{Name='Access Rights';Expression={[string]::join(', ', $_.AccessRights)}} | 
    Export-Csv -NoTypeInformation \\sharename\mailboxpermissions.csv 
+0

「1つのオブジェクト単位」は何を意味しますか? – 4c74356b41

+0

Active Directoryの通常のオブジェクト単位です。すべてのメールボックスがExchange上にあるわけではありません。 –

答えて

0

ちょうどあなたが1つのオブジェクトのみを選択し、別のselectを追加します-organizationalUnitフィルタを使用します。したがって、コードは次のようになります。

Get-Mailbox -ResultSize Unlimited -organizationalUnit "ou=Users,ou=City,ou=county,dc=domain,dc=com" | Get-MailboxPermission | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | Select Identity,User,@{Name='Access Rights';Expression={[string]::join(', ', $_.AccessRights)}} | Export-Csv -NoTypeInformation \\sharename\mailboxpermissions.csv 
+0

こんにちはマーティン、あなたの答えに感謝します。コードを試しましたが、スクリプトがすべてのメールボックスで実行されていることが確認されました。 –

+0

あなたはCSVをチェックしましたか? –

+0

csvは空で、長い時間が経ってからスクリプトがエラーで壊れてしまい、powershellプロセスが約5Gbのメモリを必要とするため、これは驚くべきことではありません! –

0

最後に、問題が解決されました:

Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | 
where {$_.OrganizationalUnit -eq “Contoso.com/Users/test/" -and $_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | 
Select Identity,User,@{Name='Access Rights';Expression={[string]::join(', ', $_.AccessRights)}} | 
Export-Csv -NoTypeInformation \\sharename\mailboxpermissions.csv 
関連する問題