The code below shows the users with licenses but I need to know what their sync type is as well and I am unsure how to get that information
# Connect to o365 tenant
Connect-MsolService
# Get all users in o365 and get license information
$groupOfUsers = Get-MsolUser -all
$results = foreach ($user in $groupOfUsers) {
$licenses = $user.licenses.accountskuid
foreach ($license in $licenses) {
[pscustomobject]@{
UPN = $user.userprincipalname
License = $license
}
}
}
# Export the results to csv
$results | Export-Csv c:\scripts\UsersWitho365licenses.csv -NoTypeInformation
Everything in Powershell is an object, therefore, it has methods and properties, and as LotPings commented,
But this is an array which may differ on the properties an methods you will be able to use in the foreach. Try this (I will do it with FileItems as I don't have that module):
Result:
But You don't care about all that you just want the properties, you can get them like this:
Result:
One of the properties in the output of Get-Member should be what you are looking for.