Dan French
Dan French

Reputation: 1

Powershell Cannot find type [System.Data.DataTable]

I'm attempting to query a Microsoft SQL Server via PowerShell. I have version 4 installed.

I'm attempting to connect to a Microsoft SQL server database. I've done this before on a different computer. The first line of the script that worked before is.

$records = New-Object System.Data.DataTable

This generates this error

Error: New-Object : Cannot find type [System.Data.DataTable]: verify that the assembly containing this type is loaded.

I think I need something installed which makes the System.Data.DataTable available but I've not been able to figure out what it is.

Upvotes: 0

Views: 2881

Answers (1)

dpw
dpw

Reputation: 1586

You should load the SMO objects in order to run queries against SQL Server. As recommended in that article though, it's easier to import the SQLPS module.

Upvotes: 0

Related Questions