Off to SQLPASS 2013!

SQL PASS Summit 2013

This year I’m volunteering at SQL PASS Summit 2013 as an MCT Volunteer, to assist those interested in certifying for SQL Server 2012.  Being an MCT means keeping up with certifications, which means keeping up with tests, and since 2002 I’ve certified on SQL 2000,2005 and 2008.

This May I achieved my MCSE: Data Platform this year, and working toward MCSE: Business Intelligence certification as well, with just one more test to go!

If you’re nervous about taking a Microsoft exam, just know you can do it, like thousands of other have. If you want help preparing to take a SQL Server exam, can you imagine a better place than the PASS Summit with thousands of smart SQL people there to help? Check out the PASS info page on MCP certification resources, like study hall, exam prep sessions,  practice exercises, and more.

I’m looking forward to meeting SQL people and absorbing the knowledge.  Also interested in exploring Charlotte and investigating the craft beer scene 🙂  Any one heading out there? I’ll buy the first round.

PowerShell brain teaser

I’ve been following the buzz about the PowerShell Scripting Games on Twitter, and came across this PowerShell brain teaser from beefycode.

Here’s my answer, wish me luck!

In PowerShell, when is the following statement true? Explain why.
 

     ( $a -eq $b ) -ne ( $b -eq $a )

 

The key to this puzzle can be found in PowerShell help:

 
help about_Comparison_Operators -ShowWindow
 
Here’s the relevant paragraph from the help result:
 

When the input to an operator is a scalar value, comparison operators return a Boolean value. When the input is a collection of values, the comparison operators return any matching values. If there are no matches in a collection, comparison operators do not return anything. 

 
When we use the -eq operator in PowerShell, most assume it’s the same as the equals sign (=) in other programming languages, and using it would return a boolean result, and would return $true if the compared values match, and $false of they do not. And it would make sense that the order variables are specified shouldn’t matter, so if $a -eq $b then of course $b -eq $a
 
But the paragraph from the help topic above tells us that -eq and other comparison operators perform an additional function; if one of the compared values is a collection, like an array, it will return any matching values in the array, rather than a boolean result.
 
Let’s take an example. If $a is an integer, and $b is an array that contains that integer, the expression ( $a -eq $b ) is like asking “Hey PowerShell, is this integer variable $a equal to this array $b?”. However, if I switch the variables around, the expression ( $b -eq $a ) is like asking “Hey PowerShell, what values in this array $b are equal to this integer variable in $a?”
 
This PowerShell behavior is how we could get a $true result for the brain teaser expression:
 ( $a -eq $b ) -ne ( $b -eq $a ), like so:

 PS C:\Users\Dave> $a = 1

PS C:\Users\Dave> $b = 1,2

PS C:\Users\Dave> $a.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType

PS C:\Users\Dave> $b.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array

PS C:\Users\Dave> $a -eq $b
False

PS C:\Users\Dave> $b -eq $a
1

PS C:\Users\Dave> ( $a -eq $b ) -ne ( $b -eq $a )
True

Any questions?

Great time at Florida .Net UG in West Palm

Whew! Presentation on PowerShell for Developers to the Florida .Net user group went well, and it was a very lively group. I went in expecting to dig deep into applying PowerShell for GUI application development, deployment and the like. But we had a lot of folks very new to PowerShell, and we had a very interactive presentation and discussion with lots of good questions. 

I instead focused on using the PowerShell 3 ISE as a starting point to new students to PowerShell, and taking advantage of this tool (along with the basic three Get Cmdlets, remember those? 🙂 ) to make those uncomfortable first steps to learning a new technology as easy as possible.

It is my hope that many in the group will get excited about learning something that’s not just a useful and marketable skill, but fun to do! If you attended and have follow up questions or need reminders of the resources I referred to, please contact me. I think the slides will be less useful than set of resource links to help learning the fundamentals of PowerShell. Looks like I have work to do….

I want to take a moment to thank thank three guys that provided me with some slides and demos to to share. Mike Robbins, Michael West, and Michael Cruz. (Yes, three Mikes helped me.) Thanks gents! Hope to ‘see’ you April 16th at our next Florida PowerShell user group virtual meeting!

Presenting PowerShell for Developers to Florida.net UG in West Palm

I’ve been asked to present to the Florida.Net user group in West Palm this week, and chose to present on PowerShell for Developers, and here’s why.

There are incredible possibilities and utility in PowerShell, most of the marketing and discussion on the web is for I.T. administrators, rather than developers (though there are some signs this is changing.) The conventional wisdom (and humor) tells us that people in I.T. must fit into either of these categories. Here’s another perspective.

As a consultant and trainer, I need broad familiarity with technology. I’m focused on Windows, with some geek love for Linux :). SQL Server is my technology focus, but Windows Server setup and configuration are important to ensure it runs well. I have built and also supported .Net applications that rely on SQL Server, so the Frameworks and how they connect and interact with my SQL Server are important as well. Like many I.T. professionals I work with many interrelated technologies, and staying effective means knowing about both administering my servers and developing and supporting applications.

So while the I.T. industry seems to push us to specialize, there will always be a place for people who excel in both systems administration AND development, particularly in small companies where wearing many I.T. hats is a necessity. And as the technology continues to develop, learning new technology is essential to staying relevant and valuable in the marketplace. But time is a limited resource, so getting familiar and productive quickly is essential.

This brings us to why I believe PowerShell to be so important, especially to developers. PowerShell is built on the .Net Framework, so developers get a jump on the rest of us in learning and applying it. While the learning curve can seem steep, with a basic knowledge of this tool you can then leverage the tools of others, to solve problems and develop new solutions quickly. Microsoft’s latest Server 2012 comes with dozens of PowerShell modules built in. There are PowerShell modules for Microsoft technologies like IISWindows Azure, and Hyper-V. But not just Microsoft:  Amazon AWS, VMWareDell Servers, and many other companies understand that leveraging PowerShell is good for the customer and for business. 

So any technology professional on the Windows platform, whether administrator, developer or somewhere in between, should seriously consider investing the time to learn PowerShell so they can be more effective.

I’m excited about PowerShell. I’ve just been learning it over the last few months, and it has already helped me solve problems for clients, and made me a better consultant. So my goal for my presentation this week is to introduce both the basics of PowerShell and its possibilities to the developers in attendance, so they might get excited about PowerShell and how they can leverage it to be better at what they do.

I’ve been too long without blogging… I mean, who really reads this stuff? But if you took the time to read this, please contact me or comment below and let me know what you think, and perhaps you can help inspire me to continue blogging regularly. 🙂 Thanks!

SQL 2012 and PowerShell 3 talk at Florida.Net UG

After some tuning I re-presented my talk on SQL 2012 and PowerShell 3 for the Florida.Net user group.

They let me ramble on much longer, so I had the chance to do more demos and step through the code more thoroughly.

Recieved some really great feedback, and saw more than a few people may have caught the PowerShell bug 🙂

The updated slides are on SlideShare.net.

If I get five or more requests via email or my contact form, I’ll post the code as well. Just want to check whether this internet thing is working….

SQL 2012 and Powershell 3 SFSSUG Talk

Spoke last night on SQL 2012 and Powershell 3 at South Florida SQL Server User Group today. Thanks guys for having me!

I had lots of content, and was ready to dive into changes from PowerShell 2 to 3, new SQL 2012 Cmdlets, and coding with SQL Management Objects. However most of the group was just starting out with PowerShell, so I had to shift direction, ended up talking more than demoing. 🙂  

Would be interested in doing a PowerShell 101 class for any user group interested in the future. PowerShell is just an incredible tool that any DBA, Server Admin or Developer should learn and apply.

I’ve posted the slides on SlideShare.net

I’ll post the demo code as well shortly if requested, it needs some cleanup before it’s ready to share.

SQL Alert when you’re low on disk space

I found this gem while troubleshooting a SQL Server with a backup drive that filled up often. It uses the WMI provider will alert when ANY drive on the server goes below 10GB. You can change the value ‘10000000000’ below to adjust this. You’ll also want to change your operator from ‘Support’ to your operator name. 

Note that this requires Database Mail to be set up with an operator and valid email. Should work for SQL 2005 thru 2012 as is, mine was set up on SQL 2005.

The ability to use WMI Provider in SQL Alerts seems very useful, I have seen uses for WMI SQL Alerts, but they involved more code than just creating the alert. If you’re interested in exploring the metrics WMI exposes to you, check out the WMI Tester included in Windows. There’s also more information in WMI at the Microsoft site.

Been using it for a while and thought to share it. I couldn’t locate the blog where I found it originally. If that’s you, let me know so I can thank you. If you have any other useful SQL Alerts that take advantage of WMI, please let me know as well.

USE [msdb]
GO
EXEC msdb.dbo.sp_update_alert @name=N'Disk Less that 10GB',
@message_id=0,
@severity=0,
@enabled=1,
@delay_between_responses=1800,
@include_event_description_in=0,
@database_name=N'',
@notification_message=N'',
@event_description_keyword=N'',
@performance_condition=N'',
@wmi_namespace=N'\\.\ROOT\CIMV2',
@wmi_query=N'SELECT * FROM __InstanceModificationEvent WITHIN 600 WHERE TargetInstance ISA "Win32_LogicalDisk" AND TargetInstance.FreeSpace < 10000000000', @job_id=N'00000000-0000-0000-0000-000000000000' GO --Replace Support with your Operator Name EXEC msdb.dbo.sp_update_notification @alert_name=N'Less that 10GB', @operator_name=N'Support', @notification_method = 1 GO