Internal/APIKey.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
function Add-ITGlueAPIKey { [cmdletbinding()] Param ( [Parameter(Mandatory = $false, ValueFromPipeline = $true)] [AllowEmptyString()] [Alias('ApiKey')] [string]$Api_Key ) if ($Api_Key) { $x_api_key = ConvertTo-SecureString $Api_Key -AsPlainText -Force Set-Variable -Name "ITGlue_API_Key" -Value $x_api_key -Option ReadOnly -Scope global -Force } else { Write-Host "Please enter your API key:" $x_api_key = Read-Host -AsSecureString Set-Variable -Name "ITGlue_API_Key" -Value $x_api_key -Option ReadOnly -Scope global -Force } } function Remove-ITGlueAPIKey { Remove-Variable -Name "ITGlue_API_Key" -Scope global -Force } function Get-ITGlueAPIKey { if($null -eq $ITGlue_API_Key) { Write-Error "No API key exists. Please run Add-ITGlueAPIKey to add one." } else { $ITGlue_API_Key } } New-Alias -Name Set-ITGlueAPIKey -Value Add-ITGlueAPIKey |