SOLVED

Please help change my output to GB units only.

Iron 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 (Iron 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.

1 best response

Accepted Solutions
best response confirmed by Boe Dillard (Iron 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  

View solution in original post