Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of non-existent / expired domains #1

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

jonwbstr
Copy link
Contributor

The function generated errors when trying to work with dates that were not there. Improved the handling of missing dates.

Function generated errors when trying to work with dates that were not there. Improved the handling of missing dates.
@RobBiddle
Copy link
Owner

@jonwbstr thanks for submitting this! Do you have an example of a domain which did not return expiration dates? I just want to confirm the problem and verify the fix before merging in your changes.

@jonwbstr
Copy link
Contributor Author

jonwbstr commented Mar 18, 2024 via email

@RobBiddle
Copy link
Owner

Was a non-existing domain the problem you ran into?
It sounded like you had an existing domain that was returning a whois result with missing expiration dates?

If it's only the former, I'm trying to decide what would be the best way to handle that case, eliminate the errors as you've proposed with your fix, which will return an object with no dates, or specifically throw either an error or warning stating something like "No whois information found for Domain xyz.tld"

PS C:\Users\rbiddle> whois noexisty.com

Whois v1.21 - Domain information lookup
Copyright (C) 2005-2019 Mark Russinovich
Sysinternals - www.sysinternals.com

Connecting to COM.whois-servers.net...
No whois information found.

PS C:\Users\rbiddle> get-whois noexisty.com
Get-Date : Cannot convert 'System.Object[]' to the type 'System.DateTime' required by parameter 'Date'. Specified method is not supported.
At C:\Users\rbiddle\OneDrive - Upic Solutions\Documents\WindowsPowerShell\Modules\Get-WHOIS\1.0.1\Public\Get-WHOIS.ps1:126 char:38
+             $CreationDate = Get-Date $CreationDate
+                                      ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetDateCommand

Get-Date : Cannot convert 'System.Object[]' to the type 'System.DateTime' required by parameter 'Date'. Specified method is not supported.
At C:\Users\rbiddle\OneDrive - Upic Solutions\Documents\WindowsPowerShell\Modules\Get-WHOIS\1.0.1\Public\Get-WHOIS.ps1:129 char:40
+             $ExpirationDate = Get-Date $ExpirationDate
+                                        ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetDateCommand

Get-Date : Cannot convert 'System.Object[]' to the type 'System.DateTime' required by parameter 'Date'. Specified method is not supported.
At C:\Users\rbiddle\OneDrive - Upic Solutions\Documents\WindowsPowerShell\Modules\Get-WHOIS\1.0.1\Public\Get-WHOIS.ps1:130 char:83
+ ... (New-TimeSpan -Start (Get-Date) -End (Get-Date $ExpirationDate)).Days
+                                                    ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetDateCommand



DomainName          : noexisty.com
CreationDate        : {}
DaysUntilExpiration :
ExpirationDate      : {}
NameServers         : {}
Registrar           : {}
WhoisServerName     : whois.verisign-grs.com```

@RobBiddle
Copy link
Owner

@jonwbstr I'll likely merge in your changes regardless since it fixes a problem, but curious about your preference in output when a domain doesn't exist.

@RobBiddle RobBiddle merged commit 1b7b893 into RobBiddle:main Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants