---Exchange 2019 use command:
--- 查询邮件组中用户邮箱大小,并按大小排序,导出到CSV文件
Get-Mailbox -ResultSize Unlimited | select DisplayName,PrimarySmtpAddress,@{label="TotalItemSize";expression={(Get-MailboxStatistics $_.Name).TotalItemSize}} | Sort-Object TotalItemSize -Descending | select -first 40 | export-csv c:\106390excuser.csv -NoTypeInformation
---查看版本信息
PS C:> $PSVersionTable
Name Value
PSVersion 5.1.17763.5122
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.5122
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
---查看作用域权限---
PS C:\Users\administrator.RECODEAL> Get-ExecutionPolicy -List
Scope ExecutionPolicy
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
解释:
权限问题。Powershell脚本的4种执行权限介绍,Windows默认不允许任何脚本运行,我们可以使用"Set-ExecutionPolicy"cmdlet来改变的PowerShell环境,共有4种运行权限:
Restricted——默认的设置, 不允许任何script运行
AllSigned——只能运行经过数字证书签名的script
RemoteSigned——运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名
Unrestricted——允许所有的script运行
---增加权限---
PS C:\Users\administrator.RECODEAL> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
PS C:\Users\administrator.RECODEAL> Set-ExecutionPolicy RemoteSigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): Y
--查看历史命令位置
PS C:\windows\system32> Get-PSReadLineOption
EditMode : Windows
AddToHistoryHandler :
HistoryNoDuplicates : True
HistorySavePath : C:\Users\administrator.group\AppData\Roaming\Microsoft\Windows\PowerShell\P
SReadLine\ConsoleHost_history.txt
HistorySaveStyle : SaveIncrementally
HistorySearchCaseSensitive : False
HistorySearchCursorMovesToEnd : False
Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | % { Get-MailboxFolderStatistics $ .UserPrincipalName -FolderScope Calendar | ? {$.FolderType -eq "Calendar"} | select Identity,ItemsInFolder,FolderSize } | Export-CSV -nti c:\106390excuser.csv
$Mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited
$data = @()
foreach($mailbox in $mailboxes){
$data+=Get-MailboxFolderStatistics $mailbox.UserPrincipalName -FolderScope Calendar| where{$_.FolderType -eq "Calendar"} | select Identity,FolderSize
Start-Sleep -s 1
}
$data | Export-Csv C:\106390excuser2.csv -NoTypeInformation
---2019 before command:
---查看用户邮箱的使用量
[PS] C:\Windows\system32>Get-MailboxStatistics | Sort TotalItemSize
位于命令管道位置 1 的 cmdlet Get-MailboxStatistics
请为以下参数提供值:
Identity: yunpeng.li
DisplayName ItemCount StorageLimitStatus LastLogonTime
skypeng Lee 492 2024/8/15 10:38:12
[PS] C:\Windows\system32>Get-MailboxStatistics | Sort TotalItemSize | ft DisplayName,ItemCount,TotalItemSize
位于命令管道位置 1 的 cmdlet Get-MailboxStatistics
请为以下参数提供值:
Identity: skypeng.lee
DisplayName ItemCount TotalItemSize
skypeng Lee 492 125.9 MB (132,053,699 bytes)
[PS] C:\Windows\system32>Get-MailboxStatistics -Identity yunpeng.li | fl
RunspaceId : 4426da6c-fac4-4b99-ac18-97e899ffe89d
MoveHistory :
AssociatedItemCount : 43
DeletedItemCount : 14
ItemCount : 492
TotalDeletedItemSize : 2.448 MB (2,566,614 bytes)
TotalItemSize : 125.9 MB (132,053,699 bytes)
MessageTableTotalSize : 5.281 MB (5,537,792 bytes)
MessageTableAvailableSize : 832 KB (851,968 bytes)
AttachmentTableTotalSize : 126.3 MB (132,481,024 bytes)
AttachmentTableAvailableSize : 3.906 MB (4,096,000 bytes)
OtherTablesTotalSize : 1.719 MB (1,802,240 bytes)
OtherTablesAvailableSize : 384 KB (393,216 bytes)
IsEncrypted : False
DataEncryptionPolicyId :
KeyVersionIDs :
AdvancedDataEncryptionDetails :
CurrentSchemaVersion : 0.185
DisconnectDate :
DisconnectReason :
DisplayName : Yunpeng Li
LastLoggedOnUserAccount :
LastLogoffTime : 2024/8/15 10:43:27
LastLogonTime : 2024/8/15 10:38:12
LegacyDN : /o=Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=usera06225b5
MailboxGuid : 2d01ad46-eeb5-40a9-9a47-64c32be67a8d
OwnerADGuid : 318ceaca-c79c-47d4-9c18-1205eee5a9a2
MailboxType : Private
MailboxTypeDetail : UserMailbox
ObjectClass : Unknown
StorageLimitStatus :
MailboxTableIdentifier :
Database : DB4
ServerName : EXCHANGE02
DatabaseName : DB4
IsDatabaseCopyActive : True
IsClutterEnabled : False
IsQuarantined : False
QuarantineDescription :
QuarantineLastCrash :
QuarantineEnd :
QuarantineFileVersion :
IsAbandonedMoveDestination : False
ExternalDirectoryOrganizationId : 00000000-0000-0000-0000-000000000000
IsArchiveMailbox : False
IsMoveDestination : False
MailboxMessagesPerFolderCountWarningQuota :
MailboxMessagesPerFolderCountReceiveQuota :
DumpsterMessagesPerFolderCountWarningQuota :
DumpsterMessagesPerFolderCountReceiveQuota :
FolderHierarchyChildrenCountWarningQuota :
FolderHierarchyChildrenCountReceiveQuota :
FolderHierarchyDepthWarningQuota :
FolderHierarchyDepthReceiveQuota :
FoldersCountWarningQuota :
FoldersCountReceiveQuota :
NamedPropertiesCountQuota : 16384
SystemMessageSize : 0 B (0 bytes)
SystemMessageCount : 0
SystemMessageSizeWarningQuota : 21.56 GB (23,149,873,725 bytes)
SystemMessageSizeShutoffQuota : 22 GB (23,622,320,128 bytes)
FastIsEnabled : False
BigFunnelIsEnabled : True
BigFunnelMaintainRefiners : True
BigFunnelFilterTableTotalSize : 288 KB (294,912 bytes)
BigFunnelFilterTableAvailableSize : 32 KB (32,768 bytes)
BigFunnelPostingListTableTotalSize : 0 B (0 bytes)
BigFunnelPostingListTableAvailableSize : 0 B (0 bytes)
BigFunnelLargePOITableTotalSize : 1.063 MB (1,114,112 bytes)
BigFunnelLargePOITableAvailableSize : 320 KB (327,680 bytes)
BigFunnelTotalPOISize : 716.1 KB (733,334 bytes)
BigFunnelMessageCount : 210
BigFunnelIndexedSize : 93.89 MB (98,448,981 bytes)
BigFunnelPartiallyIndexedSize : 33.76 MB (35,395,883 bytes)
BigFunnelNotIndexedSize : Unlimited
BigFunnelCorruptedSize : 0 B (0 bytes)
BigFunnelStaleSize : Unlimited
BigFunnelShouldNotBeIndexedSize : 756.6 KB (774,765 bytes)
BigFunnelIndexedCount : 157
BigFunnelPartiallyIndexedCount : 53
BigFunnelNotIndexedCount : 0
BigFunnelCorruptedCount : 0
BigFunnelStaleCount : 0
BigFunnelShouldNotBeIndexedCount : 341
BigFunnelMailboxCreationVersion : 0
DatabaseIssueWarningQuota : Unlimited
DatabaseProhibitSendQuota : Unlimited
DatabaseProhibitSendReceiveQuota : Unlimited
ResourceUsageRollingAvgRop :
ResourceUsageRollingClientTypes :
NeedsToMove : None
MCDBMessageTableTotalSize :
MCDBMessageTableAvailableSize :
MCDBMessageTablePercentReplicated :
MCDBOtherTablesTotalSize :
MCDBOtherTablesAvailableSize :
MCDBBigFunnelFilterTableTotalSize :
MCDBBigFunnelFilterTableAvailableSize :
MCDBBigFunnelFilterTablePercentReplicated :
MCDBBigFunnelLargePOITableTotalSize :
MCDBBigFunnelLargePOITableAvailableSize :
MCDBBigFunnelLargePOITablePercentReplicated :
MCDBBigFunnelPostingListTableTotalSize :
MCDBBigFunnelPostingListTableAvailableSize :
MCDBBigFunnelPostingListTablePercentReplicated :
Identity : 2d01ad46-eeb5-40a9-9a47-64c32be67a8d
MapiIdentity : 2d01ad46-eeb5-40a9-9a47-64c32be67a8d
OriginatingServer : exchange02.xxcngroup.com
IsValid : True
ObjectState : Unchanged
[PS] C:\Windows\system32>