none
No longer needed RRS feed

All replies

  • Please read the following post first:

    This forum is for scripting questions rather than script requests


    -- Bill Stewart [Bill_Stewart]

    Monday, November 13, 2017 10:27 PM
  • These objects are not numbers.  They are strings.  They cannot be formatted like numbers.


    \_(ツ)_/

    Monday, November 13, 2017 11:14 PM
  • Hi Bill, THis is not a request for a "Script" This is a question about how to get a certain part of the script working, as what I have attempted has not worked.

    Is there a certain section of this forum where this should be posted?

    Monday, November 13, 2017 11:59 PM
  • Hi Jrv,

    This is output that I get from what is currently on the script and the "TotalDeletedItemssize"


    ItemsCount ArchiveItemsCount ItemsSizeBytes ArchiveItemsSizeBytes TotalDeletedItemSize
    336146 231584 14 736 491 165 6 313 097 490 288.7 KB (295,624 bytes)

    I am after the same as ^^^ ArchiveItemSizeBytes just for the "TotalDeletedItemsize" (182 days and older)

    If that makes sense?


    Tuesday, November 14, 2017 12:03 AM
  • Hi Bill, THis is not a request for a "Script" This is a question about how to get a certain part of the script working, as what I have attempted has not worked.

    This is specifically addressed in the post:

    • I have this script. I need someone to add feature X to it. Can someone do that for me?

    The short answer is that this forum is not a free script authoring or customization service.


    -- Bill Stewart [Bill_Stewart]



    Tuesday, November 14, 2017 5:16 PM
  • Hi Bill, THis is not a request for a "Script" This is a question about how to get a certain part of the script working, as what I have attempted has not worked.

    This is specifically addressed in the post:

    • I have this script. I need someone to add feature X to it. Can someone do that for me?

    The short answer is that this forum is not a free script authoring or customization service.


    -- Bill Stewart [Bill_Stewart]



    I guess if I was asking for someone to do this from scratch, or get this working for me, that would be differnet.

    The fact that I am asking for a push in the right direction, to further my knowledge is irrelevant.

    Thanks for your "Help"

    Tuesday, November 14, 2017 8:19 PM
  • This "288.7 KB (295,624 bytes)" is a string and not a number. If you want bytes as a number you have to parse the string.

    '288.7 KB (295,624 bytes)' -match '\((.*)\)'
    $matches[1] -replace 'bytes|,'
    [int]$bytes = ($matches[1] -replace 'bytes|,')
    $bytes
    


    \_(ツ)_/

    Tuesday, November 14, 2017 8:29 PM
  • I don't see the original post anymore, but looks like you're trying to run something like this:

    Get-Mailbox <UserName> | Get-MailboxStatistics

    The TotalDeletedItemSize attribute has a couple of overloads to it (such as ToBytes(), ToMB(), and ToGB()), so if you were to do something like this:

    (Get-Mailbox <UserName> | Get-MailboxStatistics).TotalDeletedItemSize.Value.ToMB()

    It'll return the MB value that you might want. You can swap that out with .ToBytes() or .ToGB(). 

    You can see a full list of available overloads by doing the following:

    (Get-Mailbox <UserName> | Get-MailboxStatistics).TotalDeletedItemSize.Value | Get-Member

    Should output something like this:

       TypeName: Microsoft.Exchange.Data.ByteQuantifiedSize
    
    Name          MemberType Definition                                                                                                                                                                                                    
    ----          ---------- ----------                                                                                                                                                                                                    
    CompareTo     Method     int CompareTo(Microsoft.Exchange.Data.ByteQuantifiedSize other), int IComparable.CompareTo(System.Object obj), int IComparable[ByteQuantifiedSize].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     uint64 RoundUpToUnit(Microsoft.Exchange.Data.ByteQuantifiedSize+Quantifier quantifier)                                                                                                                        
    ToBytes       Method     uint64 ToBytes()                                                                                                                                                                                              
    ToGB          Method     uint64 ToGB()                                                                                                                                                                                                 
    ToKB          Method     uint64 ToKB()                                                                                                                                                                                                 
    ToMB          Method     uint64 ToMB()                                                                                                                                                                                                 
    ToString      Method     string ToString(), string ToString(string format), string ToString(string format, System.IFormatProvider formatProvider), string IFormattable.ToString(string format, System.IFormatProvider formatProvider)  
    ToTB          Method     uint64 ToTB()                                                                                                                                                                                                 
    
    
    

    This forum gets a lot of requests for people to write scripts for their own use, but this seems more like you're wanting to understand how to get a different value from something that you've already gathered. 

    Tuesday, November 14, 2017 8:35 PM
  • The original code looked like it was remoted with O365 or  Invoke-Command so there will be no conversion methods on the result.  When the objects are serialized only the properties get serialized.


    \_(ツ)_/

    Tuesday, November 14, 2017 9:41 PM
  • Gotcha. Thanks for that.

    In that case, couldn't you still do the conversion within the invoke-command before the values get passed back? So it would return the value in the correct format. 

    Or at the very least create a custom PS object and return that back.

    Tuesday, November 14, 2017 9:44 PM
  • Nope.  I was wrong.  It was for Exchange 2010 (out of support) snap-in.  The OP was not a scripter and was lost even though the original script is so trivial that a child could update it.

    This is the problem with untrained people trying to work in Windows technologies.  They do not have enough fundamental training to know how to proceed and ask many questions in forums.  If they would learn the basics they would find they could understand more and do more with fewer questions.

    The original code here has many examples of using the ByteQuantifiedSize structure to get bytes.  Adding one line would have solved the issue.


    \_(ツ)_/

    Tuesday, November 14, 2017 9:54 PM
  • Hi Jacorbello.

    Thanks for this.... I removed the original post, as I did not appreciate the comments from Bill, and lack of support. I understand 100% there are people out there who just want other people to do their job for them, however I am not one of these people. I may not be as "technical" as other people, especially on this forum and I was simply asking for a push in the right direction. My wording may have not been correct in how I was asking for assistance, which could have been misconstrued as asking for someone else to do it for me, which it was not.

    Below is the original script... I have been able to add in the "TotalDeletedItemSize" & "DeletedItemCount" which work perfectly and output what I need.

    What I am having trouble with and, and want the push in the right direction is how to obtain the "Archivable" size and count (this is the same output as what is given under "ArchiveItemsCount" & ArchiveItemSizeBytes")

    ItemsCount ArchiveItemsCount ItemsSizeBytes ArchiveItemsSizeBytes TotalDeletedItemSize DeletedItemCount

    336146

    231584

    14 736 491 165

    6 313 097 490

    288.7 KB

    3


    I have added the script back to the original post so you can see what I am getting at. (for now)


    Tuesday, November 14, 2017 10:24 PM
  • Hi Jacorbello.

    Thanks for this.... I removed the original post, as I did not appreciate the comments from Bill, and lack of support. I understand 100% there are people out there who just want other people to do their job for them, however I am not one of these people. I may not be as "technical" as other people, especially on this forum and I was simply asking for a push in the right direction. My wording may have not been correct in how I was asking for assistance, which could have been misconstrued as asking for someone else to do it for me, which it was not.

    Below is the original script... I have been able to add in the "TotalDeletedItemSize" & "DeletedItemCount" which work perfectly and output what I need.

    What I am having trouble with and, and want the push in the write direction is how to obtain the "Archivable" size and count (this is the same output as what is given under "ArchiveItemsCount" & ArchiveItemSizeBytes")

    ItemsCount ArchiveItemsCount ItemsSizeBytes ArchiveItemsSizeBytes TotalDeletedItemSize DeletedItemCount

    336146

    231584

    14 736 491 165

    6 313 097 490

    288.7 KB

    3


    I have added the script back to the original post so you can see what I am getting at. (for now)

    Did you try to add it.  Just copy what the original code does and add the new properties.  It is you responsibility to edit this. Jacorbello showed you what you need to know.

    What you are asking is complicated by the fact that you seem to show the items you want. 


    \_(ツ)_/


    • Edited by jrv Tuesday, November 14, 2017 10:28 PM
    Tuesday, November 14, 2017 10:26 PM
  • I am not after a different value (I.e Kb or Mb)

    I am wanting to get the "Total Deleted item size" older than 6months old. 

    So the script above currently gets "ArchiveItemsSizeBytes" I am after the same thing except for "Recovered Deleted items'

    I have added in exactly what the code currently does, and changed the value to what I think it should be, however the result is not correct, I just end up with the same output (Duplicate) of "ArchiveItemsSizeBytes"

    If that makes sense?

    Wednesday, November 22, 2017 4:00 AM