Powershell: Does System.Data.SqlClient.SqlDataAdapter usange in powershell need some ADO.Net installation? In PowerShell, goal is to query some data from Sql Server and put that into a preformatted Excel file. Towards that, the following PowerShell script snippet, throws an error saying "assemblies are missing".

From what I could gather online, SqlClient.SqlDataAdapter is part of ADO.Net, which does not require including any assemblies (as it is always present in the OS .Net framework installation). Is this correct? How do I rectify this?

...
... other connection code
...
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand;
$SqlCmd.Connection = $SqlConnection;
$SqlCmd.CommandText = $ActiveTransactions_Count_Query;

$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter;
$SqlAdapter.SelectCommand = $SqlCmd;

$DataSet_ActiveTransaction = New-Object System.Data.DataSet;
$SqlAdapter.Fill($DataSet_ActiveTransaction);
$DataSetTable = $DataSet_ActiveTransaction.Tables[0];
$DataSetTable


Error:

New-Object : Cannot find type [Sql.Data.SqlClient.SqlDataAdapter]: make sure
the assembly containing this type is loaded.
At M:\Build.ps1:21 char:25 + $SqlAdapter = New-Object &lt;&lt;&lt;&lt; 
Sql.Data.SqlClient.SqlDataAdapter;
    + CategoryInfo          : InvalidType: (:) [New-Object],
    PSArgumentException
    + FullyQualifiedErrorId :     TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Put this at the top of your script:

Add-Type -AssemblyName System.Data


Yes it's part of the OS, and no this is not normally required, but there must be some issue from the combination of your OS version + PowerShell version + SQL 2008 R2.