Teradata Connectivity Using Windows PowerShell

Connectivity

Re: Teradata Connectivity Using Windows PowerShell

  exception.png

 

here is the hole exception

New Member

Re: Teradata Connectivity Using Windows PowerShell

It's possible use this script with Teradata Wallet? I try but don't have sucess.

 


@NetFx wrote:
param(  [string] $sqlCommand = $(throw "Please specify a query."),
        [System.Management.Automation.PsCredential] $credential,
        [string] $dataSource = 'YourSystemName')

if ($credential)
{
    $plainCred = $credential.GetNetworkCredential()
   
    $authentication = ("User Id={0};Password={1};" -f $plainCred.Username, $plainCred.Password)
}

Add-Type -assemblyname system.data

$factory = [System.Data.Common.DbProviderFactories]::GetFactory("Teradata.Client.Provider")

$connection = $factory.CreateConnection()

$connection.ConnectionString = "Data Source = $dataSource;Connection Pooling Timeout=300;$authentication"
$connection.Open()

$command = $connection.CreateCommand()
$command.CommandText = $sqlCommand

$adapter = $factory.CreateDataAdapter()
$adapter.SelectCommand = $command

$dataset = new-object System.Data.DataSet

try
{
    [void] $adapter.Fill($dataset)

    $dataset.Tables | Select-Object -Expand Rows
}
finally
{
    $connection.Close()
}

1- Install the .NET Data Provider for Teradata

2- Save the code to a file; e.g. Invoke-SqlCommand.ps1

2- Change the third Parameter to your system name.

3- Create a PsCredential object: $cred = Get-Credential

4- Execute a SQL Command: .\Invoke-SqlCommand 'HELP SESSION' $cred


 

Tags (2)
Teradata Employee

Re: Teradata Connectivity Using Windows PowerShell

No, the ".NET Data Provider for Teradata" does not directly integrate with the Teradata Wallet. 

However PowerShell supports DP-API which is the same technology Teradata Wallet uses on Windows. 

Search for PowerShell DPAPI and Password; you will find lots of how-to articles.