Hello There,
We have imported Domain Expiration Application from Thwack Community, when tried to configure and execute the command we are getting the below error. Can some one from this community look into it and suggest us some solution.
Script:
$domain = $args[0];
if ($domain -eq $null)
{
Write-Host "Message: Can't find ""domain"" argument. Please provide full domain name from .com, .net or .edu root domains. For example: solarwinds.com";
exit 1;
}
if (($domain -match ".com$") -or ($domain -match ".net$") -or ($domain -match ".edu$"))
{
try
{
$web = New-WebServiceProxy ‘www.webservicex.net/whois.asmx
}
catch
{
Write-Host "Message: Failed to create Web Service object. Try to use New-WebServiceProxy command locally.";
exit 1;
}
try
{
$out = $web.GetWhoIs($domain);
}
catch
{
Write-Host "Message: Failed to get statistic for $domain.";
exit 1;
}
if ($out -match "No match for")
{
Write-Host "Message: No match for $domain.";
exit 1;
}
$tmp=$out -split "Expiration Date: ";
$tmp2=$tmp[1] -split " ";
$site_date=$tmp2[0] -split "-";
$site_day=[int]$site_date[0];
$site_month=[string]$site_date[1];
$site_year_tmp=$site_date[2];
$site_year=$site_year_tmp -split "\n";
$site_year=[int]$site_year[0];
switch ($site_month)
{
"jan" {$site_month=[int]1; break;}
"feb" {$site_month=[int]2; break;}
"mar" {$site_month=[int]3; break;}
"apr" {$site_month=[int]4; break;}
"may" {$site_month=[int]5; break;}
"june" {$site_month=[int]6; break;}
"jun" {$site_month=[int]6; break;}
"july" {$site_month=[int]7; break;}
"jul" {$site_month=[int]7; break;}
"aug" {$site_month=[int]8; break;}
"sept" {$site_month=[int]9; break;}
"sep" {$site_month=[int]9; break;}
"oct" {$site_month=[int]10; break;}
"nov" {$site_month=[int]11; break;}
"dec" {$site_month=[int]12; break;}
default {Write-Host "Message: Unknown month of site expiration.; exit 1;";}
}
$current=Get-Date;
$cur_day=$current.Day;
$cur_month=$current.Month;
$cur_year=$current.Year;
$site_total_days=$site_day+$site_month*30+$site_year*365;
$cur_total_days=$cur_day+$cur_month*30+$cur_year*365;
$stat=$site_total_days-$cur_total_days;
$mess=[string]$site_month+"/"+[string]$site_day+"/"+[string]$site_year;
Write-Host "Statistic: $stat";
Write-Host "Message: Expiration Date: $mess";
exit 0;
}
else
{
Write-Host "Message: Not accepted domain. Please provide full domain name from .com, .net or .edu root domains.";
exit 1;
}
Error
