Skip to content

Commit e5eb23c

Browse files
TheMattCollins0CalebAlbers
authored andcommitted
Change to accept a API Key supplied as a parameter (#17)
1 parent 8d6f9b9 commit e5eb23c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Diff for: ITGlueAPI/Internal/APIKey.ps1

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
function Add-ITGlueAPIKey {
2+
[cmdletbinding()]
3+
Param (
4+
[Parameter(Mandatory = $false)]
5+
[AllowEmptyString()]
6+
[Alias('ApiKey')]
7+
[string]$Api_Key
8+
)
9+
if ($Api_Key) {
10+
$x_api_key = ConvertTo-SecureString $Api_Key -AsPlainText -Force
11+
12+
Set-Variable -Name "ITGlue_API_Key" -Value $x_api_key -Option ReadOnly -Scope global -Force
13+
}
14+
if (!$Api_Key) {
215
Write-Host "Please enter your API key:"
316
$x_api_key = Read-Host -AsSecureString
417

518
Set-Variable -Name "ITGlue_API_Key" -Value $x_api_key -Option ReadOnly -Scope global -Force
19+
}
620
}
721

8-
922
function Remove-ITGlueAPIKey {
1023
Remove-Variable -Name "ITGlue_API_Key" -Force
1124
}
1225

1326
function Get-ITGlueAPIKey {
1427
$ITGlue_API_Key
28+
1529
Write-Host "Use Get-ITGlueAPIKey -Force to retrieve the unencrypted copy." -ForegroundColor "Red"
1630
}
1731

18-
New-Alias -Name Set-ITGlueAPIKey -Value Add-ITGlueAPIKey
32+
New-Alias -Name Set-ITGlueAPIKey -Value Add-ITGlueAPIKey

0 commit comments

Comments
 (0)