Forum Discussion
license export in Office365
I might have to review them when I get home though
Get-MsolUser -UserPrincipalName User1@mydomain.com | ft DisplayName,Licenses
$csv = Import-Csv c:\your.csv
| ForEach ($user in $csv) {Get-MsoluserLicense} | ft displayname,Licenses | export-csv C:\logfile.csv
- Rising FlightDec 20, 2018Brass Contributor
Hi when i use the below syntax i am getting output
Get-MsolUser -UserPrincipalName user1@mydomain.com | Format-List DisplayName,Licenses
DisplayName : User1
Licenses : EMS, ENTERPRISEPACK}
==========================================
I tried the below two syntaxes i am getting error$CSV = Import-CSV C:\userlist.csv
$CSV | ForEach-Object {
$UPN =$_.upn
Get-MsolUser -UserPrincipalName "$UPN" | Format-List DisplayName,Licenses}
==============================================
$Users= Import-CSV C:\userlist.csv
Foreach($User in $Users){(Get-MsolUser -UserPrincipalName $User.Name).Licenses.DisplayName|Ft} | Export-CSV "C:\output.csv" -NoTypeInformation
=================================
my csv file is in the format
Name
user1@mydomain.om
user2@mydomain.com- Dec 20, 2018There is bracket error in the last one! I’ll check a little later
- Rising FlightDec 21, 2018Brass Contributor
The below syntax works perfectly fine
$Users= Import-CSV C:\userslist.csv
Foreach($User in $Users){Get-MsolUser -UserPrincipalName $User.Name | Select DisplayName,Licenses}
When i want to export the output to csv file i am not getting the output, i have used the below syntax
Foreach($User in $Users){Get-MsolUser -UserPrincipalName $User.Name | Select DisplayName,Licenses| Export-CSV C:\out.csv -NoTypeInformation}
I am getting output as
user1 System.Collections.Generic.List`1[Microsoft.Online.Administration.UserLicense]
user2 System.Collections.Generic.List`1[Microsoft.Online.Administration.UserLicense]