We help IT Professionals succeed at work.
Get Started

How do I change the way powershell exports info to a CSV file.

Last Modified: 2015-03-09
I have successfully created a batch file that runs a powershell script in Exchange Managment Shell to extract the users that have an exchange mobile device partnership to a CSV file. The first column of my CSV file is the "Identity" which looks like this.

Domain.com/ICT/User Accounts/fred flinstone/ExchangeActiveSyncDevices/AirWatchDroid?AirWatch1070560211

It is pulling this information from AD. Is there a way to change or filter out everything from "Identity" except the username?

Here is my script.
Add-PSSnapin Microsoft.Exchange.Management.Powershell.SnapIn -ea silentlyContinue

$UserList = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_{*"} | Get-Mailbox

$UserList | foreach { Get-MobileDeviceStatistics -Mailbox $_} | Sort Identity,DeviceType,DeviceID,FirstSyncTime,LastSuccessSync | select Identity,DeviceType,DeviceID,FirstSyncTime,LastSuccessSync | Export-Csv -Path c:\MobileDeviceCSV\ExchMobileDevice.csv –NoTypeInformation
Watch Question
IT Infrastructure Architect
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE