I have two PSCustom Objects / hashtables that contain license names and values for office 365. I am looking for a method to search the second hashtable for the matching license name so I can do some math to get percentage consumed of the total count for each Business unit.
- ConsumedLicenses
| Name | Value |
|---|---|
| E3 | 55 |
- LicenseCounts
| AccountSkuId | ActiveUnits | ConsumedUnits |
|---|---|---|
| E3 | 400 | 75 |
I originally started on using a nestled foreach loop but found that will not do what I want to do. Looking for some guidance on how to proceed.
Foreach($consumedlicense in $ConsumedLicenses)
{
$match = $true
Foreach($licensecount in $LicenseCounts)
{
if($consumedlicense.keys -ne $licensecount.AccountSkuId)
{
Write-host "$consumedlicense.keys not $licensecount.AccountSkuId"
$match = $false;Break
}
}
if($match)
{
Write-host "$consumedlicense.keys matches $licensecount.AccountSkuId"
$Percentage = $ConsumedLicense.values / $licensecount.ActiveUnits
Write-Host "$consumedlicense.keys = $Percentage of total licenses."
}
}