There doesn't seem to be a direct method to add policy key using powershell. All methods here.
You could use Microsoft Graph API with Powershell as a workaround. There is an article about connecting to Microsoft GraphAPI Using PowerShell.
Note: Add application permission TrustFrameworkKeySet.ReadWrite.All
first, and grant consent for your tenant.
$Uri = "https://graph.microsoft.com/beta/trustFramework/keySets/{id}/generateKey"
$Body = @{
use="sig"
kty="RSA"
nbf="1508969811"
exp="1508969811"
}
Invoke-RestMethod -Uri $Uri -Headers @{Authorization = "Bearer $($token)"} -Method Post -ContentType "application/json" -Body $Body
UPDATE:
The name of policy key is id
of the trustframeworkKeySet.
Key type is kty
of trustFrameworkKey. And secret is related to oct
.
So, you need to create keySet first, then generate the key.
Create keySet:
POST https://graph.microsoft.com/beta/trustFramework/keySets
Content-type: application/json
{
"id": "keyset1 like B2C_1A_test"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…