Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Getting MSiSCSI status for discovered targets with WMI

$
0
0

Hello!

I've been trying to develop a monitoring script for iSCSI connections in a Hyper-V environment. We are using MSiSCSI Initiator to map LUNs.

So far I'm able to retrieve info about connected sessions using the class MSiSCSI_InitiatorSessionInfo. The problem with this is it only shows active targets. I want to display both active (logged in) targets and inactive targets (not logged in).

Using MSiSCSIInitiator_TargetClass I can see all discovered targets but as far as I can tell there's no property to tell me whether the target is logged in or not. I've looked through ALL WMI classes related to iSCSI...

In the GUI (iscsicpl) I can clearly see "Status - Connected" and "Status - Inactive" which leads me to believe there has to be some way to get this info via cli/wmi.

Does anyone have any tips for me how to gather this information via powershell?

 

Also, on a different note, I've been wondering about the property "State" on ISCSI_ConnectionStaticInfo. In the Dev documentation MS states "The type of connection state. This member can have the following symbolic constant values, which are defined in Iscsimgt.h."

Well, I've looked through iscsimgt.h and all I can find is:
 // login
#define login 0
// full
#define full 1
// logout
#define logout 2

The state on my connections shows up as '9'... where does this number come from? I would expect 0, 1 or 2. Perhaps the following lines have something to do with it but I can't figure them out:

 // **typedef** Indicates the current state of this connection
    UCHAR State;
    #define ISCSI_ConnectionStaticInfo_State_SIZE sizeof(UCHAR)
    #define ISCSI_ConnectionStaticInfo_State_ID 3
Regards,
Stefan

Viewing all articles
Browse latest Browse all 8583

Trending Articles