public/Get-GDDomain.ps1
Set-StrictMode -Version Latest function Get-GDDomain { [CmdletBinding(DefaultParameterSetName = 'Secure')] param( [parameter(ParameterSetName = 'Secure', Mandatory = $true)] [string] $key, [parameter(ParameterSetName = 'Secure', Mandatory = $true)] [securestring] $secret, [parameter(ParameterSetName = 'Credentials', Mandatory = $true)] [System.Management.Automation.PSCredential] $credentials, [string] $domain, [string[]] $statuses ) Begin { } Process { if ($credentials) { $key = $credentials.UserName $PlainSecret = _convertSecureStringTo_PlainText -SecureString $credentials.Password } else { $PlainSecret = _convertSecureStringTo_PlainText -SecureString $secret } $sb = New-Object System.Text.StringBuilder $null = $sb.Append("https://api.godaddy.com/v1/domains/$domain") if ($null -ne $statuses) { $null = $sb.Append("?statuses=") $i = 0; foreach ($status in $statuses) { if ($i -gt 0) { $null = $sb.Append(",") } $i++ $null = $sb.Append($status) } } $Headers = @{accept = 'application/json'; Authorization = "sso-key $($key):$($PlainSecret)"} Invoke-RestMethod -Uri "$($sb.ToString())" -Headers $Headers -Method Get } End { } } |