DataCore iSCSIのポート情報を分かりやすく整えるPowerShellスクリプト

こんな感じで必要な情報だけ整えてオブジェクトのプロパティに入れることができました。

```
Import-Module 'C:\Program Files\DataCore\SANsymphony\DataCore.Executive.Cmdlets.dll' -WarningAction silentlyContinue
Connect-DcsServer
$iSCSIActivePorts = @()
$iSCSIPorts = Get-DcsPort -Machine (hostname) -Type "iSCSI"|sort Caption

$iSCSIPorts | ForEach-Object {
    If ($_.ServerPortProperties.Active -eq $true){
        $Server = ($_.HostId | Get-DcsServer).Caption
        $Name=$_.caption
        $Role=$_.Serverportproperties.Role
        $Iqn=$_.PortName
        $Ip = ($_.serverportproperties.iScsiPortalsConfig|select address).Address.ToString().Replace(':', '')
        $Mac=$_.PhysicalName.Substring(4,17).Replace("-",":")

        $iSCSIActivePorts += [pscustomobject]@{Name=$Name; Server = $Server; Role=$Role; IQN=$Iqn; IP=$Ip; Mac=$Mac}
    }
}
$iSCSIActivePorts|ft
Disconnect-DcsServer
```

出力結果や使い方の例（この環境ひどいｗ）

```
$iSCSIActivePorts|ft

Server Name                     Role IQN                                 IP           Mac             
------ ----                     ---- ---                                 --           ---             
DCS1   ClusterIP                None iqn.2000-08.com.datacore:dcs1-8     10.10.107.3  90:1B:0E:64:5...
DCS1   DCS1-FE1             Frontend iqn.2000-08.com.datacore:dcs1-5     10.10.200.10 00:0E:1E:D3:D...
DCS1   DCS1-iSCSIMR1          Mirror iqn.2000-08.com.datacore:dcs1-mr1   172.16.0.1   00:15:5D:6A:0...
DCS1   MGMT                     None iqn.2000-08.com.datacore:dcs1-4                  90:1B:0E:64:5...
DCS1   NEW BE                   None iqn.2000-08.com.datacore:dcs1-18                 00:15:5D:6A:0...
DCS1   NEW FE               Frontend iqn.2000-08.com.datacore:dcs1-newfe 10.10.100.1  00:15:5D:6A:0...
DCS1   NEW FE2              Frontend iqn.2000-08.com.datacore:dcs1-20    10.10.100.11 00:15:5D:6A:0...
DCS1   NEW FE3              Frontend iqn.2000-08.com.datacore:dcs1-21    10.10.100.21 00:15:5D:6A:0...
DCS1   NEW FE4              Frontend iqn.2000-08.com.datacore:dcs1-22    10.10.100.31 00:15:5D:6A:0...
DCS1   NEW FE5              Frontend iqn.2000-08.com.datacore:dcs1-23    10.10.100.41 00:15:5D:6A:0...
DCS1   NEW FE6              Frontend iqn.2000-08.com.datacore:dcs1-24    10.10.100.51 00:15:5D:6A:0...
DCS1   NEW FE7              Frontend iqn.2000-08.com.datacore:dcs1-fe7   10.10.100.61 00:15:5D:6A:0...
DCS1   NFS                      None iqn.2000-08.com.datacore:dcs1-nfs1  10.10.200.1  00:0E:1E:D3:D...
DCS1   Server iSCSI Port 25     None iqn.2000-08.com.datacore:dcs1-25                 00:15:5D:6A:0...
DCS1   Server iSCSI Port 26     None iqn.2000-08.com.datacore:dcs1-26                 00:15:5D:6A:0...
DCS1   Server iSCSI Port 27     None iqn.2000-08.com.datacore:dcs1-27                 00:15:5D:6A:0...
DCS1   Server iSCSI Port 29   Mirror iqn.2000-08.com.datacore:dcs1-mr2   172.16.0.254 00:15:5D:6A:0...
DCS1   Server iSCSI Port 30   Mirror iqn.2000-08.com.datacore:dcs1-mr3   1.2.3.4      00:15:5D:6A:0...
DCS1   Server iSCSI Port 9      None iqn.2000-08.com.datacore:dcs1-9     10.10.107.4  90:1B:0E:64:5...

#使い方の例
#ミラーポートのIPアドレスだけ一覧表示
$iSCSIActivePorts | Where-Object {$_.Role -eq "Mirror"} | ft IP

IP          
--          
172.16.0.1  
172.16.0.254
1.2.3.4

#役割があるものだけ表示
$iSCSIActivePorts | Where-Object {$_.Role -ne "None"} | ft

Server Name                     Role IQN                                 IP           Mac              
------ ----                     ---- ---                                 --           ---              
DCS1   DCS1-FE1             Frontend iqn.2000-08.com.datacore:dcs1-5     10.10.200.10 00:0E:1E:D3:DB:69
DCS1   DCS1-iSCSIMR1          Mirror iqn.2000-08.com.datacore:dcs1-mr1   172.16.0.1   00:15:5D:6A:0B:0D
DCS1   NEW FE               Frontend iqn.2000-08.com.datacore:dcs1-newfe 10.10.100.1  00:15:5D:6A:0B:0C
DCS1   NEW FE2              Frontend iqn.2000-08.com.datacore:dcs1-20    10.10.100.11 00:15:5D:6A:0B:0C
DCS1   NEW FE3              Frontend iqn.2000-08.com.datacore:dcs1-21    10.10.100.21 00:15:5D:6A:0B:0C
DCS1   NEW FE4              Frontend iqn.2000-08.com.datacore:dcs1-22    10.10.100.31 00:15:5D:6A:0B:0C
DCS1   NEW FE5              Frontend iqn.2000-08.com.datacore:dcs1-23    10.10.100.41 00:15:5D:6A:0B:0C
DCS1   NEW FE6              Frontend iqn.2000-08.com.datacore:dcs1-24    10.10.100.51 00:15:5D:6A:0B:0C
DCS1   NEW FE7              Frontend iqn.2000-08.com.datacore:dcs1-fe7   10.10.100.61 00:15:5D:6A:0B:0C
DCS1   Server iSCSI Port 29   Mirror iqn.2000-08.com.datacore:dcs1-mr2   172.16.0.254 00:15:5D:6A:0B:0D
DCS1   Server iSCSI Port 30   Mirror iqn.2000-08.com.datacore:dcs1-mr3   1.2.3.4      00:15:5D:6A:0B:16
```

参考にしたURL
https://qiita.com/sukakako/items/b9d4c10b75cf7c2fe965
https://docs.datacore.com/SSV-WebHelp/datacore_cmdlets_for_windows_powershell.htm