Remove empty attributes from Get-Mailbox

This topic contains 3 replies, has 2 voices, and was last updated by  mr_evans2u 4 years, 6 months ago.

  • Author
    Posts
  • #6751

    mr_evans2u
    Participant

    I am using the following code to get a dump of exchange data, but I don't want attributes that don't have data with it. How do I go through the attributes and remove the attributes that don't have data?

    Get-MailboxStatistics -identity $ID | Select DisplayName, @{expression={$_.totalDeletedItemSize.value.ToKB()};label="DelSize(KB)"}, MailboxGUID, ServerName, @{Name="Mailbox Size (MB)";Expression={$_."TotalItemSize".Value.ToMB()}}, StorageGroupName, DatabaseName, itemcount, LastLogonTime |
     Out-File -encoding ascii $User -width 750 
    
        Get-Mailbox -identity $ID |Format-List * |
    	Out-File -encoding ascii $User -width 750  -append 	  
            $conn.Close()
    
    	 Get-content $User | where {$_ -ne ""} | Out-file $Newfile
    	 Remove-Item $User

     

  • #6779

    mr_evans2u
    Participant

    for example it would look like this.....

  • #6815

    Poshoholic
    Participant

    Once you have your format-list results in a file, do something like this:

    Get-Content $user | Where-Object {$_ -notmatch ':\s+$'} | Set-Content $Newfile
    Remove-Item $user

  • #6834

    mr_evans2u
    Participant

    Thank you Poshoholic! That is simpler then what I had figured out.

You must be logged in to reply to this topic.