Fun with PowerShell: How to get SQL Server information

While I like the SQL Server PowerShell provider I have two issues with it.  First, it’s kind of limited, and second, it only installs with 2008 versions of SQL Server.  For these reasons I prefer to use the good old fashion SQL Server SMO namespace to do my dirty work.  That and we have a lot of SQL Server 2005 in our environment.

http://msdn.microsoft.com/en-us/library/ms162169.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.aspx

Digging around in the SQL Server SMO, Server namespace, I noticed there was this lovely “Information” property list and thought, “I bet I could do something pretty cool with that.”  Now when I say cool, I mean cool in the I’m-a-geek definition of the word, not in the I-was-cool-and-popular-in-high-school version of the word.  And so I wrote a nifty little program, which can easily be turned into a function, that pulls all your basic SQL Server information from a system.

Read More ⇒

Friday, August 27 2010   |   Tagged as: , , , , ,   |   James Kehr   |   Comments

iSSD and other small things

I picked this up from Engadget today and thought it was worthy enough to break my PowerShell blogging obsession long enough to blog about my real technology passion: hardware.

http://sandisk.com/about-sandisk/press-room/press-releases/2010/2010-08-18-sandisk-introduces-world’s-smallest-64gb-solid-state-drive—first-in-new-embedded-ssd-category

The iSSD is a new boot drive from SanDisk.  The iSSD is a postage stamp sized—for those old enough to remember postage stamps—solid state drive (SSD) that is soldered to the motherboard instead of inserted into a MiniPCI slot or SATA drive bay.  This is not a new idea, simply a better implementation of an old concept.

Sizes range from 4GB to 64GB and boast speeds up to 160 MB/sec seq. read and 100 MB/sec seq. write.  Not the fastest thing in the world, but plenty fast for a boot drive.

These little guys should do wonders for the tablet and ultra-slim notebook markets.  Devices like the iPad help get their small size from soldering the NAND flash directly to the motherboard.  The iSSD takes it a step further by providing a simple, all-in-one package that should make adding tiny boot storage to the motherboard cheap and easy for everyone.  Yay competition!

#James Kehr
Get-Member $OW | ?{$_.title -eq "System Administrator"`
-and $_.certification -contains 'MCITP:SA 2008, MCSE 2000, MCDST, Network+, A+'}

New-Variable -name company -value 'ORCS Web, Inc.' -description www.orcsweb.com | 1.888.313.9421’

Thursday, August 19 2010   |   James Kehr   |   Comments

Fun with PowerShell: Hyper-V Virtual Machine details

Before I begin I will make a full confession.  This code isn’t actually mine.  Not really.  I chopped most of it out of the PowerShell Management Library for Hyper-V.

http://pshyperv.codeplex.com/

Why would I do such a thing?  I generally dislike calling external files in my PowerShell scripts.  Not always, but most of the time.  The more external files you have the harder it is to make a script highly portable, and, under most circumstances, scripts should be highly portable with as few external dependencies as possible.  And so I ripped out Get-VM from hyperv.ps1 and turned it into a self-standing function called getVmDetails.

Read More ⇒

Wednesday, August 11 2010   |   James Kehr   |   Comments

Introducing the Advanced Virtual PC Controls for Windows 7

Last year I got a nice gift from Microsoft for attending TechEd in the form of a TechNet subscription.  After receiving my activation code I promptly upset my ISP by downloading everything I could get my hands on.  It was enough that I’m honestly shocked I didn’t get a call or get turned off.  Among those downloads was a product I had toyed with in the past but never really gotten in to, Windows Home Server (WHS).

For those not familiar with WHS it’s basically Miscrosoft’s home backup tool based off the Windows Server 2003 SBS operating system.  It includes the ability to backup your home computers, store shared files, stream audio/video, remote control your home machines from the Internet, and much more.  I had never really played with it before because I lacked the spare change to buy the necessary hardware.  Enter virtualization… 

Read More ⇒

Tuesday, August 10 2010   |   Tagged as: , , , , , ,   |   James Kehr   |   Comments

Saving perfmon templates in Windows Server 2008 [R2], Vista and 7

There is a slight change in the way perfmon (the lovingly short way of saying Windows Performance Monitor) templates work once you leave the XP/2003 domain.  In the old days Microsoft likes to put everything in these hard to dissect, custom bin files that you couldn't easily, or at all, modify without the aid of the Microsoft application.  Luckily they are leaving that model behind for one that is open and easy for administrators to automate with.  Enter the XML Dragon.

Read More ⇒

Tuesday, August 03 2010   |   Tagged as: , , , , , ,   |   James Kehr   |   Comments

Fun with PowerShell: IP address control for Windows forms

I've gotten pretty good at manipulating .NET with PowerShell, but I still have some annoyances.  Every once in a while I bump into a .NET control that does one of those VROOOOM maneuvers right over my head.  One such instance was the IP address controls I found on MSDN.  To be fair though I think these are more C or C# controls, but still.

Read More ⇒

Wednesday, June 02 2010   |   Tagged as: , , , , , ,   |   James Kehr   |   Comments

Fun with PowerShell: Add ToolTips to a Windows Form

While working on a new scripting project I came across a need to add a tool tip to a button.  As all good scripters do I started by searching the internet to see is anyone had done the work for me; alas, the only person I found who had successfully added a ToolTip to a PowerShell form had cheated by using Visual Studio - I didn't even know Visual Studio had PowerShell editing capabilities - so off I went in search of a method of adding ToolTips to PowerShell.

http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.aspx

ToolTip is the .NET term for those little informational balloons that pop-up when you hover the mouse over a button or icon or whatever.  They are used in far more than Windows Forms, but for the purposes of this article we'll stick to forms.  There are two kinds of ToolTip popup, a balloon and an OS default.

Read More ⇒

Wednesday, May 26 2010   |   Tagged as: , , , ,   |   James Kehr   |   Comments

Hello web, meet the free video codec!

Today, May 19th, may just be a historic day.  Not in the same way the printing press, the steam engine or VE-day were, but in a more geeky, technology way.  In fact, you probably won’t even see this story on CNN or MSNBC.  You may not have even known this event happened today unless you frequent sites like Slashdot, TechCrunch or Digg.  What is this big news?  The WebM project, a royalty-free, open source video codec released today by Google.

You see, there is this thing called a patent… we all know what patents are so I’ll skip a bit.  Patents make the business world go round.  They are good for profits and jobs, bad for small businesses and hobbyists who can’t afford to pay royalties and licensing fees which affect a large chunk of the Internet.  One of the heaviest patented software applications are video codecs, and while the Internet has been relatively royalty free when video comes into play it won’t stay that way forever.

Read More ⇒

Wednesday, May 19 2010   |   Tagged as: , , , , , , ,   |   James Kehr   |   Comments

PowerShell - $() update...meet the Subexpression Operator

I was poking around the PowerShell help files today and finally found the name of "$()" which I blogged about a while back.  Meet the Subexpression Operator, everyone!

$( ) Subexpression operator
  Description: Returns the result of one or more statements. For a
  single result, returns a scalar. For multiple results, returns an
  array. Examples:


      $($x * 23)
      $(Get-WMIObject win32_Directory)
 
To read more about the subexpression operator, and other PowerShell operators, type in "help about_operators" in PowerShell or follow one of the links below.
 
 
Sunday, May 02 2010   |   James Kehr   |   Comments

PowerShell stuff: Validating an IP address - Revisited

Every once in a while I write these huge blocks of code to do something really cool only to find out .NET has already got that built in.  Take my post from yonder days about validating an IP address…

http://www.orcsweb.com/blog/james/fun-with-powershell-testing-whether-an-ipv4-address-has-a-valid-structure/

It turns out .NET has already got that built in and all those lines of code can be condensed into this:


$ipAddress = “192.168.1.100”
$ipObj = [System.Net.IPAddress]::parse($ipAddress)
$isValidIP = [System.Net.IPAddress]::tryparse([string]$ipAddress, [ref]$ipObj)
if ($isValidIP) {
   Write-host “$ipAddress is valid”
} else {
   Write-host “$ipAddress is not valid”
}

For those who like the MSDN references you can take a gander at them here:
 
In the words of the great comedian Eric Idle, “That was easy!”  Mental note, search MSDN for .NET libraries before diving off into code that probably already exists.
 
#James Kehr
Get-Member $OrcsWeb | ?{$_.title -eq "System Administrator"`
-and $_.certification -contains 'MCITP:SA 2008, MCSE 2000, MCDST, Network+, A+'}

New-Variable -name company -value 'ORCS Web, Inc.' -description www.orcsweb.com | 1.888.313.9421’
Monday, April 26 2010   |   James Kehr   |   Comments

Subscribe

RSS FeedYou can subscribe to James Kehr feed via RSS to receive updates when new entries are posted.

@OrcsWeb

  • Thanks for the kudo shout-out! RT @leebrandt: I gotta say, @orcsweb has been really responsive in setting up my hosting stuff.
  • RT @julielerman: darling devs using EF: unless you're intimately aware of how EF works, please don't use long-running ObjectContexts in ...
  • RT @scottgu: Very cool VS extension that runs pages using different browsers: http://bit.ly/bvnj5b