Allow passing connection info as string params, better instructions

This commit is contained in:
Liam Steckler 2025-06-12 10:19:06 -07:00
parent 19c89ed3e6
commit 6d5d696012
3 changed files with 36 additions and 9 deletions

View file

@ -1,13 +1,20 @@
#Requires -Version 7.0
#Requires -Module jwtPS
function Connect-AppleBusinessManager {
if (-not $Env:AppleBusinessManagerClientId -or -not $Env:AppleBusinessManagerPrivateKeyId -or -not $Env:AppleBusinessManagerPrivateKey) {
throw "Client ID, Private Key ID and Private Key environment variables were not set for Apple Business Manager"
[CmdletBinding(DefaultParameterSetName = 'EnvironmentVariable')]
param(
[string][Parameter(ParameterSetName = 'PrivateKeyAsString', Mandatory)]$ClientId,
[string][Parameter(ParameterSetName = 'PrivateKeyAsString', Mandatory)]$PrivateKey,
[string][Parameter(ParameterSetName = 'PrivateKeyAsString', Mandatory)]$PrivateKeyId
)
if ($PSCmdlet.ParameterSetName -eq 'EnvironmentVariable') {
if (-not $Env:AppleBusinessManagerClientId -or -not $Env:AppleBusinessManagerPrivateKeyId -or -not $Env:AppleBusinessManagerPrivateKey) {
throw "Client ID, Private Key ID and Private Key environment variables were not set for Apple Business Manager"
}
$Script:ClientId = $Env:AppleBusinessManagerClientId
$Script:PrivateKey = $Env:AppleBusinessManagerPrivateKey
$Script:PrivateKeyId = $Env:AppleBusinessManagerPrivateKeyId
}
$Script:ClientId = $Env:AppleBusinessManagerClientId
$Script:PrivateKey = $Env:AppleBusinessManagerPrivateKey
$Script:PrivateKeyId = $Env:AppleBusinessManagerPrivateKeyId
$Header = @{
'kid' = $Script:PrivateKeyId
}