Jannos-443 / PRTG-M365

PRTG Microsoft 365 Scripts
MIT License
10 stars 6 forks source link

prepaidUnits calculation if low license count #6

Closed rphlwnk closed 1 year ago

rphlwnk commented 1 year ago

Since Microsoft decided to array the prepaidUnits and move the actual value according to the licenseing state i got a "-" value on the free licence sensor and no total license count:

image

So if you have less than x amount of free licenses the prepaidUnits count is not unter .enabled instead it is moved to .warning or .suspended - see example below:

capabilityStatus : Enabled
consumedUnits    : 5
skuPartNumber    : STREAM
appliesTo        : User
prepaidUnits     : @{enabled=1000000; suspended=0; warning=0}

capabilityStatus : Enabled
consumedUnits    : 1100
skuPartNumber    : ENTERPRISEPACK
appliesTo        : User
prepaidUnits     : @{enabled=0; suspended=0; warning=1100}

It is a simple fix where you can add up enabled+warning+suspended on line 279

$NewLic.PrepaidUnitsEnabled = ($R.PrepaidUnits.enabled + $R.PrepaidUnits.warning + $R.PrepaidUnits.suspended)

image

Jannos-443 commented 1 year ago

Hey rphlwnk,

good point, thank you. I changed the line :)