SOLVED

Please help change my output to GB units only.

%3CLINGO-SUB%20id%3D%22lingo-sub-1414677%22%20slang%3D%22en-US%22%3EPlease%20help%20change%20my%20output%20to%20GB%20units%20only.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1414677%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20goal%20is%20to%20find%20the%20mailbox%20folder%20and%20subfolder%20sizes%20of%20a%20mailbox%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20command%20works%20(but%20the%20units%20are%20kb%2C%20mb%26amp%3B%20gb%20-%20my%20goal%20is%20only%20gb)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-ExecutionPolicy%20RemoteSigned%3C%2FP%3E%3CP%3E%24UserCredential%20%3D%20Get-Credential%3C%2FP%3E%3CP%3E%24Session%20%3D%20New-PSSession%20-ConfigurationName%20Microsoft.Exchange%20-ConnectionUri%20-ERR%3AREF-NOT-FOUND-%3CA%20href%3D%22https%3A%2F%2Foutlook.office365.com%2Fpowershell-liveid%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office365.com%2Fpowershell-liveid%2F%3C%2FA%3E%20-Credential%20%24UserCredential%20-Authentication%20Basic%20-AllowRedirection%3C%2FP%3E%3CP%3EImport-PSSession%20%24Session%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-MailboxFolderStatistics%20bob%40domain.com%20%7C%20Select%20Name%2CFolderSize%2CItemsinFolder%20%7C%20export-csv%26nbsp%3B%20c%3A%5Cbob.csv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20when%20I%20try%20to%20change%26nbsp%3B%3C%2FP%3E%3CP%3EGet-MailboxFolderStatistics%20bob%40domain.com%20%7C%20Select%20Name%2CFolderSize%20%7C%20export-csv%26nbsp%3B%20c%3A%5Cbob.csv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eto%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-MailboxFolderStatistics%20bob%40domain.com%20%7C%20select-object%20DisplayName%2C%20%40%7Bname%3D%22FolderSize%20(GB)%22%3Bexpression%3D%7B%5Bmath%5D%3A%3ARound(((%24_.FolderSize.Value.ToString()).Split(%22(%22)%5B1%5D.Split(%22%20%22)%5B0%5D.Replace(%22%2C%22%2C%22%22)%2F1GB)%2C2)%7D%7D%20%7C%20export-csv%20c%3A%5Cbob.csv%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20nothing%20-%20I%20tried%20adding%20get-unified%20-%20I%20admit%20I%20have%20no%20idea%20what%20I'm%20doing%20-%20just%20mashing%20together%20code%20from%20other%20places.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1414677%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%20center%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Administration%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Management%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1414871%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help%20change%20my%20output%20to%20GB%20units%20only.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1414871%22%20slang%3D%22en-US%22%3E%3CP%3ERemove%20.Value%2C%20you%20don't%20need%20it%20as%20the%20data%20is%20already%20returned%20as%20string.%20And%20you%20want%20to%20use%20Name%20instead%20of%20DisplayName%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EGet-MailboxFolderStatistics%20bob%40domain.com%20%7C%20select-object%20Name%2C%20%40%7Bname%3D%22FolderSize%20(GB)%22%3Bexpression%3D%7B%5Bmath%5D%3A%3ARound(((%24_.FolderSize).Split(%22(%22)%5B1%5D.Split(%22%20%22)%5B0%5D.Replace(%22%2C%22%2C%22%22)%2F1GB)%2C2)%7D%7D%20%7C%20export-csv%20c%3A%5Cbob.csv%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1415025%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help%20change%20my%20output%20to%20GB%20units%20only.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1415025%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWonderful%20job%20-%20thank%20you!!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20want%20to%20create%20a%20lot%20of%20work%20for%20you%20but%20is%20there%20an%20easy%20way%20to%20have%20it%20only%20list%20folders%20that%20are%20over%201GB%3F%26nbsp%3B%20%26nbsp%3BThis%20user%20has%20about%2050%20folders%20and%20while%20I%20can%20sort%20by%20size%20in%20excel%20it%20would%20be%20useful%20if%20I%20had%20to%20do%20a%20lot%20of%20these%20if%20only%20the%201gb%20or%20larger%20ones%20showed.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

My goal is to find the mailbox folder and subfolder sizes of a mailbox 

 

This command works (but the units are kb, mb& gb - my goal is only gb)

 

Set-ExecutionPolicy RemoteSigned

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

 

 

 

Get-MailboxFolderStatistics bob@domain.com | Select Name,FolderSize,ItemsinFolder | export-csv  c:\bob.csv

 

 

But when I try to change 

Get-MailboxFolderStatistics bob@domain.com | Select Name,FolderSize | export-csv  c:\bob.csv

 

to 

 

Get-MailboxFolderStatistics bob@domain.com | select Name, @{name="FolderSize (GB)";expression={[math]::Round((($_.FolderSize.Value.ToString()).Split("(")[1].Split(" ")[0].Replace(",","")/1GB),2)}} | export-csv c:\bob.csv  

 

I get nothing - I tried adding get-unified - I admit I have no idea what I'm doing - just mashing together code from other places.

 

2 Replies
Best Response confirmed by Boe Dillard (Contributor)
Solution

Remove .Value, you don't need it as the data is already returned as string. And you want to use Name instead of DisplayName

 

Get-MailboxFolderStatistics bob@domain.com | select-object Name, @{name="FolderSize (GB)";expression={[math]::Round((($_.FolderSize).Split("(")[1].Split(" ")[0].Replace(",","")/1GB),2)}} | export-csv c:\bob.csv  

@Vasil Michev 

 

Wonderful job - thank you!!!!

 

I don't want to create a lot of work for you but is there an easy way to have it only list folders that are over 1GB?   This user has about 50 folders and while I can sort by size in excel it would be useful if I had to do a lot of these if only the 1gb or larger ones showed.