How do I pipeline the output of Exchange 2010's Get-MoveRequest
command so that the Name
variable can be used in the $Username variable below?
[CmdletBinding(DefaultParameterSetName = "MoveUser")]
param(
[Parameter(Mandatory = $true, ParameterSetName = "MoveUser", ValueFromPipeline = $true, Position = 0)]
$Username
)
function Get-MBStats($Username )
{
$req = Get-MailboxStatistics -Identity $Username -IncludeMoveHistory
$UserDetail = ($req).MoveHistory[0]
# TODO: SOME CUSTOM STUFF HERE #
New-Object PSObject -Property @{
Username = $Username
Status = $UserDetail.Status
TargetDatabase = $UserDetail.TargetDatabase
CompletionTime = $UserDetail.CompletionTimestamp
MailboxSizeKB = $UserDetail.TotalMailboxSize.ToKB()
DurationSec = $UserDetail.TotalInProgressDuration.TotalSeconds
BadItems = $UserDetail.BadItemsEncountered
}
# Todo: GUI http://msdn.microsoft.com/en-us/magazine/hh288074.aspx #
}
Get-MBStats($Username)
UPDATE
Here are the members output from MoveRequest (source)
TypeName: Microsoft.Exchange.Management.RecipientTasks.MoveRequest
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetProperties Method System.Object[] GetProperties(System.Collections.Generic.ICollection[Microso...
GetType Method type GetType()
ToString Method string ToString()
Validate Method Microsoft.Exchange.Data.ValidationError[] Validate()
PSComputerName NoteProperty System.String PSComputerName=nycexhc01.nfp.com
RunspaceId NoteProperty System.Guid RunspaceId=dc444c7e-bcac-4c1c-8fdf-847875456c03
Alias Property System.String Alias {get;set;}
BatchName Property System.String BatchName {get;}
Direction Property Microsoft.Exchange.MailboxReplicationService.RequestDirection Direction {get;}
DisplayName Property System.String DisplayName {get;set;}
DistinguishedName Property System.String DistinguishedName {get;}
ExchangeGuid Property System.Guid ExchangeGuid {get;}
ExchangeVersion Property Microsoft.Exchange.Data.ExchangeObjectVersion ExchangeVersion {get;}
ExternalDirectoryObjectId Property System.String ExternalDirectoryObjectId {get;}
Flags Property Microsoft.Exchange.Data.Directory.Recipient.RequestFlags Flags {get;}
Guid Property System.Guid Guid {get;}
Identity Property Microsoft.Exchange.Data.ObjectId Identity {get;}
IsOffline Property System.Boolean IsOffline {get;}
IsValid Property System.Boolean IsValid {get;}
LastExchangeChangedTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutr...
Name Property System.String Name {get;set;}
OrganizationId Property Microsoft.Exchange.Data.Directory.OrganizationId OrganizationId {get;}
OriginatingServer Property System.String OriginatingServer {get;}
Protect Property System.Boolean Protect {get;}
RecipientType Property Microsoft.Exchange.Data.Directory.Recipient.RecipientType RecipientType {get;}
RecipientTypeDetails Property Microsoft.Exchange.Data.Directory.Recipient.RecipientTypeDetails RecipientTy...
RemoteHostName Property System.String RemoteHostName {get;}
RequestStyle Property Microsoft.Exchange.MailboxReplicationService.RequestStyle RequestStyle {get;}
SourceArchiveDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId SourceArchiveDatabase {get;}
SourceDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId SourceDatabase {get;}
Status Property Microsoft.Exchange.Data.Directory.Recipient.RequestStatus Status {get;}
Suspend Property System.Boolean Suspend {get;}
SuspendWhenReadyToComplete Property System.Boolean SuspendWhenReadyToComplete {get;}
TargetArchiveDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId TargetArchiveDatabase {get;}
TargetDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId TargetDatabase {get;}
Here are the members of the target
TypeName: Microsoft.Exchange.Data.Mapi.MailboxStatistics
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
Dispose Method System.Void Dispose()
Equals Method bool Equals(System.Object obj)
GetDisposeTracker Method Microsoft.Exchange.Diagnostics.DisposeTracker GetDisposeTracker()
GetHashCode Method int GetHashCode()
GetProperties Method System.Object[] GetProperties(System.Collections.Generic.ICollection[Microsoft....
GetType Method type GetType()
SuppressDisposeTracker Method System.Void SuppressDisposeTracker()
ToString Method string ToString()
Validate Method Microsoft.Exchange.Data.ValidationError[] Validate()
PSComputerName NoteProperty System.String PSComputerName=nycexhc01.nfp.com
RunspaceId NoteProperty System.Guid RunspaceId=dc444c7e-bcac-4c1c-8fdf-847875456c03
AssociatedItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
Database Property Microsoft.Exc开发者_如何转开发hange.Data.ObjectId Database {get;}
DatabaseName Property System.String DatabaseName {get;}
DeletedItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
DisconnectDate Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
DisconnectReason Property System.Nullable`1[[Microsoft.Exchange.Data.Mapi.MailboxState, Microsoft.Exchang...
DisplayName Property System.String DisplayName {get;}
Identity Property Microsoft.Exchange.Data.Mapi.MailboxId Identity {get;}
IsArchiveMailbox Property System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, ...
IsQuarantined Property System.Boolean IsQuarantined {get;}
IsValid Property System.Boolean IsValid {get;}
ItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
LastLoggedOnUserAccount Property System.String LastLoggedOnUserAccount {get;}
LastLogoffTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
LastLogonTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
LegacyDN Property System.String LegacyDN {get;}
MailboxGuid Property System.Guid MailboxGuid {get;}
MailboxTableIdentifier Property System.String MailboxTableIdentifier {get;}
MapiIdentity Property Microsoft.Exchange.Data.Mapi.MapiObjectId MapiIdentity {get;}
MoveHistory Property System.Object MoveHistory {get;}
ObjectClass Property Microsoft.Exchange.Data.Mapi.ObjectClass ObjectClass {get;}
OriginatingServer Property Microsoft.Exchange.Data.Fqdn OriginatingServer {get;}
ServerName Property System.String ServerName {get;}
StorageLimitStatus Property System.Nullable`1[[Microsoft.Exchange.Data.Mapi.StorageLimitStatus, Microsoft.E...
TotalDeletedItemSize Property Microsoft.Exchange.Data.Unlimited`1[[Microsoft.Exchange.Data.ByteQuantifiedSize...
TotalItemSize Property Microsoft.Exchange.Data.Unlimited`1[[Microsoft.Exchange.Data.ByteQuantifiedSize...
The documentation is not clear on what Get-MoveRequest
returns, but something like below is what you can try:
Get-MoveRequest ... | select -expand Name | Get-MBStats
精彩评论