Powershell and iSCSI

Powershell module notes:

Get-Module : List loaded modules

Get-Module –ListAvailable : List available modules

iSCSI target (Run on machine exporting disks)

Import-Module IscsiTarget



iSCSI (Run on machine importing disks)

Import-Module iSCSI





Get-Disk | Format-List -Property Path,Size,IsReadOnly

(get-wmiobject -namespace ROOT\WMI -class MSiSCSIInitiator_SessionClass).Devices | Where-Object {$_.LegacyName -ne $null} | Select-Object -Property LegacyName,DeviceInterfaceName -unique | Format-List

Disable Access to a iscsi target from a given machine

Import-Module IscsiTarget

Get-IscsiServerTarget | Format-List -Property TargetName,InitiatorIds

TargetName   : target1
InitiatorIds : {IPAddress:, IPAddress:, IPAddress:, IPAddress:}

TargetName   : target2
InitiatorIds : {IPAddress:, IPAddress:, IPAddress:, IPAddress:

Set-IscsiServerTarget -TargetName target2 -InitiatorId @(“IPAddress:″,”IPAddress:″,”IPAddress:”)

Immediately the iscsi session drops!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s