<commit_before>Function Connect-SqlServer
{
<# 
.SYNOPSIS 
Internal function that creates SMO server object. Input can be text or SMO.Server.
#>	
	[CmdletBinding()]
	param (
		[Parameter(Mandatory = $true)]
		[object]$SqlServer,
		[System.Management.Automation.PSCredential]$SqlCredential,
		[switch]$ParameterConnection,
		[switch]$RegularUser
	)
	
	
	if ($SqlServer.GetType() -eq [Microsoft.SqlServer.Management.Smo.Server])
	{
		
		if ($ParameterConnection)
		{
			$paramserver = New-Object Microsoft.SqlServer.Management.Smo.Server
			$paramserver.ConnectionContext.ApplicationName = "dbatools PowerShell module - dbatools.io"
			$paramserver.ConnectionContext.ConnectionString = $SqlServer.ConnectionContext.ConnectionString
			
			if ($SqlCredential.username -ne $null)
			{
				$username = ($SqlCredential.username).TrimStart("\")
				
				if ($username -like "*\*")
				{
					$username = $username.Split("\")[1]
					$authtype = "Windows Authentication with Credential"
					$server.ConnectionContext.LoginSecure = $true
					$server.ConnectionContext.ConnectAsUser = $true
					$server.ConnectionContext.ConnectAsUserName = $username
					$server.ConnectionContext.ConnectAsUserPassword = ($SqlCredential).GetNetworkCredential().Password
				}
				else
				{
					$authtype = "SQL Authentication"
					$server.ConnectionContext.LoginSecure = $false
					$server.ConnectionContext.set_Login($username)
					$server.ConnectionContext.set_SecurePassword($SqlCredential.Password)
				}
			}
			
			$paramserver.ConnectionContext.Connect()
			return $paramserver
		}
		
		if ($SqlServer.ConnectionContext.IsOpen -eq $false)
		{
			$SqlServer.ConnectionContext.Connect()
		}
		return $SqlServer<commit_msg>Fixed bug: Didn't use credentials for parameter connections<commit_after>Function Connect-SqlServer
{
<# 
.SYNOPSIS 
Internal function that creates SMO server object. Input can be text or SMO.Server.
#>	
	[CmdletBinding()]
	param (
		[Parameter(Mandatory = $true)]
		[object]$SqlServer,
		[System.Management.Automation.PSCredential]$SqlCredential,
		[switch]$ParameterConnection,
		[switch]$RegularUser
	)
	
	
	if ($SqlServer.GetType() -eq [Microsoft.SqlServer.Management.Smo.Server])
	{
		
		if ($ParameterConnection)
		{
			$paramserver = New-Object Microsoft.SqlServer.Management.Smo.Server
			$paramserver.ConnectionContext.ApplicationName = "dbatools PowerShell module - dbatools.io"
			$paramserver.ConnectionContext.ConnectionString = $SqlServer.ConnectionContext.ConnectionString
			
			if ($SqlCredential.username -ne $null)
			{
				$username = ($SqlCredential.username).TrimStart("\")
				
				if ($username -like "*\*")
				{
					$username = $username.Split("\")[1]
					$authtype = "Windows Authentication with Credential"
					$paramserver.ConnectionContext.LoginSecure = $true
					$paramserver.ConnectionContext.ConnectAsUser = $true
					$paramserver.ConnectionContext.ConnectAsUserName = $username
					$paramserver.ConnectionContext.ConnectAsUserPassword = ($SqlCredential).GetNetworkCredential().Password
				}
				else
				{
					$authtype = "SQL Authentication"
					$paramserver.ConnectionContext.LoginSecure = $false
					$paramserver.ConnectionContext.set_Login($username)
					$paramserver.ConnectionContext.set_SecurePassword($SqlCredential.Password)
				}
			}
			
			$paramserver.ConnectionContext.Connect()
			return $paramserver
		}
		
		if ($SqlServer.ConnectionContext.IsOpen -eq $false)
		{
			$SqlServer.ConnectionContext.Connect()
		}
		return $SqlServer
{'fraction_non_alphanumeric': 0.11539560125678378, 'fraction_numerical': 0.0005712653527563553, 'mean_word_length': 4.211309523809524, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2621535', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1024, 'n_words': 170}