My organization has a subscription to Office 365. Cloud sync with the local AD
I am establish the remote session with the cloud. I want to find all users in who do not have a license for Office 365.
For first, I wrote the following pipe:
Get-MsolUser -MaxResults 500 | Where-Object { $_.isLicensed -eq "false" } | Select-Object UserPrincipalName, DisplayName, Department | sort department | Export-Csv c:\powershell\LicensedUser
and receive valid csv table.
then I want to get a list of users for a particular department, and for this to run the following command
Get-MsolUser -MaxResults 500 | Where-Object { $_.isLicensed -eq "false" -and $_.department -eq "marketing" } | Select-Object UserPrincipalName, DisplayName, Department | Export-Csv c:\powershell\LicensedUser
Pipe is running without an error messages, but the csv table is empty
What I did wrong?
Please, help