I am working on a script I can run that will take a list of users and their allocated licenses and filter them based on their UPN to get a count of license usage per sub domain as a representation of the total licenses.
I have sorted them into hash tables based on the domain in their UPN.
$org1Users += [PSCustomObject]@{
UserPrincipalName = $user.UserPrincipalName
AccountSkuId = $user.Licenses
With those hash tables each contains the UPN and the Licenses string for each user displayed as:
UserprincipalName Licenses
----------------- --------
Bob_Frank@domain.com {org:STREAM, org:ENTERPRISEPACK}
I am trying to figure out how I can iterate through each user in the hashtable and split out their licenses so that I can do a switch or if/else chain of "if they have x license" increment the count of *License_Type" in another Hashtable. As it is it will only do it once per user which doesn't work if they have Multiple Licenses.
foreach($user in $AGUsers)
{
If($AGUsers.AccountSkuId -eq 'owfg:VISIOCLIENT')
{
$ConsumedLicenses[$VISIOCLIENT]++
}
elseif ($AGUsers.AccountSkuId -eq "org:STREAM" ) {
$ConsumedLicenses[$STREAM]++
}
.....onwards
At the end I will be taking the values from the License_Type hash tables and using the individual values to generate a report breaking down the % of the total count of licenses each domain is consuming.