Ali,
Assuming that you are using PowerShell 3.0 and your CSV files has a 'DisplayName' column, then this should work:
$Names = Import-CSV D:\MoveMailbox\Scripts\user.csv
$displayNamesArray = $Names.DisplayName
$wmiResults = get-wmiobject -namespace root\MicrosoftExchangev2 -class Exchange_mailbox -computer Server01 | Select ServerName,StorageGroupName,StoreName,MailboxDisplayName,Size
$wmiResults | Where-Object { $displayNamesArray -contains $_.MailboxDisplayName } | Export-csv Mailboxsize.csv
If you are using PowerShell 2.0 (you have to do a little extra work to build then $displayNamesArray):
$Names = Import-CSV D:\MoveMailbox\Scripts\user.csv
$displayNamesArray = @()
$Names | ForEach-Object { $displayNamesArray += $_.DisplayName }
$wmiResults = get-wmiobject -namespace root\MicrosoftExchangev2 -class Exchange_mailbox -computer Server01 | Select ServerName,StorageGroupName,StoreName,MailboxDisplayName,Size
$wmiResults | Where-Object { $displayNamesArray -contains $_.MailboxDisplayName } | Export-csv Mailboxsize.csv
It's usually faster to make a single WMI call and then parse the results in memory - however, if you have a large server with lots of results and only want results on a few users, it may be better to loop through the array of users and use a WQL query to
only retrieve those users.
Mike