2011-09-16 41 views
0

Microsoft.Exchange.Data.EnhancedTimeSpanMicrosoft.Exchange.Data.ByteQuantifiedSize分別轉換爲秒和字節(或megs)的正確方法是什麼,以便我可以將它們分開?在Powershell中獲得每秒兆字節數(主要是鑄造問題)

function Get-MBStats($Username = "someuser") 
{ 

$UserDetail = (Get-MailboxStatistics -Identity $Username -IncludeMoveHistory).MoveHistory[0] 
# | ft status, targetdatabase , completiontimestamp , totalmailboxsize ,overallduration -auto# 

# What is the syntax for this? 
$DataRate = $UserDetail.OverallDuration/$UserDetail.TotalMailboxSize 

New-Object PSObject -Property @{ 
Username = $Username 
Status = $UserDetail.Status 
TargetDatabase = $UserDetail.TargetDatabase 
CompletionTime = $UserDetail.CompletionTimestamp 
TotalMailboxSize = $UserDetail.TotalMailboxSize 
OverallDuration = $UserDetail.OverallDuration 
Rate = $DataRate 
} 

# Todo: GUI http://msdn.microsoft.com/en-us/magazine/hh288074.aspx # 
} 

Get-MBStats 

回答

0

我才發現,原來我可以這樣做

$a.TotalItemSize.Value | Get-Member

其中$ a代表我的工作類型的變量發現類型的成員。

這裏是ByteQuantifiedSize

TypeName: Microsoft.Exchange.Data.ByteQuantifiedSize 

Name   MemberType Definition 
----   ---------- ---------- 
CompareTo  Method  int CompareTo(Microsoft.Exchange.Data.ByteQuantifiedSize other) 
Equals  Method  bool Equals(System.Object obj), bool Equals(Microsoft.Exchange.Data.ByteQuantifiedSize other) 
GetHashCode Method  int GetHashCode() 
GetType  Method  type GetType() 
RoundUpToUnit Method  System.UInt64 RoundUpToUnit(Microsoft.Exchange.Data.ByteQuantifiedSize+Quantifier quantifier) 
ToBytes  Method  System.UInt64 ToBytes() 
ToGB   Method  System.UInt64 ToGB() 
ToKB   Method  System.UInt64 ToKB() 
ToMB   Method  System.UInt64 ToMB() 
ToString  Method  string ToString(), string ToString(string format), string ToString(string format, System.IF... 
ToTB   Method  System.UInt64 ToTB() 

成員和這裏是EnhancedTimeSpan成員。

TypeName: Microsoft.Exchange.Data.EnhancedTimeSpan 

Name    MemberType Definition 
----    ---------- ---------- 
Add    Method  Microsoft.Exchange.Data.EnhancedTimeSpan Add(System.TimeSpan ts) 
CompareTo   Method  int CompareTo(System.Object value), int CompareTo(Microsoft.Exchange.Data.EnhancedTimeS... 
Divide   Method  long Divide(System.TimeSpan ts) 
Duration   Method  Microsoft.Exchange.Data.EnhancedTimeSpan Duration() 
Equals   Method  bool Equals(System.Object value), bool Equals(Microsoft.Exchange.Data.EnhancedTimeSpan ... 
GetHashCode  Method  int GetHashCode() 
GetType   Method  type GetType() 
Mod    Method  Microsoft.Exchange.Data.EnhancedTimeSpan Mod(System.TimeSpan ts) 
Multiply   Method  Microsoft.Exchange.Data.EnhancedTimeSpan Multiply(long n) 
Negate   Method  Microsoft.Exchange.Data.EnhancedTimeSpan Negate() 
Subtract   Method  Microsoft.Exchange.Data.EnhancedTimeSpan Subtract(System.TimeSpan ts) 
ToString   Method  string ToString() 
Days    Property System.Int32 Days {get;} 
Hours    Property System.Int32 Hours {get;} 
Milliseconds  Property System.Int32 Milliseconds {get;} 
Minutes   Property System.Int32 Minutes {get;} 
Seconds   Property System.Int32 Seconds {get;} 
Sign    Property System.Int32 Sign {get;} 
Ticks    Property System.Int64 Ticks {get;} 
TotalDays   Property System.Double TotalDays {get;} 
TotalHours  Property System.Double TotalHours {get;} 
TotalMilliseconds Property System.Double TotalMilliseconds {get;} 
TotalMinutes  Property System.Double TotalMinutes {get;} 
TotalSeconds  Property System.Double TotalSeconds {get;}