# Prompt the user to enter the username $username = Read-Host "Enter the username" # Get the user object from Active Directory $user = Get-ADUser $username -Properties * # Get the licenses assigned to the user $licenses = Get-ADUser $user -Properties msDS-UserLicenses | Select-Object -ExpandProperty msDS-UserLicenses # Display the licenses Write-Host "Licenses assigned to $($user.Name):" $licenses