none
List of department users do not have a license for Office365 RRS feed

  • Question

  • Hi folks,

    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\LicensedUsers.csv 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\LicensedUsers.csv

    Pipe  is running without an error messages, but the csv table is empty

    What I did wrong?

    Please, help
    Tuesday, August 4, 2015 1:30 PM

All replies

  • Your second script worked fine for me. Are you sure you have users with Marketing as their department?
    Wednesday, September 2, 2015 2:41 PM
  • Can you try this one? 

    Get-MsolUser -MaxResults 500 | Where-Object { ($_.isLicensed -eq "false") -and ($_.department -like "marketing")  }  | Select-Object UserPrincipalName, DisplayName,  Department | Export-Csv c:\powershell\LicensedUsers.csv



    Bruce Jourdain de Coutance - Consultant MVP Exchange http://blog.brucejdc.fr

    Tuesday, September 15, 2015 8:27 AM