New PowerShell scripts to share

I had a recent project where I needed to brush up on PowerShell, and I didn't find any other scripts shared online for my specific issue, so I thought I'd share what I came up with.

It's not particularly complex, but hopefully someone will find it helpful.

 

I put GetDataSet.ps1 together because I needed to be able get SQL records from an ODBC data source. I had read the System Center Central post on connecting to SQL with PowerShell, but it seemed like PowerShell has some built-in Microsoft SQL Server support that didn't apply to other data sources. I found a basic template PowerShell script for ADODB (ActiveX Database Objects) on the Hey, Scripting Guy! blog at TechNet. I had to customize the connection string for my specific ODBC driver, and I tried to leave this shared version of the script generic and commented so that you can tweak it for your own situation.

 

Another PowerShell script I use fairly regularly is checkProcess.ps1. It started as a basic kill process script, then I added the ability to more gracefully close down certain applications. After a while I realized I was also periodically starting some of these same apps, so I updated the script to be able to start them as well. One of the latest enhancements I owe to another System Center Central post, by Tenchuu, clarifying how the PowerShell count property behavior can change based on context. If nothing else, working on this script gave me excuses to work on nuance in PowerShell like checking arguments, write-progress, and declaring data types.

If you try out either of these scripts, let me know what you think by adding feedback to this post or using the Contact page.