Skip to content

JeshuaEdgar/openprovider-powershell

Repository files navigation

OpenProviderPowershell

How to use

OpenProviderPowershell is available on PowerShellGallery!

PSGalleryVersion PSGalleryDownloads

To install:

Install-Module OpenProviderPowershell

Or to update:

Update-Module OpenProviderPowershell

Connecting/disconnecting

Connecting to OpenProvider is easy, simply run the following commands to get a connection to OpenProvider.

Connect-OpenProvider
# or
$Credential = Get-Credential
Connect-OpenProvider -Credential $Credential

Connecting to the sandbox environment is now possible too! Just add -Sandbox to Connect-OpenProvider.

For security run the following at the end of your session/script.

Disconnect-OpenProvider

Nameservers

You are able to add, get, remove and update OpenProvider nameservers.

Note: to add nameservers, you must have the domain in your OpenProvider portal!

Get-OPNameserver
Add-OPNameserver -Name "ns1.testdomain.com" -IP "123.456.789.10"
Remove-OPNameserver -Name "ns1.testdomain.com"
Update-OPNameserver -Name "ns1.testdomain.com" -IP "10.987.654.32"

DNS Zones

Getting a zone is necesary for adding and setting DNS records. To get a Zone ID for a domain run the following:

Get-OPZone -Domain "testdomain.com"

Query zone records with the following:

Get-OPZoneRecords -Domain "testdomain.com"

Note: by default will get OpenProvider zones for a domain when both OpenProvider and Sectigo are present, you can add the parameter -Provider sectigo to get the records in the sectigo zone.

Adding records is simple: provide the domain name, Zone ID, type of record and the value. Example:

Add-OPZoneRecord -Domain "testdomain.com" -ZoneID "12345678" -Type TXT -Value "v=SPF1 -all"

Note: The following DNS records can be added through this module:

  • A
  • AAAA
  • CAA
  • CNAME
  • MX
  • TXT
  • NS

Updating existing records can be done too. Use New-OPZoneRecordObject to create easy objects that can be parsed into Set-OPZoneRecord. Here is an example how you could get a DNS record and adjust it to your needs:

$domain = "testdomain.com"
# get the zone id
$zone = Get-OPZone -Domain $domain -Provider sectigo
# get the records assosciated with the domain
$zone_records = Get-OPZoneRecords -Domain $domain -Provider sectigo
# filter the original record
$original_record = $zone_records | Where-Object { ($_.type -eq "TXT") -and ($_.value -eq "v=SPF1 +all") }
# create a new record object
$new_record = New-OPZoneRecordObject -Type TXT -Value "v=SPF1 -all"
# set the record 
Set-OPZoneRecord -Domain $domain -ZoneID $zone.ZoneID -OriginalRecord $original_record -NewRecord $new_record

Domain

You can search for all domains in your OpenProvider directory:

Get-OPDomain

Or you can search for a specific domain:

Get-OpDomain -Domain "testdomain.com"

For a more detailed report such as nameservers connected to the domain epiry dates or renewal information add the -Detailed option.

Availability and pricing for a domain can be checked with the following command, multiple domains are accepted (they must be in a list like the example below):

$domainlist = @(
    "iwanttocheck.com"
    "thesedomains.au"
    "ohandthisone.nl"
)
Get-OPDomainAvailability -Domain $domainlist

This can be useful if you want to check the availibility and price before you go ahead and register a domain.

Disclaimer

This module has no affilation with OpenProvider, just a personal/community project.

This module is still in development, feedback is welcome and endpoint/feature requests are welcome.

Please refer to OpenProvider API Docs for feature/endpoint requests.