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

A Lack of Excitement

PASS, PowerShell, SQL Server, T-SQL, Tools
I usually use all the problems, crashes, and issues that I run into at work as grist for my mill, aka, material to blog about. But lately, we haven't been crashing & burning much <knock wood, turn three times, throw salt over my left shoulder, spit>. But it was suggested that may be I should mention why that is. The fact of the matter is that I've been spending a lot more time working on methods for monitoring our systems so that we avoid more of the stupid stuff, full disks, failed backups, long running agent jobs, etc.. I've blogged before about our use of Microsoft's Operations Manager for monitoring our servers and how we've built custom rules and monitors to keep an eye on things. I've also mentioned how…
Read More

Two Book Recommendations

PowerShell, SQL Server
I have two new books that I can heartily recommend. This isn't a review of either book since I've only just started reading them. However, I've used each to solve a couple of small problems within a day of having them on the shelf. To me, that proves their worth. First up is Michael Coles new book "Pro SQL Server 2008 XML." I'm still a bit jittery with XQuery... OK, I have a hard time writing XQuery and I have to look up how to do every step and I still get things wrong. Anyway... There are two entire chapters devoted to how to use XQuery and an appendix with an XQuery & XPath reference. Great stuff. Look for an extended review several weeks from now after I've had a chance to…
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