VMware Cloud Community
infra3
Enthusiast
Enthusiast

How to Check iSCSI Connections from Powershell

Hi,

How to check iscsi connected session from power shell

How to Disconnect the iSCSI sessions from power shell

OS windows 2008 R 2 Enterprise

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

You can check the state of the sessions like this

$esxName = 'MyEsx'

$esx = Get-VMHost -Name $esxName

$esxcli = Get-EsxCli -VMHost $esx -v2

$esxcli.iscsi.session.connection.list.Invoke() |

select Adapter,Target,State

You can remove sessions, but you probably want to do some filtering (Where-clause) to make sure you are removing the intended sessions.

$esxcli.iscsi.session.list.Invoke() | %{

    $sSession = @{

        isid = $_.ISID

        adapter = $_.Adapter

    }

    $esxcli.iscsi.session.remove.Invoke($sSession)

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
infra3
Enthusiast
Enthusiast

Hi ,

Actually my question was I have iSCSI connection inside VM GOS level

I wan to check the details form power cli which are having targets are connected to windows 2008 r2 VM

how can I list the active sessions and how to disconnect

Sorry for the confusion

Reply
0 Kudos
LucD
Leadership
Leadership

I see.

Well there is an iSCSI module from Microsoft, but as far as I can tell it only starts with Windows 2012.

For Windows 2008 R2 there was the MicrosoftIscsiTarget module, but that seems to be lacking functionality to query the sessions.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
infra3
Enthusiast
Enthusiast

Hi ,

I have installed iscsiTargetqfe6  from Microsoft , and I was able to get some some commands

Need to check what are the possible ways

pastedImage_0.png

Reply
0 Kudos