Enable IIS7 under BitDefender 2009 Firewall Rules

Create the following rule and make sure that it’s positioned numerically “above” (i.e. lower number) than all the service.exe related rules… especially above the main “deny” rule at the last slot… i’m assuming we’re dealing with the System process because IIS7 (Windows Vista/Server 2008) moved the core listener daemon responsibility down to a lower level than W3SVC.exeimage  image image

PowerShell f’in rocks!

  • Main Microsoft landing page for PowerShell… download and install it!!  (if you’re running Windows Server 2008, it’s already loaded)
  • Out of the box executing PowerShell scripts is completely disabled for security… there’s a couple immediate tasks to enable…
    • Go find the PowerShell icon and fire it up… Vista (booo hiss!) > Start > Programs > Windows PowerShell 1.0 … Win7 (yay!) > Start > Programs > Accessories > Windows PowerShell
    • Turn on ability to run PowerShell script files via
      “Set-ExecutionPolicy RemoteSigned” … you’ll need to do this right up front (only once) since this is locked down by default
    • Download and install the PowerShell Community Extensions (PSCX)… all kinds of baseline goodies
    • The PSCX install will establish a default “profile.ps1” script that establishes a bunch of handy default shell and script functionality
    • Profile.ps1 lives here: “%USERPROFILE%My DocumentsWindowsPowerShellProfile.ps1” (don’t worry, Vista maps “My Documents” to the appropriate new physical folder for backwards compatibility with XP)
  • One of the main advantages that PowerShell provides beyond previously existing scripting technologies (Windows or otherwise) is this: they’ve taken the power of command line piping and implemented it at an object oriented level versus simple flat text… this alone makes PowerShell game changingly more powerful than what Unix/OS X/Linux could lay claim to fame.
    • For an immeidate mental example to take in how profound this is… take a common task like piping LS to SORT so that you can sort by file size (ls does not support file size sorting via an argument)… eg:
    • ls -al | sort +4nr
    • the problem is (as this immediate Google hit proves) that this depends on hard coding which column of the flat text output you want operate on
    • PowerShell elegantly eliminates this issue by allowing us to pass true data structures along the pipeline such that we can cleanly sort on the “size” property!!  not some random column of flat text… eg:
    • PS C:> dir | sort-object Length –descending
    • Is that not freaking beautiful or what!?!?  They’ve really taken some effort to make the commands and syntax humanly readable… i think that is giving a big nod to the fact that the unfortunate evolution of Windows has created a class of so called Sys Admins that are dismally dependent on clicking pretty buttons rather than automating away their recurring issues
  • We get full access to everything in the .Net Framework from a friendly script syntax… there’s already a gaggle of PowerShell wrappers (aka “cmdlets”) that hide the uglier details of accessing Windows Registry, Web Services, XML, WMI, Active Directory, Exchange Server, SQL Server Admin, SharePoint… on and on
  • Cmdlets are just more PowerShell code bundled in a subroutine (plus .Net “snapin” DLLs where needed) so there has been tons of rapid adoption where folks are creating nice pretty PowerShell cmdlet wrappers around everything with more and more publicly available cmdlet libraries all the time.
  • Windows Forms via PowerShell is pretty cool… PowerShell’s script is a pretty easy flowing syntax that washes away the usual pain of stuff like declaring variables of the proper type and has loads of friendly libraries available to do all the heavy lifting… marry that with .Net Forms GUIs and you can get some nifty stuff rolling in a day…
  • See my first script below… it does a nice batch of meat and potatoes ditch work in about 75 short lines of fairly readable code
  • Invoke-Win32” – The code gods have already built us an awesome “function which uses code generation to dynamically create a .Net P/Invoke definition” so that we can fire Win32 API’s on a whim! Toss just the Invoke-Win32 function from that page into your Profile.ps1 right after everything else.
  • Hide-PowerShell() – (code posted below) very handy for hiding the PowerShell console when all you really want to see is the Window Forms stuff you threw together… just toss this short code into your Profile.ps1 as well
  • PowerShellPlus – very nice IDE with gonzo Intellisense & context Help for E-VER-Y-THING in da Shell… love it… running 2.1.0.45 Beta, hasn’t crashed once. [Update: 21 Sep 2010] Looks like they’re already up to v3.5
  • [Update: 21 Sep 2010] Windows 7 includes a very decent IDE for free: Start > Program > Accessories > Windows PowerShell > Windows PowerShell ISE

My First PowerShell Script (awww aint she a cutie 😉

  1. Hits SQL Server to pull a list of data via the ol’ ADO.Net APIs
  2. Pings all those machines to determine if they’re online (currently commented out but it runs quite fast),
  3. Throws the list into a simple Windows Forms ListBox for user selection
  4. and finally sets a registry entry (an ODBC System DSN Server entry) based on the chosen selection & launches a an app

This little ditty is a great example for scripting… it wrappers another legacy app with a front end that compensates for something lacking.

Hide-PowerShell 

$cn = new-object system.data.SqlClient.SqlConnection("Data Source=blah;User ID=blah;Password=blah"); 
$ds = new-object "System.Data.DataSet" "dsTaxOffices" 
$q = "SELECT Name + ' ('+Code+')' as Name, IPAddress FROM master.dbo.TaxOffices (nolock) where Active = 1" 
$da = new-object "System.Data.SqlClient.SqlDataAdapter" ($q, $cn) 
$da.Fill($ds) 

# ping each box to see who's online 
#foreach($row in $ds.Tables[0].Rows) { 
# $ipaddress = $row["IPAddress"] 
# $ping_result = Get-WmiObject -Class Win32_PingStatus -Filter "Address='$ipaddress'" 
# if ($ping_result.StatusCode -ne "0") { 
# $row["Name"] = $row["Name"] + "`t* offline *" 
# } 
#} 

# Load Windows Forms Library 
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 

#pointer for easy debug message box popups 
$mb=[Windows.Forms.MessageBox] 
#$mb::Show("you clicked me! ", "Message") 

# Create Window 
$form = new-object "System.Windows.Forms.Form" 
$form.Size = new-object System.Drawing.Size @(300,377) 
$form.topmost = $true 
$form.text = "Choose Office" 
$form.FormBorderStyle = "FixedToolWindow" 
#$form.add_load({ 
    #$mb::Show("onload", "onload") 
# $form.WindowState = "Normal" 
#}) 

# Create Flow Panel 
#$panel = new-object "System.Windows.Forms.flowlayoutpanel" 
#$panel.Dock = [System.Windows.Forms.DockStyle]::Fill 
#$form.Controls.Add($panel) 

# Create Controls 
$lst = new-object System.Windows.Forms.ListBox 
#$lst.FormattingEnabled = true; 
#$lst.TabIndex = 0; 
$lst.Location = new System.Drawing.Point(3, 3); 
$lst.Name = "listBox1"; 
$lst.Size = New-Object System.Drawing.Size @(285, 320); 

# databind list of offices to listbox 
$lst.ValueMember = "IPAddress" 
$lst.DisplayMember = "Name" 
$lst.DataSource = $ds.Tables[0] 

$btnSelect = New-Object System.Windows.Forms.Button 
$btnSelect.Location = New-Object System.Drawing.Point @(65, 325) 
$btnSelect.Name = "button1"; 
$btnSelect.Size = New-Object System.Drawing.Size @(159, 23); 
#$btnSelect.TabIndex = 1; 
$btnSelect.Text = "Select"; 
#$btnSelect.UseVisualStyleBackColor = true; 
$form.AcceptButton = $btnSelect 

$btnSelect.add_click({ 
    Set-ItemProperty hklm:softwareodbcodbc.iniitraac Server $lst.SelectedItem.IPAddress 
    Get-Process | Where-Object {$_.Name -eq "itraacw32"} | kill 
    sleep 1 #wait a sec for the old process to really drop off, otherwise new one collides and stops itself 
    start "C:Program FilesiTRAAC ConsoleiTRAACw32.exe" 
    $form.Close() 
}) 

# Add controls to Panel 
$form.Controls.Add($lst) 
$form.Controls.Add($btnSelect) 

# Show window 
$form.showdialog()

Everybody needs a picture right?

image

Hide-PowerShell() script source

function ShowWindowAsync([IntPtr] $hWnd, [Int32] $nCmdShow) 
{ 
  $parameterTypes = [IntPtr], [Int32]  
  $parameters = $hWnd, $nCmdShow 
  Invoke-Win32 "user32.dll" ([Boolean]) "ShowWindowAsync" $parameterTypes $parameters 

    # Values for $nCmdShow 
    # SW_HIDE = 0; 
    # SW_SHOWNORMAL = 1; 
    # SW_NORMAL = 1; 
    # SW_SHOWMINIMIZED = 2; 
    # SW_SHOWMAXIMIZED = 3; 
    # SW_MAXIMIZE = 3; 
    # SW_SHOWNOACTIVATE = 4; 
    # SW_SHOW = 5; 
    # SW_MINIMIZE = 6; 
    # SW_SHOWMINNOACTIVE = 7; 
    # SW_SHOWNA = 8; 
    # SW_RESTORE = 9; 
    # SW_SHOWDEFAULT = 10; 
    # SW_MAX = 10 
} 
function Show-PowerShell() { 
  $null = ShowWindowAsync (Get-Process -Id $pid).MainWindowHandle 1  
} 
function Hide-PowerShell() {  
    $null = ShowWindowAsync (Get-Process -Id $pid).MainWindowHandle 0  
} 
function Minimize-PowerShell() {  
    $null = ShowWindowAsync (Get-Process -Id $pid).MainWindowHandle 2  
}

SQL Server "CHECKSUM()"

Absolutely crazy I hadn’t run across this little gem yet… could’ve used that bugger to get out of a couple jams.  e.g. eliminating heavily duplicated xml blobs that represent incoming supply chain events/transactions.  The BOL has a couple examples to get your juices flowing.  e.g. Run it on a column list, CHECKSUM(*), to compare rows.  There’s also BINARY_CHECKSUM(), HashBytes() and CHECKSUM_AGG() for different slices.

Nifty 'WhatIsMyIP' Script – put current WAN IP on Clipboard

Pre-req’s:

  • 4NT – love love love that little bugger… but i guess PowerShell is probably the new cool kid in town for this kind of stuff 
    • ‘echos’ command in 4NT outputs test w/o a linefeed… so I can tack something else I wanted onto the URL… obviously the sky is your limit (can’t find the equivalent in PowerShell yet??)
  • curl – everybody’s favorite web mashup tool

echos http:// >clip:
curl -s "http://whatismyip.org" >>clip:
echos /training >>clip:

Awesome, CAD for LEGOs!

ok i know it’s been around for ages apparently… but man that’s awesome anybody do a hard drive cage in the "technic" rivit oriented pieces yet? 🙂 highlights:

  • it actually "knows" when you put two technic "i-beams" together on a rivet pivot point… it’ll rotate them in 3D so you can line things up with true geometry!
  • it adds up the whole parts list and gives you a total price to physically manifest your creation <nifty>
  • people can & are publishing their custom designs
  • it copies multi-part "bundles" and flips/rotates them easily to construct symmetric objects quickly

Get Started

Volume Shadow Copy Service is Pretty Cool

(at least in Windows 2008) More specifically the "Previous Versions" functionality that leverages this service. To cut to the chase, I didn’t realize that you could browse into whole folders worth of snapshots… screenshot below says it all… Notice that there’s a funky "localhostdrive$@GMT…" syntax for getting at the old version of that folder… in this case I shadowed the entire drive starting at the root level. After Googling around a little more on this I’m starting to think us Winblows users shouldn’t be quite so OSX TimeWarp jealous and that VSS although not as sexy, is perhaps even more robust. In case you have no idea what I’m talking about this is a built in file level "snapshot" feature at the OS level… we get to recover the previous version of any file that’s been snapshot this way… I’m not sure yet but I think one might be able to turn it on so that a snapshot automatically occurs whenever you modify a file. image It’s kinda tucked away … you have to manually go and turn it on under the Properties of your drive letters: image Here we can create snapshots manually of course. And you’ll want to check out the snapshot schedule under Settings button which defaults to weekly… might wanna make that more often 😉 One quickly realizes the best strategy is not to simply blindly shadow your whole drive but to define a frequent schedule on your documents and development type folders … pick and choose like that depending on the specific content. The help is quick to point out its something to be used in tandem with normal backups and is not a replacement.

(Fairly) Quick & Painless Streaming of Your Local Audio

Here’s the basic pieces I plugged together:

  • MediaMonkey is my preferred mp3 player: www.MediaMonkey.com
    1. MediaMonkey supports WinAmp API plugins which provides an excellent pool to draw nifty add-ons from
  • EdCast (formerly “OddCast”) comes in various implementations, one of which is a WinAmp plugin that sends your current song to a ShoutCast (or IceCast) server: http://www.oddsock.org/tools/edcast/
    1. I chose the EdCast plugin versus ShoutCast’s own plugin because EdCast got the song name and artist to come through Media Monkey and ShoutCast’s plugin has a known issue that this feature only works with WinAmp
  • ShoutCast DNAS (Distributed Network Audio Server) – streams the audio out to clients: http://www.shoutcast.com/download-files

Install/configure/run:

  • Drop the EdCast plugin into Program FilesMediaMonkeyPlugins
  • Fire up your Monkey and get some tunes rolling
  • Then in Monkey > Tools > Options > Player > DSP Plugins > edcast DSP…
    1. Click on the meter in the middle of the dialog to turn on the
      broadcast
    2. Hit “Add Encoder” and then right click the entry to configure for MP3 and
      localhost, change password to what you want
    3. Personalize your stream on the YP Settings
  • Now install the ShoutCast server and fire that up
  • Cruise through the config file via the menu option in that GUI… it’s very self explanatory and all the defaults are good… probably just have to make sure you get the password lined up with what you put in the plugin config
  • Then just browse to http://yourserveraddress:8000/listen.pls from another machine and it’ll fire up your local media player (if you’ve got .pls associated of course)
  • There’s some interesting stuff kicked out as a default web page if you browse to http://yourserveraddress:8000… including an admin page where you can monitor listeners, etc.
  • The default DNAS config automatically publishes you to the global ShoutCast directory (so you might want to watch your intake from that vector victor 🙂
  • PS- The main reason I did this was so I could listen to my tunez at work w/minimal effort 🙂

The Origin of VirguleStar.com

I’m drafting off the idea of expanding geeky punctuation into words (popularized by www.SlashDot.org)
(Funny story behind his originating motivation)
so SlashDot equals /.

Based on that, being a comment happy developer, I thought an expansion of /* would be particularly apropos as that’s the well known opening comment syntax in languages like C, C++, C#, Java, T-SQL, etc.

Of course, SlashStar.com and readily desirable derivates were already taken 🙁 … however, browsing for slash synonyms turned up "virgule", specifically for the forward slash character, nice!… yeah ok, it doesn’t role off the tongue but its obscurity meant I had an available domain name hit and that’s obviously key! 🙂

And thus www.VirguleStar.com was born.

Canon’s consumer inkjet printer + scanner workhorses

This is the Canon MP830 that I got two years ago for ~$200:
 

As of 07 Oct 2009 it’s now the MX860 that’s sitting in that slot… progress marches on 🙂
 

As with all this consumer electronics cr_p there’s no guarantees it’ll be all sunshine and daisies…The initial unit I received had some serious problems that can now confidently chalk up to a solid lemon syndrome… I returned it and the brand new replacement I got back has had absolutely zero issues and is still cranking like a champ as of Q4 2009! This model prints very decent photos… not tippy top commercial quality but pretty darn good on glossy paper. Paper seems to matter as much as ink… I’ve seen fading on some glossy stock hanging on the wall next to other stock that hasn’t.   Make sure to checkout my Continuous Ink Supply System write up