-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGet-GoDaddyAPIKey.ps1
52 lines (44 loc) · 1.2 KB
/
Get-GoDaddyAPIKey.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<#
.Synopsis
Returns the current API key/secret pair.
.DESCRIPTION
Returns the current API key/secret pair being used by the GoDaddy module.
.EXAMPLE
PS C:\> Get-GoDaddyAPIKey
Key Secret
--- ------
mykey mysecret
#>
function Get-GoDaddyAPIKey
{
[CmdletBinding()]
Param
(
)
Begin
{
}
Process
{
## Test if apiKey.csv exists, if so, return the contents.
if ((Test-Path "$PSScriptRoot\apiKey.csv") -eq $True) {
$apiKeySecure = Import-Csv "$PSScriptRoot\apiKey.csv"
# Decrypt API Key
$apiKey = @(
[PSCustomObject]@{
Key = [System.Net.NetworkCredential]::new("", ($apiKeySecure.Key | ConvertTo-SecureString)).Password
Secret = [System.Net.NetworkCredential]::new("", ($apiKeySecure.Secret | ConvertTo-SecureString)).Password
}
)
# Return decrypted key info
$apiKey
}
## If Test-Path fails, write the following warning:
else {
Write-Warning -Message "API Key does not exist. Use Set-GoDaddyAPIKey to create one."
}
}
End
{
}
}