src/Public/Unlock-OpteraLicenseReclaim.ps1
|
function Unlock-OpteraLicenseReclaim { <# .SYNOPSIS Stores a purchased license key so reports unlock the named per-account remediation list. .DESCRIPTION Stores the key in the per-user key file used by every subsequent scan. The key is format-checked here; full validation (active, bound to your tenant, unexpired) happens at scan time against the Optera AI endpoint, because the tenant isn't known until you scan. Get your key at https://opteraai.com/license-reclaim.html after purchase. .EXAMPLE Unlock-OpteraLicenseReclaim -LicenseKey OLR-7K2QF-9MX4A-PD3RT #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $LicenseKey ) # Format-only check at storage time (no tenant context yet). -Offline avoids a network call. $check = Test-OpteraLicenseKey -LicenseKey $LicenseKey -Offline if ($check.Mode -ne 'Full') { Write-Error "License key rejected: $($check.Message)" return } $path = Get-OpteraLicenseKeyPath $dir = Split-Path -Parent $path if (-not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null } if ($PSCmdlet.ShouldProcess($path, 'Store Optera LicenseReclaim key')) { $LicenseKey.Trim() | Set-Content -LiteralPath $path -Encoding ASCII -NoNewline Write-Host "License key stored. Reports will now reveal the named remediation list." -ForegroundColor Green Write-Host " $($check.Message)" -ForegroundColor DarkGray } [pscustomobject]@{ Stored = $true; Path = $path; Validated = $check.Validated; Message = $check.Message } } |