# Offline capacity report. No sign-in or tenant access; input is a sanitised CSV. [CmdletBinding()] param([string]$InputPath = (Join-Path $PSScriptRoot '../data/sample-licences.csv')) $ErrorActionPreference = 'Stop' $seen = @{} foreach ($sku in (Import-Csv -LiteralPath $InputPath)) { $enabled = 0; $consumed = 0 if ([string]::IsNullOrWhiteSpace($sku.Sku)) { throw 'Sku is required.' } if ($seen.ContainsKey($sku.Sku)) { throw "Duplicate SKU: $($sku.Sku)" } $seen[$sku.Sku] = $true if (-not [int]::TryParse($sku.Enabled,[ref]$enabled) -or $enabled -lt 0) { throw 'Enabled must be a non-negative integer.' } if (-not [int]::TryParse($sku.Consumed,[ref]$consumed) -or $consumed -lt 0) { throw 'Consumed must be a non-negative integer.' } $available = $enabled - $consumed [pscustomobject]@{ Sku = $sku.Sku; Enabled = $enabled; Consumed = $consumed Available = $available Status = if ($available -lt 0) { 'Overallocated - review' } elseif ($available -eq 0) { 'At capacity' } else { 'Available' } } }