Month: December 2011

Kind of a misnomer, there are no cmdLets for powershell for litespeed. This strictly generates the strings required for doing recovery with Litespeed and either writes them out to the host or executes them by passing the commands to the sql server.

Here’s a quick script to set the model database grown & autogrowth settings. These settings are not a one-size fits all. They’re just better defaults for my environment than the defaults (which are terrible for any environment, IMHO). You must have SQLPSX installed for this to work.

Here is a quick script to find duplicate indexes on tables in sql server using powershell. You’ll need SqlPSX installed to run this. The output is not pretty, as it just writes to the host, but it works. I’ll leave it to you to write it to excel or whatnot. The code to write to excel can be found in my previous post.

Here’s a quick script to write your index sizes in KB to Excel in powershell. The code to write to Excel was pilfered from here. Obviously, this isn’t 100% accurate, as you’d have to execute the sys.dm_db_index_physical_stats function in detailed mode to get detailed information, but this is a good rough estimate.

I’ve been taking the sqlskills class this week (mind-numbingly good class btw, will post more later when my brain cools down) and lucky for me Aaron Nelson (blog | twitter) is taking the class as well. So, this gave me a chance to ask something which I’ve been trying to figure out how to replicate in powershell for a few months now. Naturally, it took him mere seconds to figure it out.

I’ve been wanting to replicate the functionality of the sql ‘in’ statement on the pipeline, but I could never get it to work correctly. Here is how you can get this to work. You’ll need SQLPSX installed to get this to work.

At first I was a bit perplexed at how this was working, but after a few cups of coffee it made more sense. What I had been confused about was the order of the statements in the where{} cmdlet. I had been of the mindset that the where{} was returning a set of objects. Obviously, this is not the case. All it is doing is filtering table arraylist.