Need Powersheel script to export User details from On-Prem and O365

Dear All - Need your help and support to create a PowerShell script which will take the sAMAccountName as an input and provide the mailbox, active sync, webmail status of those users. The user can be on-prem or cloud anywhere, the script should check details in both locations and export the information in excel file.

In the later stage, I want to export the Skype details as well in the same script. This is required for Monthly reconciliation of users access.

In addition to above, I want below details in the excel.

sAMAccountName
DisplayName
mail
Mailbox Status (On-Prem or O365 or No-Mailbox)
Active Sync Status
Webmail Status
OU

This is a powershell support forum for scripts you may be having issues with. what have you tried?

Hello Dan… i tired few thing but the challenges is connecting both the exchange environments i.e. on-prem and cloud at a same time.

This is a known issue, try the following.