<commit_before>Write-Host "Ensconce - dnsHelper Loading"

function CheckName ([string]$dnsServer, [string]$domain, [string]$lookupName)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $lookupName
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -or ($item.Contains("3600 A")))
		{
			$outcome = $True
		}
	}
	$outcome
}

function CheckCNameValue ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $name /node
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -and ($item.ToLower().Contains($server.ToLower())))
		{
			$outcome = $True
		}
	}
	$outcome
}

function DeleteCName ([string]$dnsServer, [string]$domain, [string]$name)
{
	write-host "Deleting DNS CNAME record for $name.$domain"
	$result = dnscmd $dnsServer /recordDelete $domain $name CNAME /f
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -And $item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function CreateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	write-host "Creating DNS CNAME record for $name.$domain pointing at $server"
	$result = dnscmd $dnsServer /recordAdd $domain $name CNAME $server
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -And $item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function UpdateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	$outcome = $false
	if(DeleteCName $dnsServer $domain $name)
	{
		$outcome = CreateCName $dnsServer $domain $name $server
	}
	$outcome
}

function CreateOrUpdateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server, [bool]$warnOnUpdate = $false)
{
	$outcome = $false
	if(CheckName $dnsServer $domain $name)
	{
		if(CheckCNameValue $dnsServer $domain $name $server)
		{
			write-host "DNS CNAME record for $name.$domain already pointing at $server"
			$outcome = $true
		}
		else
		{
			if(UpdateCName $dnsServer $domain $name $server)
			{
				$outcome = $true
				if($warnOnUpdate)
				{
					write-warning "DNS CNAME record for $name.$domain updated to point at $ipAddress"
				}
				else
				{
					write-host "DNS CNAME record for $name.$domain updated to point at $server"
				}				
			}
			else
			{
				write-error "Failed to update DNS CNAME record for $name.$domain"
			}
		}
	}
	else
	{
		if(CreateCName $dnsServer $domain $name $server)
		{
			$outcome = $true
			write-host "DNS CNAME record for $name.$domain created pointing at $server"
			else
			{
				write-error "Failed to create DNS CNAME record for $name.$domain"
			}
		}
	}
	$outcome
}

function CheckARecordValue ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $name /node
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 A") -and ($item.Contains($ipAddress)))
		{
			$outcome = $True
		}
	}
	$outcome
}

function DeleteARecord ([string]$dnsServer, [string]$domain, [string]$name)
{
	write-host "Deleting DNS A record for $name.$domain"
	$result = dnscmd $dnsServer /recordDelete $domain $name A /f
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("3600 A") -And $item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function CreateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	write-host "Creating DNS A record for $name.$domain pointing at $ipAddress"
	$result = dnscmd $dnsServer /recordAdd $domain $name A $ipAddress
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("3600 A") -And $item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function UpdateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	$outcome = $false
	if(DeleteARecord $dnsServer $domain $name)
	{
		$outcome = CreateARecord $dnsServer $domain $name $ipAddress
	}	
	$outcome
}

function CreateOrUpdateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress, [bool]$warnOnUpdate = $false)
{
	$outcome = $false<commit_msg>Fix DNS helper as DNS cmd messages differ<commit_after>Write-Host "Ensconce - dnsHelper Loading"

function CheckName ([string]$dnsServer, [string]$domain, [string]$lookupName)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $lookupName
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -or ($item.Contains("3600 A")))
		{
			$outcome = $True
		}
	}
	$outcome
}

function CheckCNameValue ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $name /node
    
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 CNAME") -and ($item.ToLower().Contains($server.ToLower())))
		{
			$outcome = $True
		}
	}
	$outcome
}

function DeleteCName ([string]$dnsServer, [string]$domain, [string]$name)
{
	write-host "Deleting DNS CNAME record for $name.$domain"
	$result = dnscmd $dnsServer /recordDelete $domain $name CNAME /f
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function CreateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	write-host "Creating DNS CNAME record for $name.$domain pointing at $server"
	$result = dnscmd $dnsServer /recordAdd $domain $name CNAME $server
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function UpdateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server)
{
	$outcome = $false
	if(DeleteCName $dnsServer $domain $name)
	{
		$outcome = CreateCName $dnsServer $domain $name $server
	}
	$outcome
}

function CreateOrUpdateCName ([string]$dnsServer, [string]$domain, [string]$name, [string]$server, [bool]$warnOnUpdate = $false)
{
	$outcome = $false
	if(CheckName $dnsServer $domain $name)
	{
		if(CheckCNameValue $dnsServer $domain $name $server)
		{
			write-host "DNS CNAME record for $name.$domain already pointing at $server"
			$outcome = $true
		}
		else
		{
			if(UpdateCName $dnsServer $domain $name $server)
			{
				$outcome = $true
				if($warnOnUpdate)
				{
					write-warning "DNS CNAME record for $name.$domain updated to point at $ipAddress"
				}
				else
				{
					write-host "DNS CNAME record for $name.$domain updated to point at $server"
				}				
			}
			else
			{
				write-error "Failed to update DNS CNAME record for $name.$domain"
			}
		}
	}
	else
	{
		if(CreateCName $dnsServer $domain $name $server)
		{
			$outcome = $true
			write-host "DNS CNAME record for $name.$domain created pointing at $server"
        }
		else
		{
				write-error "Failed to create DNS CNAME record for $name.$domain"
		}
	}
	$outcome
}

function CheckARecordValue ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	$result = dnscmd $dnsServer /EnumRecords $domain $name /node
	$outcome = $False
	foreach ($item in $result)
	{
		if ($item.Contains("3600 A") -and ($item.Contains($ipAddress)))
		{
			$outcome = $True
		}
	}
	$outcome
}

function DeleteARecord ([string]$dnsServer, [string]$domain, [string]$name)
{
	write-host "Deleting DNS A record for $name.$domain"
	$result = dnscmd $dnsServer /recordDelete $domain $name A /f
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function CreateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	write-host "Creating DNS A record for $name.$domain pointing at $ipAddress"
	$result = dnscmd $dnsServer /recordAdd $domain $name A $ipAddress
	$outcome = $false
	foreach ($item in $result)
	{
		if ($item.Contains("Command completed successfully"))
		{
			$outcome = $true
		}
	}
	$outcome
}

function UpdateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress)
{
	$outcome = $false
	if(DeleteARecord $dnsServer $domain $name)
	{
		$outcome = CreateARecord $dnsServer $domain $name $ipAddress
	}	
	$outcome
}

function CreateOrUpdateARecord ([string]$dnsServer, [string]$domain, [string]$name, [string]$ipAddress, [bool]$warnOnUpdate = $false)
{
	$outcome = $false
{'fraction_non_alphanumeric': 0.14794841735052755, 'fraction_numerical': 0.005627198124267292, 'mean_word_length': 4.358668341708543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598349', 'n_tokens_mistral': 3316, 'n_tokens_neox': 3033, 'n_words': 766}