Saturday, April 23, 2011

Virtual session on sysprep and PowerShell

I did a presentation for the virtual PowerShell chapter of SQLPASS (link HERE) last week.

I talked about using sysprep for creating quick OS images and also talked about the new sysprep support now in SQL Server 2008 R2.

My lab environment uses Hyper-V, so I try to practice using PowerShell as much as possible.  One thing I demo’d was a very basic/simple PowerShell script to:

  • Create a new VM
  • Change the default RAM
  • Copy a sysprep’d image to a new name
  • Attach a hard disk
  • Add a DVD drive
  • Attach an ISO to the DVD drive
  • Start the VM

Here’s the script:

import-module hyperv
new-vm -name foo
get-vm foo|set-vmmemory -memory 1024
copy-item "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\Server_sysprep_gold.vhd" `
"C:\Users\Public\Documents\Hyper-V\Virtual hard disks\Server_foo.vhd"
get-vm foo|add-vmdisk -controller 0 -lun 0 -path "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\Server_foo.vhd"
get-vm foo|add-vmdrive -dvd -controllerid 1 -lun 0
get-vm foo|add-vmdisk -dvd -controller 1 -lun 0 -path "C:\Users\Administrator\ISOs\sql_server_2008_r2.iso"
get-vm foo|start-vm

(Yes, I could have condensed some stuff, but that’s not the point I was trying to communicate.  I don’t see the point in condensing 10 lines of code to 5-6 at the expense of readability, and prefer to ease the PowerShell learning curve for newcomers.)

A few resources from the session:

Enjoy!  I’m not sure when the recording will be put online, but I’ll put a link to it…  I don’t talk a whole lot about PowerShell though.  Maybe just 10-15 minutes at the end.

Sunday, April 10, 2011

PowerShell: State of the Union

I’m not going to go that far back in history to rehash where PowerShell has come from, but I want to talk about where I think it is going.

I think it took the fact that the PowerShell icon now appears by default in Windows Server 2008 R2 for more people to start taking it more seriously.  PowerShell seemed to be talked about a way lot more last year than before.  More and more are starting to embrace it, and now that there are more Microsoft products that have been released since CEC 2009 (FYI HERE), there’s PowerShell almost everywhere in all the Microsoft (server-based) products.

I will highlight one (or two) disappointment(s) of late: System Center Configuration Manger 2012 (currently at Beta 2).  I can sympathize with some product teams though, especially when they already have an interface to automate just about everything already.  They want to concentrate on the next version of their products, versus PowerShell-izing everything.  I don’t expect to see any Microsoft-provided PowerShell cmdlets in SCCM 2012, but they seem to be working hard on their WMI interface, so at least the community can come to the rescue here (and already have with some PowerShell projects based on SCCM 2007 like Greg Ramsey). 

Now, that being said, the other System Center 2012 product in public beta is Virtual Machine Manager 2012 (currently at Beta 1), and its PowerShell support continues where VMM 2008 was: the GUI is written on top of PowerShell.  That means, there’s a cmdlet for *every* task, just like Exchange 2010 continues the tradition started with Exchange 2007.  I’ve seen public slides from recent events that have highlighted increased PowerShell support in System Center Service Manager 2012 and System Center Data Protection Manager 2012 also (neither being in public beta yet).

I might expect SQL Server to also never have full PowerShell functionality or take a few major releases before that happens.  I think we will see SQL Server Denali in the next 12 months, and it, to my knowledge, still won’t have a Add-Table cmdlet, for example.  Again, the community to the rescue, and there’s a *huge* community project led by the likes of Chad Miller who have brought PowerShell extensions for SQL.

Nonetheless, the “Father of PowerShell”, Jeffrey Snover, is now a major influencer (after a big promotion) in the Windows Server division.  I’m not basing this statement on any secret facts that I’m privied to, but I’m expecting Windows Server v.Next to *explode* in the number of features that have direct PowerShell administration functionality, and I’m hoping to be pleasantly surprised once the information starts to become public.  I’m not talking about having to wrap PowerShell around cmd.exe, Win32 API or P/Invoke, but having native cmdlets that provide all of the base OS tasks…