Powershell

PowerShell: Invoke-SqlCmd4 - A Superior SQL Commandlet

PowerShell: Invoke-SqlCmd4 - A Superior SQL Commandlet

Note: This is part of a series of posts where I’m improving some of my older blog posts.

Recently, I wrote about one of the issues with the Invoke-SqlCmd commandlet where it sets the ApplicationName when you use the parameter that should set the host.

Fellow MVP Ben Miller sent me a copy of the Invoke-SqlCmd3 that they were using. It was much better.

I then realized that there were many other options missing from these commandlets (such as options for Database Mirroring and Availablity Groups) and so I set about improving it.

2026-07-01

PowerShell: New-Object : Constructor not found. Cannot find an appropriate constructor for type

PowerShell: New-Object : Constructor not found. Cannot find an appropriate constructor for type

This blog post is here so that I don’t forget it in future.

I’ve been writing Powershell again all day today and I spent ages trying to find this error when instantiating a particular object.

Bottom line is that there was a valid constructor that took a single string argument. However, I was passing an empty string to the constructor. I won’t tell you what I really think about that error message. Let’s just leave it at The error message returned is interesting.

2025-08-26