Link to home
Start Free TrialLog in
Avatar of alopez2
alopez2

asked on

How to export data from PowerShell script?

Can someone please show me how to export the data from the PowerShell script below to a file?  I cannot for the life of me get it done.  Only a blank file is produced.

Have also tried the export-csv cmndlet with same results.

The data comes up on the screen just fine.

Running the script on an Exchange 2013 server.

Thx,

--------------------

$Mbx = Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -Eq $true -And -not DisplayName -like "CAS_{*"}; $mbx | foreach {$name = $_.name; $device = get-MobileDeviceStatistics -mailbox $_.identity; $device | foreach {write-host $name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} | out-file -filepath C:\Temp\ActiveSyncDeviceInfoTake1.txt -inputobject $Mbx -encoding ASCII -append -width 120 }
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you run just this much:
Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -Eq $true -And -not DisplayName -like "CAS_{*"}; $mbx | foreach {$name = $_.name; $device = get-MobileDeviceStatistics -mailbox $_.identity; $device | foreach {write-host $name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync}

Do you see anything?
Avatar of alopez2
alopez2

ASKER

Thank you both.  oBdA, your script worked perfectly.  Will close out the case.  Thank you.
Avatar of alopez2

ASKER

Script worked great.  Thank you!
alopez2, what your script does?