Azure does Powershell too

Azure, PowerShell
Or, I guess it might be more appropriate to say that Powershell does Azure. Regardless, there are a set of commandlets for Azure and Azure SQL Database. Here's the link to get you started and the basic documentation. After that, it's a little tricky to know for sure what's required. Follow the instructions on the link to get the basic set up done, and then I'll show you just a little bit about how you can manage your Windows Azure SQL Database through PowerShell. First up, you need to set up a context, which is basically a connection to your Azure server. This requires very specific objects. The code below outlines what you need: $SQLLogin = new-object System.Management.Automation.PSCredential("UserName", ('12345' | ConvertTo-SecureString -asPlainText -Force)) $context = New-AzureSqlDatabaseServerContext –ServerName 'MyAzureServer' -Credential $SQLLogin…
Read More

Experimenting with Social Media

Professional Development
After multiple talks with Jason Strate (blog|twitter) and Denny Cherry (blog|twitter) about how they are working on automating more of their blogging and social media interactions, I'm going down that road... a little ways. The first thing that I'm trying out is Pocket. It's a way to capture web sites that you want to read later. You don't want to have to try to manage book marks in your browser. They all suck (and Google Chrome on the Mac sucks even worse) in this task. So this app lets you quickly mark a site and tag it for reading later. Further, you have an account that you can access from multiple devices. I'm already trying out two different readers that will work with Pocket on the Surface and I already…
Read More

SQL University: SQL Azure & PowerShell

Azure, PowerShell
Welcome once more to the Miskatonic branch of SQL University. I see that most off you survived out last encounter… uh, class. Most of you even appear somewhat sane… somewhat. Today we’re going to talk about PowerShell and it’s use with SQL Azure. Which sounds a something like an eldritch horror breaking in from some outer dimension… hmmm… that could explain certain things… So, back to Powershell and SQL Azure. You can’t run Powershell from SQL Azure. Thank you for attending and enjoy your trip home. Still here? I did try. Let’s clarify. You can’t run PowerShell from SQL Azure, but I didn’t say that you couldn’t use SQL Azure as a target for PowerShell. It is possible to connect to your SQL Azure databases running PowerShell from a local…
Read More

Powershell to Automate SQL Compare

Tools
A question came up on the SQL Server Central Forums, how could you use Red Gate SQL Compare to automate creating scripts for all your databases at once. What’s the first thing that popped into my head? Yep, Powershell. SQL Compare Pro comes with a command line utility that allows you to automate just about everything you can do with the GUI. I like to use it when I’m setting up deployment mechanisms for systems because it makes one click deployments possible. I won’t go into all the methods of that type of automation here. For a lot more information on that topic, check out the Team-Based Development book. If you’re interested in exploring how you can use the command line, just type this: sqlcompare/? Now is a good time…
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

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