SOLVED

License Utilization Script

%3CLINGO-SUB%20id%3D%22lingo-sub-7681%22%20slang%3D%22en-US%22%3ELicense%20Utilization%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-7681%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20having%20a%20time%20getting%20the%20licenses%20assigned%20to%20a%20user%20to%20export%20via%20export-csv%20the%20way%20I'd%20expect...%26nbsp%3B%20The%20following%20code%20outputs%20%22Microsoft.Online.Administration.UserLicense%3BMicrosoft.Online.Administration.UserLicense%22%20for%20licenses%2C%20still%20not%20what%20I'm%20hoping%20for%20when%20flattening%20out%20the%20multivalued%20attribute%20the%20way%20I've%20done%20in%20other%20scripts...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24LicensedUserList%20%3D%20get-msoluser%20-All%20%7C%20where%20%7B%24_.IsLicensed%20-eq%20%22True%22%7D%3CBR%20%2F%3E%24LicensedUserList%20%7C%20select%20DisplayName%2CSignInName%2CTitle%2CUsageLocation%2C%40%7BName%3D'Licenses'%3BExpression%3D%7B%5Bstring%5D%3A%3Ajoin(%22%3B%22%2C(%24_.Licenses))%7D%7D%7C%20Export-CSV%20%24ExportFile%20-NoTypeInformation%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%3A%20I'm%20also%20not%20sure%20what%20the%20%22Right%20Group%22%20for%20this%20question%20is%20on%20the%20new%20forums.%26nbsp%3B%20I%20can't%20find%20a%20%22PowerShell%22%20or%20general%20%22Administration%22%20area%2C%20just%20an%20area%20dedicated%20to%20the%20Admin%20portal.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-7750%22%20slang%3D%22en-US%22%3ERe%3A%20License%20Utilization%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-7750%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20usual%2C%20you%20have%20the%20answers%20right%20at%20your%20fingertips%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E...%26nbsp%3B%20And%20I%20need%20to%20do%20better%20at%20examing%20the%20child%20object%20lists...%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-7728%22%20slang%3D%22en-US%22%3ERe%3A%20License%20Utilization%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-7728%22%20slang%3D%22en-US%22%3ETry%20it%20with%20%24_.Licenses.AccountSkuId%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2076861%22%20slang%3D%22en-US%22%3ERe%3A%20License%20Utilization%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2076861%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3BAny%20recommendations%20on%20doing%20this%20with%20PowerShell%207%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I'm having a time getting the licenses assigned to a user to export via export-csv the way I'd expect...  The following code outputs "Microsoft.Online.Administration.UserLicense;Microsoft.Online.Administration.UserLicense" for licenses, still not what I'm hoping for when flattening out the multivalued attribute the way I've done in other scripts...

 

$LicensedUserList = get-msoluser -All | where {$_.IsLicensed -eq "True"}
$LicensedUserList | select DisplayName,SignInName,Title,UsageLocation,@{Name='Licenses';Expression={[string]::join(";",($_.Licenses))}}| Export-CSV $ExportFile -NoTypeInformation

 

 

PS: I'm also not sure what the "Right Group" for this question is on the new forums.  I can't find a "PowerShell" or general "Administration" area, just an area dedicated to the Admin portal.

3 Replies
best response confirmed by Chad Conrow (Occasional Contributor)
Solution
Try it with $_.Licenses.AccountSkuId

As usual, you have the answers right at your fingertips, @Vasil Michev...  And I need to do better at examing the child object lists... :)

@Vasil Michev Any recommendations on doing this with PowerShell 7?