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

Get-IscsiServerTarget

Get-IscsiVirtualDisk

iSCSI (Run on machine importing disks)

Import-Module iSCSI

Get-IscsiTargetPortal

Get-IscsiConnection

Get-IscsiSession

Get-IscsiTarget

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:192.168.117.210, IPAddress:10.0.0.220, IPAddress:192.168.117.211, IPAddress:10.0.0.221}

TargetName   : target2
InitiatorIds : {IPAddress:10.0.0.221, IPAddress:192.168.117.210, IPAddress:10.0.0.220, IPAddress:192.168.117.211

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

Immediately the iscsi session drops!

 

Advertisement


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