Tag: SQL Server

Get-Started with PowerShell for SQL Server Webinar on Wednesday June 17th

Know of anyone who is interested in PowerShell but not sure how to Get-Started? Next Wednesday, June 17th (One week from today), I'll be presenting a session on how to "Get-Started with PowerShell for SQL Server" for the PowerShell Virtual Chapter of PASS: The presentation begins at 11am CDT / noon EDT and I hope you'll join me. This is a beginner (intro) level session which will be presented via a Webinar. Sign up here. Update 6/18/2015 The video and presentation materials from this Read more [...]

Change the Recovery Model of a SQL Server database with the PowerShell SQL PSProvider

I recently set out to change the recovery model of a SQL Server database with PowerShell. There seems to be lots of information available on how to accomplish this task with PowerShell through SMO (SQL Server Management Objects) and using T-SQL wrapped inside the Invoke-Sqlcmd cmdlet. I even found lots of information about how to view the recovery model with the PowerShell SQL Server PSProvider, but when it came to actually changing the recovery model via the PSProvider, there was little if any information Read more [...]

PowerShell: When Best Practices and Accurate Results Collide

I'm a big believer in trying to write my PowerShell code to what the industry considers to be the best practices as most are common sense anyway, although as one person once told me: "Common sense isn't all that common anymore". I would hope that even the most diehard best practices person would realize that if you run into a scenario where following best practices causes the results to be skewed, that at least in that scenario it's worth taking a step back so you can see the bigger picture. I Read more [...]

PowerShell Track at SQL Saturday #328 in Birmingham Alabama this Weekend!

Do you work with technology and live within driving distance of Birmingham Alabama? Then you should consider attending SQL Saturday #328 this weekend. There’s an entire track dedicated to PowerShell and while a few of the sessions in that particular track will focus on SQL Server, there's also a session on PowerShell Fundamentals for SharePoint, a session on Stupid PowerShell Tricks by PowerShell MVP Jim Christopher, and a session on the new features in PowerShell version 5 that I’ll be presenting. I'll Read more [...]

Using PowerShell to discover information about your Microsoft SQL Servers

Earlier this week, I had an article published by PowerShell Magazine on the subject of "Using PowerShell to discover information about your Microsoft SQL Servers". Here's a brief description about that article: "In this article, I’ll be discussing how PowerShell can be used to retrieve just about any information that you would want to know about modern versions of SQL Server that you currently have running in your environment. This article isn't meant to be a deep dive, it’s meant to get Read more [...]

How to Create Reusable PowerShell Functions for Microsoft SQL Server Database Administration

In my last blog article on "Getting Started with Administering and Managing Microsoft SQL Server with PowerShell", I left off by introducing you to how to query information about your SQL Server using PowerShell with SQL Server Management Objects (SMO). In this blog article, I'll pick up where I left off and write a reusable PowerShell function to return information about SQL Server files and file groups while making the use of SMO transparent to the user of the function. I'm going to start Read more [...]

Getting Started with Administering and Managing Microsoft SQL Server with PowerShell

I've used PowerShell to administer and manage Microsoft SQL Server for quite some time although I haven't blogged much about it. I thought I would take the time to write a series of blog articles about using PowerShell to administer and manage Microsoft SQL Server to help others who are just getting started and to clear up some common misconceptions. Just to give you a little background information about myself, I've worked (professionally) in a data-center environment administering and managing Read more [...]

Use PowerShell to Create Active Directory User Accounts from Data Contained in the Adventure Works 2012 Database

This past Saturday, I presented a session at PowerShell Saturday 003 in Atlanta. Towards the end of the presentation, I created 290 Active Directory user accounts by using the information for employees contained in the Adventure Works 2012 database. This is actually a PowerShell script that I whipped up Friday night at the hotel after the speaker dinner. I populated some demographic information by joining multiple tables together from that particular database. There is more demographic information Read more [...]

Use Data Stored in a SQL Server Database to Create Active Directory User Accounts with PowerShell

I need a few Active Directory users created in my mikefrobbins.com test environment so I thought why come up with fake information when I could use information that I already have in a SQL Server database? The Employees table in the Northwind database looks like an easy enough candidate since all the data I need is in one table. This is about the concept and not about seeing how complicated I can make this process. Here's the type of information I'll pull out of this database to use for the Active Read more [...]

Querying a SQL Server Database from PowerShell

A few days ago, I wrote a PowerShell script on my computer that would ultimately be used on a different computer to automate a specific task. One of the things this script did was to query a SQL Server database which worked fine on my computer. After moving the script, it didn't take long to figure out that the other computer didn't have the necessary SQL PowerShell snap-in or module. My goal was to install the minimum features of SQL Server 2008 R2 to be able to run Transact SQL from PowerShell Read more [...]