Export Office 365 Licensing

Hi – Below you will find the Powershell script to export O365 Licensing for every user in your organization. Please let us know if you have any questions!

 

$lines = @()
foreach($msolUser in (Get-MSOLUser -ALL | where {$_.isLicensed -eq $true}))
{
    $UserInfo = Get-User -identity $msolUser.UserPrincipalName
    foreach($license in $msolUser.Licenses)
    {
        $lines += New-Object PsObject -Property @{
                    "Nom/Prenom"="$($UserInfo.DisplayName)";
                    "Societe"="$($UserInfo.Company)";
                    "AdressePrincipale"="$($UserInfo.UserPrincipalName)";
                    "Licences"="$($license.AccountSKUid)"
                  }
    }
}
$lines | Export-CSV C:\out1.csv -Delimiter ";" -Encoding Unicode

Leave a Reply

Your email address will not be published. Required fields are marked *

*