Buy vs. Build

PowerShell, Tools
It's the classic question faced by everyone in Information Services. I know how to do this and I could build software to do it, but I'm a lazy b_____d so I'd rather just pick up a piece of software that does it for me. I love working for large companies because I can usually get them to purchase stuff so that I can loll around stuffing my face all day instead of doing actual work. Unfortunately, not everyone can afford to pick up Microsoft's Operations Manager or Idera's Diagnostic Manager. But you still need to monitor your servers. With buy eliminated, that leaves build. Which, is where this excellent blog post by Laerte Junior comes in. He lays out how to build a wrapper around calls to get Performan Counter…
Read More

Powershell Script for Verifying Space

PowerShell
First let me say, I know my Powershell skills are sub-par. I'm working on it. Slowly but surely. That said, I had a problem to solve. It's one that I could have done with TSQL, but it would be very ugly TSQL, probably involving dynamic queries, and even for admin scripts, I try to avoid that. So, I went for SMO and WMI wrapped by Powershell to solve the problem. What was the problem you ask? We automate as many of our processes as we can. One process we do is resetting databases from production or other sources. Our processes work very well, but we occasionally run into a problem where the source system db has grown and the target system doesn't have the required disk space. So, we needed…
Read More

Powershell SMO Problem

PowerShell
We've been running the Enterprise Policy Management tools available from Codeplex for a few months now (Thanks to Buck Woody's (blog | twitter) session at the PASS Summit). They're honestly great. It's a fantastic way to use Policy Based Management on 2000 and 2005 servers. We did hit some issues with timeouts and looking at the script, it made a call to invoke-sqlcmd, but didn't pass the -querytimeout value. That means it default to 30 seconds and the import to database process was taking more than a minute for some of our queries. I did a little looking around and decided to just disable the timeout by passing a value of zero (0). But, I still got timeouts. Finally, after a bit of searching around, I found a closed (because…
Read More

Powershell for Batch Operations

PowerShell
I'm right in the middle of moving one of our databases from Oracle to SQL Server (and I just love saying that, over & over). Evidently the most common practice in Oracle is to leave all the tables as heaps. That's a tad bit problematic approach for SQL Server. We moved the structure from Oracle to SQL Server with almost no changes and now we're cleaning up the mess fixing the structure iterating the design. I needed to drop & recreate 250 plus indexes.  Remember, I'm lazy. A few minutes bouncing around the web and looking at the wonderful book "SQL Server 2008 Administration with Windows Powershell" and I put together a simple little script that generates a script for dropping and recreating all the primary keys on the tables and, as a…
Read More

Help with Learning Powershell

PowerShell
If you're not reading Buck Woody's blog, why not? Today he posted a helpful hint for getting performance counters directly out of PowerShell v2. I'll add a little bit to the hint, don't try running this on your XP boxes. It doesn't hurt anything, but you get a helpful little message "Get-Counter : This cmdlet can only run on Vista and above."
Read More

PowerShell Script for Creating Indexes

PowerShell, SQL Server, T-SQL
I needed to create an identical index on a bunch of tables within one of my projects (yes, I know this is problematic on multiple levels and I'm working on that too). Rather than sitting around typing this up, I decided to use PowerShell to do the work for me. I'm still very much learning how to do things in PowerShell so this took me almost as long as it would have to type them up, but now I know more than I did. Having gone through the pain of trying to find a good example on the web that did exactly what I wanted (they're out there, just hard to find), I decided I'd add this one in so the next person had at least one more source of…
Read More

Powershell White Paper

PowerShell
Allen White, who introduced me to the wonders of PowerShell at last year's PASS Summit, has published a white paper on using PowerShell within SQL Server 2008 with Microsoft. This is great news. If you're, as Brent Ozar so nicely put it, a noob like me in working with Powershell, this is going to be a great resource. Congratulations Allen, and thanks.
Read More

Powershell Blog Worth Reading

PowerShell
I don't usually make a big deal about my blog roll. I usually add either people I read regularly or people who ask to be added. I don't have a hierarchy of belonging & all that (yet). But I want to point out one that I just recently put up. Chad Miller, creator of SQL Server PowerShell Extension, blogs about SQL Server & PowerShell. If you're not already reading his stuff, you should. Unlike me, he really knows what he's talking about.
Read More

More PowerShell Basics

PowerShell
Because of the data center move, we have a number of different functions that we're running on totally different sets of servers on different days. None of this is part of our normal maintenance routines, so I've been using it as a great opportunity to stretch a little with PowerShell. I'm still learning, a lot. The latest task was to get the databases of a list of servers backed up. I initially tried it using SMO. It works great. But it's serial across all the servers as well as across the databases. I'm fine with serial backups on the databases (very, very fine, I saw a parallel backup of all databases once, pretty sparks, like the Fourth of July) but I really wanted all the servers to get backed up…
Read More

PowerShell Basics

PowerShell
I'm just learning how to use PowerShell. I've been trying to spend time with it over the last year, ever since I saw Allen White's presentations at the PASS Summit last year. I just haven't had the time. But recently, my company has been performing a multi-phased data center move. Because of it, I've needed to run tests & updates, disable jobs, all kinds of things on different sets of servers on different days. To paraphrase the old Superman cartoons "This looks like a job <voice gets deeper> for PowerShell." I'm not even remotely qualified to begin teaching anyone PowerShell. I had problems recently getting an IF conditional statement to work correctly. However, in the interest of sharing, in case you're thinking about picking it up (do) or you're actively…
Read More