| 12345678910111213141516171819202122 |
- [CmdletBinding()]
- param(
- [Parameter(Mandatory = $true)][ValidatePattern('^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$')][string]$ProjectId,
- [string]$ConfigPath = (Join-Path $PSScriptRoot 'config\central-feedback.config.dpapi')
- )
- . (Join-Path $PSScriptRoot 'Common.ps1')
- $config = Get-ProtectedConfig -Path $ConfigPath
- if (@($config.allowed_projects | Where-Object { $_.project_id -eq $ProjectId }).Count -gt 0) { throw "Project already registered: $ProjectId" }
- $submitKey = New-SubmitKey
- try {
- $entry = [pscustomobject]@{ project_id = $ProjectId; key_hash = (Get-Sha256Hex -Bytes ([Text.Encoding]::UTF8.GetBytes($submitKey))); enabled = $true }
- $config.allowed_projects = @($config.allowed_projects) + $entry
- Save-ProtectedConfig -Config $config -Path $ConfigPath
- Write-Output 'Project registration created. Copy the following key through an approved private channel; it is shown only once:'
- Write-Output $submitKey
- }
- finally {
- $submitKey = $null
- $config.app_secret = $null
- }
|