【发布时间】:2020-07-23 04:13:45
【问题描述】:
以下脚本旨在收集 Exchange Online 的邮箱大小。
$Mailboxes = @('User1.name@domain.co.uk', 'user2.name@company.com') + GetEXOMailbox | Where-Object {$_.Name -like '*User*'}
$folderAndSubfolderSize = @{n='FolderAndSubfolderSize'; e={[math]::Round(($_.FolderAndSubfolderSize.Replace(',', '') -replace '.*?\((\d+)\s+bytes\)', '$1') / 1MB, 1)}}
$DisplayName = @{n='Display Name'; e='Identity'}
$Mailboxes | Get-EXOMailbox | Select-Object -ExpandProperty Name | ForEach-Object {
Write-Host "Processing $_ ..." -ForegroundColor Yellow
Get-EXOMailboxFolderStatistics -Identity $_ |
Where-Object {$_.Name -like "Top of Information Store"} |
Select-Object -Property $DisplayName, $folderAndSubfolderSize, ItemsInFolderAndSubfolders |
Where-Object {$_.FolderAndSubfolderSize -gt 1 }
} | Out-GridView
但是,下面的错误导致结果无法正常显示。
Get-EXOMailboxFolderStatistics : Identity is a mandatory value to provide for running Get-ExoMailboxFolderStatistics. You can specify identity by using either of the following
Identity, ExternalDirectoryObjectId, UserPrincipalName.
At line:6 char:2
+ Get-EXOMailboxFolderStatistics $_.Name |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ProtocolError: (:) [Get-EXOMailboxFolderStatistics], RestClientException
+ FullyQualifiedErrorId : Identity is a mandatory value to provide for running Get-ExoMailboxFolderStatistics. You can specify identity by using either of the following
Identity, ExternalDirectoryObjectId, UserPrincipalName.
,Microsoft.Exchange.Management.RestApiClient.GetExoMailboxFolderStatistics
我想知道如何解决这个问题?
【问题讨论】:
-
调用命令时使用
-identity参数。该文档没有提到任何参数都按位置编号接受值(您尝试的位置为 0)
标签: powershell powershell-remoting