Powershell and iSCSI
Posted: January 5, 2016 Filed under: iSCSI, powershell, Uncategorized Leave a commentPowershell 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!