Blog Archives

Creating a WCF Net.TCP Service and Client using PowerShell

I’m currently attending Regis University for my grad degree, and just finished up a networking class. For my final, I chose to explore the Windows Net.TCP Port Sharing Service. I had this glorious vision of translating some C# code to

Posted in PowerShell

Using .NET DataTable Computes and Column Expressions in PowerShell

As a SQL Server DBA, I’m used to SQL being able to perform aliasing, super fast subselects, and easy aggregation. My most recent project, Invoke-Locate.ps1, however, uses SQLite because of its portability and speed when performing simple selects and inserts.

Posted in PowerShell, SQL Server

Working with Basic .NET DataSets in PowerShell

This is mostly for my reference, but you can use it, too :) Create Basic Datatable

Create Basic DataSet (Collection of Tables)

Selecting

Create Datatable from CSV Using this method, you can add 140k rows a second.

Posted in PowerShell

Find Duplicates in PowerShell Datatable using LINQ

I don’t have a practical application for this method, but I wanted to figure out how to do it anyway. Doing so was frustrating but kinda fun. It forced me to learn about lamdas in PowerShell which I’ll probably use

Posted in PowerShell

High-Performance Techniques for Importing CSV to SQL Server

If you’ve ever tried to use PowerShell’s Import-CSV with large files, you know that it can exhaust all of your RAM. Previously, I created a script on ScriptCenter that used an alternative tecehnique to import large CSV files, and even

Posted in PowerShell, SQL Server

Quickly Find Duplicates in Large CSV Files using PowerShell

Update 1/18/2015: This native PowerShell script can process over 165,000 rows a second. I’m so pumped. My million row CSV with 9k dupes processed in 6.4 seconds. I actually tried this using LINQ in PowerShell, but it seemed exponetially slower

Posted in PowerShell

Professional PowerShell-based SQL Server SMO Recipes

Last year, I finally started working with SMO (SQL Management Objects) within PowerShell and I absolutely love it. Below are a few recipes that I created and use extensively throughout my SQL Management scripts, which you can find on ScriptCenter.

Posted in PowerShell, SQL Server

Enumerate file structure within detached MDF database file using SMO

While researching how connect to a detached MDF and read the internal file structure of the internal files, including LDF files, I kept seeing suggestions for using the undocumented DBCC command DBCC checkprimaryfile. Initially, my code looked like this:

Posted in PowerShell, SQL Server