Press "Enter" to skip to content

Select Indistinct

TIL – October 22 2016

Been a few days of learning since I last wrote one of these, but I have come back to the automatic variables page on the PowerShell documentation enough times that I think I should just blog the important parts for myself.

  • $? – TRUE/FALSE if the last thing you did succeeded.
  • $_ – Something everyone uses in posh, current pipeline object.
  • $Args – all the undeclared params passed to a function, try to avoid.
  • $Error – the array of error objects that represent a stack of the most recent errors. use $Errors[0] to get the most recent error.
  • $Home – full path of home directory of the current user.
  • $Host – methods to access information about the host we are running the PowerShell command on.
  • $Matches – used with the -(not)match operators, is populated with a hash table of the matched values.
  • $MyInvocation – name, params, values, and information about the current command. Super useful for weird introspection.
  • $OFS – Output File Separator, allows you to set the default file separator for array operations. Generally better to set variables to send to split, this can have downstream effects if you dont change it back.
  • $PID – PID of the process hosting the current PowerShell process.
  • $PSBoundParameters – Nice shortcut to refer to all the params to another script or function.
  • $PsCmdlet – mostly used in advanced functions to access the current running cmdlet’s properties.
  • $PSCommandPath – full path and file name of the script being run.
  • $PSDebugContext – if $null, debugger is not running.
  • $PsHome – path to PowerShell install dir.
  • $PSScriptRoot – directory where script is being run from, avoid if you want to support ps2.
  • $PsVersionTable – returns read only hash table about the current ps session.
  • $Pwd – a path object representing the current directory.
  • $StackTrace – shortcut for the stack trace of the most recent error.
  • $This – refers to an object that is being extended in a script property or method.
  • $true/$false/$null – use boolean login on all of these, nothing new here.

Read (slightly) more at about_Automatic_Variables

TIL – July 7 2016

Today I learned that VS Code (while awesome) has a few kinks to work out if you want to mix old and new powershell idioms, and its not 100% straightforward how to fix it.

To get to this point I already downloaded Windows Management Framework 5.0 (the announcement on the VS Code site points to a dead link), got VS Code, upgraded Git, and installed the Posh utility when I opened my first file and it suggested I download the extension (pretty cool that.)

I started off having a blast, but as soon as I used Invoke-SQLCommand things got a bit messy:

"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."

I have seen this error before and it usually involves modifying an app.config to say “I am totally ok with you mixing modes or whatever, just do what magic I need.”

I found a few related errors until I stumbled on https://github.com/adamdriscoll/poshtools/issues/192 which broke down where I should be looking (~/.vscode) and that I could create a file named

C:Users\%USERNAME%.vscodeextensionsms-vscode.PowerShell-0.4.1inMicrosoft.PowerShell.EditorServices.Host.exe

and place the following content within it:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

This did not work.

After a second scratching my head I found that it looks like VS Code’s new version of powershell is using a different folder name within the hidden vscode folder, so if you check

C:Users\%appdata%.vscodeextensions

and navigate to the bin folders within it before you make your file you will be fine.

Also, make sure the app.config file matches the name of the executable being invoked (plus the extension .config) in this case I had both Microsoft.PowerShell.EditorServices.Host.exe and Microsoft.PowerShell.EditorServices.Host.x86.exe, made both files, and now I can run everything without issue.

Using Flamegraph.pl to create Flame Graphs for SQL Server Profiler, Extended Events, and more

A friend of mine was recently discussing using Flame Graphs in a project of his, and it inspired me to see how I could abuse the format to present a visual model of SQL execution.

Originally I had thought of building my own interface, but apparently the author of the above site also maintains a great repo which allows you to skip some of the more difficult steps: https://github.com/brendangregg/FlameGraph.

There is a lot of detail there about profiling software with specific tools and how to convert their output to something the tool understands, but at its core the “folded” format is fairly easy to target and if you are fine with some text manipulation you can produce your own FGs and re-use the SVG generation, search, and zoom components of this tool.

What’s the format?
It doesnt take too much effort to suss out from flamegraph’s source:
From https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl
# frame in the stack is semicolon separated, with a space and count at the end
# of the line.

Script for non-production restores

This is some code came together as a result of straightforward requirements; a team needed to spend a significant amount of time doing manual restores, and were tired of the GUI nonsense from SSMS. But also wanted some basic flexibility due to the fact that the servers configuration may change significantly (but not during the restore.)

The code makes some assumptions:
* Assumes your SQL service account has access to the file location for the backup
* You have the permission to create new databases and select from sys.master_files (CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.)

Dirty tricks in SSRS authentication

Configuring SSRS authentication to IIS can be a pain, here are some things I have done in a pinch, and almost all of them are terrible, but if you repeatedly get a 401 unauthorized with SSRS, these might be able to help.

SSRS native mode on one domain, IIS on another – DMZ

In this mode, you are normally advised to implement basic authentication, and just pass a username and password in… in some instances you may be unable to use basic, and are forced to use NTLM.

In this situation a simple method to bypass this is to create a local user on both boxes with the same password, and have that user be the one the report server grants access to, and which user is running the web server process.

Make sure this password is strong, and doesn’t change.

SSRS native mode, same domain, IIS running as local system

In some cases you may find that the system is configured to run the IIS process as local system (generally not recommended). If this is the case, you can actually grant the entire computer name in the report server permissions via its hostname and a dollar sign.

Example:

MachineHostname$

Additional Troubleshooting for Native Mode

  • Enable the HTTP log for the report server , it can help enormously to isolate what’s being accessed, where, when, and sometimes who.
  • Double check each report folder in the hierarchy’s permissions for your user, while you may think you have permission, its quite possible you don’t and that someone overrode the parent permissions.
  • If you get a FORBIDDEN message instead of an unauthorized, the user you are trying to run the report as may need escalated permissions on the SSRS application directory itself (on the SQL Server).
  • When all else fails you can grant Browser permission to “Everybody”, but be aware that means anyone can request information from your reports, and is a really really really bad idea. (If it doesn’t work, that means you are not even making the request from the same domain)

Running SQL Queries On Multiple Servers At Once Using Registered Servers In SQL Server Management Studio

I just came across a situation where I was looking at long running queries across a few production servers, I wanted to quickly and easily run my query across them all to make sure that I wasn’t missing a problem on each server where a user had left a specific query for a looong time.

Thankfully, registered servers is here to the rescue! Many people using SSMS have never even used registered servers, and if they have, they dont know about this secret context menu hiding in the GUI.

What’s a registered server?

A registered server is effectively a way to remember that you have connected to a server, and allow easy access to connecting to it again. (There is probably a MUCH more technical explanation, but this one suffices. (Want more? Check the “BOL”:page)

In SSMS you can simply right click any active server and select “Register” to bring up the prompt to register the server. If you are running more than one set of servers that should be running different queries, then you may want to create additional server groups (when we get there).

In SSMS 2008, you can simply use the shortcut CTRL+ALT+G or select “Registered Servers” under the View menu.

Once that is complete, you should be able to right click any group you have created, and select “New Query”.

When you run your query, you should notice that an additional column exists now, with the label of the server that returns the query results.

Enjoy!

Learn More

Popular Music For My Classes

This is some of the music I play for my classes, honed over a while.

Playlist 1:

|Name_____________ |Artist__________|Album_____________|
|Flashback|Kavinsky|1986 Vinyl|
|Testarossa (SebastiAn Remix)|Kavinsky|1986 Vinyl|
|Wayfarer|Kavinsky|1986 Vinyl|
|Dead Cruiser|Kavinsky|1986 Vinyl|
|Grand Canyon|Kavinsky|1986 Vinyl|
|Gettysburg|Ratatat|Classics|
|Tacobel Canon|Ratatat|Classics|
|Lex|Ratatat|Classics|
|Montanita|Ratatat|Classics|
|Kennedy|Ratatat|Classics|
|Wildcat|Ratatat|Classics|
|Swisha|Ratatat|Classics|
|Loud Pipes|Ratatat|Classics|
|Nostrand|Ratatat|Classics|
|Tropicana|Ratatat|Classics|
|Bar Rumba|Mo’ Horizons|Elemental Chill – Volume 4|
|The Crossing|Soundtrack|Gattaca|
|It Must Be The Light|Soundtrack|Gattaca|
|Irene & The Morrow|Soundtrack|Gattaca|
|Second Morrow|Soundtrack|Gattaca|
|Not The Only One|Soundtrack|Gattaca|
|The Truth|Soundtrack|Gattaca|
|Call Me Eugene|Soundtrack|Gattaca|
|Impromptu For 12 Fingers|Soundtrack|Gattaca|
|I Thought You Wanted To Dance|Soundtrack|Gattaca|
|Now That You’re Here|Soundtrack|Gattaca|
|The Arrival|Soundtrack|Gattaca|
|The Morrow|Soundtrack|Gattaca|
|Further And Further|Soundtrack|Gattaca|
|Only A Matter Of Time|Soundtrack|Gattaca|
|Traces|Soundtrack|Gattaca|
|The Departure|Soundtrack|Gattaca|
|Up Stairs|Soundtrack|Gattaca|
|God’s Hands|Soundtrack|Gattaca|
|A Borrowed Ladder|Soundtrack|Gattaca|
|Irene’s Theme|Soundtrack|Gattaca|
|The Other Side|Soundtrack|Gattaca|
|Becoming Jerome|Soundtrack|Gattaca|
|The One Moment|Soundtrack|Gattaca|
|Yourself For The Day|Soundtrack|Gattaca|
|Brulee|Ratatat|LP3|
|Flynn|Ratatat|LP3|
|Mi Viejo|Ratatat|LP3|
|Falcon Jab|Ratatat|LP3|
|Mumtaz Khan|Ratatat|LP3|
|Bird-Priest|Ratatat|LP3|
|Shiller|Ratatat|LP3|
|Gipsy Threat|Ratatat|LP3|
|Imperials|Ratatat|LP3|
|Dura|Ratatat|LP3|
|Shempi|Ratatat|LP3|
|Black Heroes|Ratatat|LP3|
|Mirando|Ratatat|LP3|
|Shempi|Ratatat|LP3|
|En Focus (feat. Trinidad)|Quantic|Mishaps Happening|
|Perception|Quantic|Mishaps Happening|
|Sound Of Everything (feat. Ali|Quantic|Mishaps Happening|
|Mishaps Happening|Quantic|Mishaps Happening|
|Furthest Moment|Quantic|Mishaps Happening|
|Trees and Seas|Quantic|Mishaps Happening|
|Use What You Got (feat. Sonny|Quantic|Mishaps Happening|
|Angels and Albatrosses|Quantic|Mishaps Happening|
|Prelude To Happening|Quantic|Mishaps Happening|
|Don’t Joke With A Hungry Man (|Quantic|Mishaps Happening|
|When You’re Through (feat. Spa|Quantic|Mishaps Happening|
|Scavenger|Redial|MOS Mashed 4|
|Toothache Epiphany|nonfinite|Northbridge|
|Seventeen Years|Ratatat|Ratatat|
|El Pico|Ratatat|Ratatat|
|Spanish Armada|Ratatat|Ratatat|
|Breaking Away|Ratatat|Ratatat|
|Lapland|Ratatat|Ratatat|
|Crips|Ratatat|Ratatat|
|Wildcat|Ratatat|Ratatat|
|Cherry|Ratatat|Ratatat|
|Crips|Ratatat|Ratatat|
|Desert Eagle|Ratatat|Ratatat|
|Germany To Germany|Ratatat|Ratatat|
|Lapland|Ratatat|Ratatat|
|Everest|Ratatat|Ratatat|
|Mr Oizo Autodrive T42|Kavinsky|Teddy Boy EP|
|Testarossa Nightdrive|Kavinsky|Teddy Boy EP|
|Transistor|Kavinsky|Teddy Boy EP|
|The Crash|Kavinsky|Teddy Boy EP|
|Arpanet Nightdrive (rework)|Kavinsky|Teddy Boy EP|
|Testarossa Autodrive|Kavinsky|Teddy Boy EP|
|Ghost Transistor|Kavinsky|Teddy Boy EP|
|The Grand Staircase|Port Blue|The Airship|
|In the Control Car|Port Blue|The Airship|
|Into the Gymnasium|Port Blue|The Airship|
|The Axial Catwalk|Port Blue|The Airship|
|Of the Airship Academy|Port Blue|The Airship|
|Up Ship!|Port Blue|The Airship|
|Sunset Cruiser|Port Blue|The Airship|
|Over Atlantic City|Port Blue|The Airship|
|The Gentle Descent|Port Blue|The Airship|
|Under the Glass Observation Dome|Port Blue|The Airship|
|An Enchanted Evening|Port Blue|The Albatross EP|
|City of Safe Harbors|Port Blue|The Albatross EP|
|Silver Blueberry|Port Blue|The Albatross EP|
|Of Japan|Port Blue|The Albatross EP|
|The Power Is On|The Go! Team|Thunder, Lightning, Strike|
|Friendship Update|The Go! Team|Thunder, Lightning, Strike|
|Junior Kickstart|The Go! Team|Thunder, Lightning, Strike|
|Huddle Formation|The Go! Team|Thunder, Lightning, Strike|
|Ladyflash|The Go! Team|Thunder, Lightning, Strike|
|Everyone’s a V.I.P. to Someone|The Go! Team|Thunder, Lightning, Strike|
|Panther Dash|The Go! Team|Thunder, Lightning, Strike|
|Get It Together|The Go! Team|Thunder, Lightning, Strike|
|Feel good by Numbers|The Go! Team|Thunder, Lightning, Strike|
|What Else Is There|NULL|Royksopp|
|Valkyrie|NULL|Redial|
|Valve|NULL|Redial|

Playlist 2:

|It Was …|Lemon Jelly|’64-’95|
|’88 aka Come Down On Me|Lemon Jelly|’64-’95|
|’68 aka Only Time|Lemon Jelly|’64-’95|
|’93 aka Don’t Stop Now|Lemon Jelly|’64-’95|
|’95 aka Make Things Right|Lemon Jelly|’64-’95|
|’79 aka The Shouty Track|Lemon Jelly|’64-’95|
|’75 aka Stay With You|Lemon Jelly|’64-’95|
|’76 aka The Slow Train|Lemon Jelly|’64-’95|
|’90 aka A Man Like Me|Lemon Jelly|’64-’95|
|’64 aka Go|Lemon Jelly|’64-’95|
|One|Ratatat|9 Beats|
|Two|Ratatat|9 Beats|
|Three|Ratatat|9 Beats|
|Four|Ratatat|9 Beats|
|Five|Ratatat|9 Beats|
|Six|Ratatat|9 Beats|
|Seven|Ratatat|9 Beats|
|Eight|Ratatat|9 Beats|
|Nine|Ratatat|9 Beats|
|The Birth and Death of the Day|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Welcome, Ghosts|Explosions in the Sky|All of a Sudden I Miss Everyone|
|It’s Natural to Be Afraid|Explosions in the Sky|All of a Sudden I Miss Everyone|
|What Do You Go Home To?|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Catastrophe and the Cure|Explosions in the Sky|All of a Sudden I Miss Everyone|
|So Long, Lonesome|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Sleep Deprivation|Simian Mobile Disco|Attack Decay Sustain Release|
|glimpse|Helios|Caesura|
|Fourteen drawings|Helios|Caesura|
|Backlight|Helios|Caesura|
|A mountain of ice|Helios|Caesura|
|Mima|Helios|Caesura|
|Hollie|Helios|Caesura|
|One|Aimee Mann|Cinematic Treatment|
|Lex|Ratatat|Classics|
|Gettysburg|Ratatat|Classics|
|Wildcat|Ratatat|Classics|
|Tropicana|Ratatat|Classics|
|Loud Pipes|Ratatat|Classics|
|Kennedy|Ratatat|Classics|
|Swisha|Ratatat|Classics|
|Nostrand|Ratatat|Classics|
|Tacobel Canon|Ratatat|Classics|
|Tank !|Cowboy Bebop|Cowboy Bebop OST|
|Something|The Willowz|Eternal Sunshine of the Spotless Mind|
|Yo Pumpkin Head|Cowboy Bebop|Future Blues|
|Central Plains|Carbon Based Lifeforms|Hydroponic Garden|
|Tensor|Carbon Based Lifeforms|Hydroponic Garden|
|MOS 6581 (Album Version)|Carbon Based Lifeforms|Hydroponic Garden|
|Silent Running|Carbon Based Lifeforms|Hydroponic Garden|
|Neurotransmitter|Carbon Based Lifeforms|Hydroponic Garden|
|Hydrophonic Garden|Carbon Based Lifeforms|Hydroponic Garden|
|Exosphere|Carbon Based Lifeforms|Hydroponic Garden|
|Comsat|Carbon Based Lifeforms|Hydroponic Garden|
|Epicentre (First Movement)|Carbon Based Lifeforms|Hydroponic Garden|
|Artificial Island|Carbon Based Lifeforms|Hydroponic Garden|
|Refraction 1.33|Carbon Based Lifeforms|Hydroponic Garden|
|The Pulse|Digitalism|Idealism|
|The Bachelors Remix|RJD2|In Rare Form|
|Big Game|RJD2|In Rare Form|
|Explosive|RJD2|In Rare Form|
|Fuck A Soundcheck|RJD2|In Rare Form|
|Incorporate Anthem|RJD2|In Rare Form|
|Inhale Remix|RJD2|In Rare Form|
|Kill ’em All Remix|RJD2|In Rare Form|
|Mic Control|RJD2|In Rare Form|
|One Day|RJD2|In Rare Form|
|Rocket Science|RJD2|In Rare Form|
|Saliva|RJD2|In Rare Form|
|Seven Light Years|RJD2|In Rare Form|
|The Takeoff|RJD2|In Rare Form|
|Under the Hammer|RJD2|In Rare Form|
|Unlimited|RJD2|In Rare Form|
|Up to No Good Again|RJD2|In Rare Form|
|Uprock|RJD2|In Rare Form|
|Weatherpeople|RJD2|In Rare Form|
|Nervous Tension|Lemon Jelly|Lemonjelly.KY|
|A Tune For Jack|Lemon Jelly|Lemonjelly.KY|
|His Majesty King Raam|Lemon Jelly|Lemonjelly.KY|
|The Staunton Lick|Lemon Jelly|Lemonjelly.KY|
|Homage To Patagonia|Lemon Jelly|Lemonjelly.KY|
|Kneel Before Your God|Lemon Jelly|Lemonjelly.KY|
|Page One|Lemon Jelly|Lemonjelly.KY|
|Come|Lemon Jelly|Lemonjelly.KY|
|Elements|Lemon Jelly|Lost Horizons|
|Space Walk|Lemon Jelly|Lost Horizons|
|Ramblin’ Man|Lemon Jelly|Lost Horizons|
|Return to Patagonia|Lemon Jelly|Lost Horizons|
|Nice Weather for Ducks|Lemon Jelly|Lost Horizons|
|Experiment Number Six|Lemon Jelly|Lost Horizons|
|Closer|Lemon Jelly|Lost Horizons|
|The Curse of Ka’zar|Lemon Jelly|Lost Horizons|
|So Easy|Rv?yksopp|Melody A.M.|
|Eple|Rv?yksopp|Melody A.M.|
|Sparks|Rv?yksopp|Melody A.M.|
|In Space|Rv?yksopp|Melody A.M.|
|Poor Leno|Rv?yksopp|Melody A.M.|
|A Higher Place|Rv?yksopp|Melody A.M.|
|Rv?yksopp’s Night Out|Rv?yksopp|Melody A.M.|
|Remind Me|Rv?yksopp|Melody A.M.|
|She’s So|Rv?yksopp|Melody A.M.|
|40 Years BackCome|Rv?yksopp|Melody A.M.|
|Remind Me|Rv?yksopp|Melody AM|
|Femme d’Argent|Air|Moon Safari|
|Zdarlight (Voyage Mix)|Digitalism|My House Is Your House, Vol. 1 Disc 1|
|First Breath After Coma|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|The Only Moment We Were Alone|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Six Days at the Bottom of the Ocean|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Memorial|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Your Hand in Mine|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Intro|Carbon Based Lifeforms|The Path|
|Behind the corner|Carbon Based Lifeforms|The Path|
|Rain|Carbon Based Lifeforms|The Path|
|Rise to tomorrow|Carbon Based Lifeforms|The Path|
|Hold|Carbon Based Lifeforms|The Path|
|Machinery|Carbon Based Lifeforms|The Path|
|And contact|Carbon Based Lifeforms|The Path|
|Sinful things|Carbon Based Lifeforms|The Path|
|Dreamshore forest|Carbon Based Lifeforms|The Path|
|Submerged|Carbon Based Lifeforms|The Path|
|Contaminated area|Carbon Based Lifeforms|The Path|
|Last breath|Carbon Based Lifeforms|The Path|
|Station blue|Carbon Based Lifeforms|The Path|
|Or plan B|Carbon Based Lifeforms|The Path|
|Eple (Black Strobe Remix)|Royksopp|The Remix Album|
|Remind Me (James Zabiela Eighties Ingeborg Mix)|Royksopp|The Remix Album|
|Poor Leno (Silicon Souls Dub Remix)|Royksopp|The Remix Album|
|49 Percent (Angello & Ingrosso Remix)|Royksopp|The Remix Album|
|What Else Is There (Vitalic Remix)|Royksopp|The Remix Album|
|Sparks (Murk Downtown Miami Remix)|Royksopp|The Remix Album|
|So Easy (So B.H.Q. Remix By Derrick Carter)|Royksopp|The Remix Album|
|Remind Me (Someone Else’s Radio Remix)|Royksopp|The Remix Album|
|Only This Moment (Alan Braxe And Fred Falke Remix)|Royksopp|The Remix Album|
|49 Percent (Mandy Remix)|Royksopp|The Remix Album|
|Eple (Fatboy Slim Mix)|Royksopp|The Remix Album|
|Poor Leno (Sander Kleinenberg Mix)|Royksopp|The Remix Album|
|Remind Me (Ernest Saint Laurent Moonfish Mix)|Royksopp|The Remix Album|
|What Else Is There (Jacques Lu Cont Radio Mix)|Royksopp|The Remix Album|
|What Else Is There (Thin White Duke Mix)|Royksopp|The Remix Album|
|Beautiful Day Without You (Rex The Dog Remix)|Royksopp|The Remix Album|
|Day One|Explosions in the Sky|The Rescue|
|Day Two|Explosions in the Sky|The Rescue|
|Day Three|Explosions in the Sky|The Rescue|
|Day Four|Explosions in the Sky|The Rescue|
|Day Five|Explosions In the Sky|The Rescue|
|Day Six|Explosions In the Sky|The Rescue|
|Day Seven|Explosions In the Sky|The Rescue|
|Day Eight|Explosions In the Sky|The Rescue|
|Abiogenesis|Carbon Based Lifeforms|World of Sleepers|
|Vortex|Carbon Based Lifeforms|World of Sleepers|
|Autumn in Ganymede|NULL|Cowboy Bebop|
|Blues Sax|NULL|Cowboy Bebop|
|Go Go Cactus Man (Whistling Song)|NULL|Cowboy Bebop|
|Tank! (Luke Vibert Remix)|NULL|Cowboy Bebop|

Mounting ISO Images in Mac OS X Without Expensive Software

I was speaking with a colleague today about ISO files/images in Mac OS X, and when he expressed his disappointment with existing software.
I said I would show him some cheap and easy ways to mount ISO files and how to backup any CDROM using Disk Utility.

Mounting an ISO on your Mac is accomplished using the hdiutil command.
To attach an image file,

  1. you will first need to open up your Terminal.app
  2. ¬†type¬† hdiutil attach -readonly filename where filename is the full unix path of your file (just to be safe). When I was testing this my command looked like “hdiutil attach -readonly /Users/ck/Downloads/cdrom-1.33.iso”.
  3. If you run into problems or find your image type says not supported, generally because it is a .cdr file, try hdiutil attach -imagekey diskimage-class=CRawDiskImage filename.

This should mount the image in your Finder sidebar as you would expect a normal CDROM would. If we are concerned with creating images with Disk Utility, that is as simple as dragging the inserted CD onto the Disk Utility application, or selecting it within Disk Utility and selecting New Image.