Powershell - Get ProxyAddresses and output to seperate row

Posted on 2012-09-05
Last Modified: 2012-09-05
I need to grab a list of proxyaddresses from users, contacts and groups and output to a text file, with only one proxy address listed per line in the output file, but also filter out any proxyaddresses that do not match "" i.e

I have the below powershell script which outputs on screen what I want,
get-qadobject -OrganizationalUnit -sizeLimit 0 -ip proxyAddresses |
select-object -expand proxyAddresses | where {$_.endswith('')}

however when exporting to csv the output is the below format

#TYPE System.String

Any ideas on how i can get a nice export file with only the filtered proxyaddresses listed on a seperate line?
Question by:ColliersInternational
    LVL 39

    Expert Comment

    by:Krzysztof Pytko
    This is due to incompatibility of string output. You need to convert first this to string.
    I'm not big programmer in PowerShell, so please check that only for your information and try to use that or wait for another expert for professional help

    In the meantime, if you're interested, please similar thread at this forum where yo_bee had the same problem but in different cmd-let output. He provided at the end all required steps

    LVL 16

    Expert Comment

    by:Rajitha Chimmani
    What is the command that you are using to export to csv?
    LVL 16

    Expert Comment

    by:Rajitha Chimmani
    Is it fine if we use the Exchange commands instead of QAD cmdlets? Hope you are doing it for Exchange/email enabled objects only.
    LVL 16

    Accepted Solution

    For Exchange, you can use the below command

    Get-Mailbox -Resultsize unlimited | foreach{$_.Emailaddresses} | where {$_.smtpaddress.endswith('')} | export-csv test.csv -NoClobber -NoTypeInformation

    You may find some errors on powershell screen but thats normal as few email addresses (X400 or X500) dont have the parameter SMTPAddress within them.

    Author Closing Comment

    Exactly the ouput I required. Thanks.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
    This video discusses moving either the default database or any database to a new volume.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now