MDT PowerShell database bulk import

Using PowerShell to read through a CSV file to add computer entries into the MDT 2010 Database

Tonight on Twitter there were a few mentions about a blog post importing computers in bulk into the MDT database using VbScript. The blog post in question was http://www.myitforum.com/myITToolbar/frame-click.asp?url=http://skatterbrainz.blogspot.com/2011/05/vbscript-bulk-import-for-mdt-2010.html

Skatterbrainz had to convert a PowerShell Module into VBScript. The module can be found here.

http://blogs.technet.com/b/mniehaus/archive/2009/05/15/manipulating-the-microsoft-deployment-toolkit-database-using-powershell.aspx

I use the scripts contained within this module all the time, here is the command I use to Bulk import my computer items.

I have a CSV file with my computer information.

With each heading being a setting used in the database.

image

I then run the following script.

Import-Module mdtdb

$assets = Import-Csv “.Book2.csv”
connect-mdtdatabase -sqlserver yourdatabaseserver -database MDTDB4

ForEach($asset In $assets)

{

new-mdtcomputer -serialnumber $asset.SerialNumber -settings @{OSInstall=’YES’; OSDComputerName=$asset.OSDComputername; _SMSTSORGNAME=$asset._SMSTSORGNAME}

}

This will run through the CSV file and add them names and settings to the MDT database.

If you need to add different settings, just add SETTINGNAME=$asset.SETTINGNAME within the { }

So quite an easy way to quickly import items into the MDT database.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: