Welcome to Powergui.org - an open source community for Windows Powershell

PowerGUI.org PowerGUI.org and blogs

Forums » Active Directory and PowerShell

Thread: powershell export to csv

This question is answered.


Permlink Replies: 4 - Pages: 1 - Last Post: Jun 28, 2011 11:50 PM by: Shay Levy
BMP_Admin

Posts: 2
Registered: 5/17/11
powershell export to csv
Posted: May 17, 2011 1:55 AM
 
  Click to reply to this thread Reply

Hello,

We need to integrate a faxsolution in our network. Our need is to export all usermailboxes and shared mailboxes in the following format Firstname,Lastname,email

I used this powershell command to reach the solution, but it's not working properly.

Get-QADUser | where {Get-Mailbox -RecipientTypeDetails "Sharedmailbox","UserMailbox"} | Select-Object Firstname,Lastname,email | Export-Csv "C:\import_orig03.txt" -Encoding "Unicode"

What am I doing wrong? What needs to be done so that I only get a list of these types of mailboxes?

Best regards,

Philippe




Shay Levy


Posts: 2,567
Registered: 1/31/08
Re: powershell export to csv
Posted: May 17, 2011 9:35 AM   in response to: BMP_Admin
Answered
  Click to reply to this thread Reply

The problem is that you get all users and foreach user you get ALL mailbox objects.

Try this way:

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails SharedMailbox,UserMailbox | Get-User | Select-Object FirstName,LastName,WindowsEmailAddress



Shay Levy [MVP]
http://PowerShay.com
PowerShell Toolbar
BMP_Admin

Posts: 2
Registered: 5/17/11
Re: powershell export to csv
Posted: May 17, 2011 1:26 PM   in response to: Shay Levy
 
  Click to reply to this thread Reply

Hello Shay,

Thanx for the advice and solution. As a novice in powershell I still need a lot to learn...

Best regards,

Philippe


Duramaxster

Posts: 1
Registered: 6/28/11
Re: powershell export to csv
Posted: Jun 28, 2011 5:51 PM   in response to: BMP_Admin
 
  Click to reply to this thread Reply

hello, I have an issue where my export will not comeout right when I export the following. The text file works great, but the csv, is not even close. I am using exchange 2010 and excel 2010. Can anyone help with this???

Oh, I needed to *** the email address as well

Get-MailboxStatistics -Server 'myserver' | Where {$_.DisconnectDate -eq $null -AND $_.DisplayName -notlike "SystemMailbox*"} | Sort DatabaseName, DisplayName | FT -AutoSize DatabaseName, DisplayName, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, ItemCount | Export-csv d:\databaseCSV\testing.csv

Its exporting wrong, the texts file looks great though

Love the logo on the maini page here, my kid wants to get one, lol

All help would be greatly appreaciated
Duramaxster


Shay Levy


Posts: 2,567
Registered: 1/31/08
Re: powershell export to csv
Posted: Jun 28, 2011 11:49 PM   in response to: Duramaxster
 
  Click to reply to this thread Reply


Replace FT with select-object. FT creates formatting instructions (not objects):

Get-MailboxStatistics -Server myserver | `
Where {$_.DisconnectDate -eq $null -AND $_.DisplayName -notlike "SystemMailbox*"} | `
Sort DatabaseName, DisplayName | `
Select-Object DatabaseName, DisplayName, @{expression={$_.totalitemsize.value.ToMB()};label='Size(MB)'},ItemCount | `
Export-csv d:\databaseCSV\testing.csv


Shay Levy [MVP]
http://PowerShay.com
PowerShell Toolbar
Legend
MVP: 2501 + pts
Guru: 2001 - 2500 pts
Expert: 751 - 2000 pts
Enthusiast: 31 - 750 pts
Novice: 0 - 30 pts
Moderators
Helpful answer (5 pts)
Answered (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums