Home | Featured | Managing iSCSI on Windows 2008 Core with Hyper-V
I've been spending some time recently working with Microsoft's Hyper-V virtualisation platform and one of the major hassles I've experienced is having to use the command line rather than GUI for certain functions. If you're not aware, Windows 2008 Core is a stripped down version of a standard Windows 2008 Server deployment and so has no GUI interface. That makes administering features such as iSCSI a little more challenging.

Managing iSCSI on Windows 2008 Core with Hyper-V

0 Flares Twitter 0 Facebook 0 Google+ 0 StumbleUpon 0 Buffer 0 LinkedIn 0 0 Flares ×

I’ve been spending some time recently working with Microsoft’s Hyper-V virtualisation platform and one of the major hassles I’ve experienced is having to use the command line rather than GUI for certain functions.  If you’re not aware, Windows 2008 Core is a stripped down version of a standard Windows 2008 Server deployment and so has no GUI interface.  That makes administering features such as iSCSI a little more challenging as this isn’t one of the features of Server Management.

Image 1 - iSCSI GUI

Image 1 - iSCSI GUI

If you use iSCSI in your Windows environment, you will be familiar with the standard iSCSI GUI.  This GUI makes administering iSCSI incredibly simple (with functions like Quick Connect) or of course you can use the more advanced features that allow the configuration of security and other features.  Image 1 shows an example of the iSCSI Initiator page from one of my Hyper-V test machines.  You can just about see that some of the connections are established and some are inactive.

Of course there is no GUI to use in 2008 Core, so the fallback is to use the iscsicli.exe command.  You can find a description of the iscsicli commands using the following link from Microsoft: iSCSI Users Guide.  This Word document provides details on how to create, display and delete iSCSI connections from the command line.  For example to list target devices, use the command “iscsicli listtargets” as shown in Image 2.

Image 2 - iscsicli

Image 2 - iscsicli

While these commands are good and useful, there are two problems; firstly they require logging onto the server to run them (I want to run them centrally) and secondly, the available commands don’t give me exactly what I want to know.  To get the data I want, I’ve utilised WMI (Windows Management Instrumentation), which provides a huge amount of information on a running Windows system.  The iSCSI details are all stored in classes that start MSiSCSI and MSiSCSIInitiator.  I’ve created two Powershell scripts, called iSCSIListSessions and iSCSIListDevices.  The first lists active and pending iSCSI sessions, the second is a bit more useful and lists sessions and the associated devices.

Each script requires the host name to be specified as a command line parameter.  See Images 3 & 4 for example output.  I’ve also attached both scripts to this post for download if anyone is interested in using them.  Note:  You use these scripts at your own risk. The scripts are pretty basic and assume the userid you’re logged in with is the one for accessing the remote server, so you need WMI permission on your logged in userid for this to work.  If I get time, I may produce something more flexible that would allow credentials to be overridden.

Image 3 - iSCSIListDevices

Image 3 - iSCSIListDevices

Image 4 - iSCSIListSessions

Image 4 - iSCSIListSessions

iSCSIListDevices.ps1

iSCSIListSessions.ps1

Make sure you rename the file extension from .txt to .ps1 before using the scripts.

About Chris M Evans

Chris M Evans has worked in the technology industry since 1987, starting as a systems programmer on the IBM mainframe platform, while retaining an interest in storage. After working abroad, he co-founded an Internet-based music distribution company during the .com era, returning to consultancy in the new millennium. In 2009 Chris co-founded Langton Blue Ltd (www.langtonblue.com), a boutique consultancy firm focused on delivering business benefit through efficient technology deployments. Chris writes a popular blog at http://blog.architecting.it, attends many conferences and invitation-only events and can be found providing regular industry contributions through Twitter (@chrismevans) and other social media outlets.
0 Flares Twitter 0 Facebook 0 Google+ 0 StumbleUpon 0 Buffer 0 LinkedIn 0 0 Flares ×