I have been breaking my head over this.
what I want is to make a small python program which does utput a list of ipadress with their corresponding NIC
in powershell this is possible by doing this, I have found this script on the internet:
function Get-IscsiPortNumber {
$PortalSummary = @()
$portalInfo = get-wmiobject -namespace root\wmi -class msiscsi_portalinfoclass
$eScriptBlock ={([Net.IPAddress]$_.ipaddr.IPV4Address).IPAddressToString}
$customLabel = @{Label="IpAddress"; expression = $eScriptBlock}
foreach ($portal in $portalInfo) {
foreach ($p in ($portal.portalinformation)) {
$CurrentPort = New-Object PsObject -Property @{
Instance = ($portal.instancename).ToUpper()
Port = $p.port
IP = ([net.ipaddress]$p.ipaddr.IpV4Address).IPAddressToString
}
$PortalSummary += $CurrentPort
}
}
return $PortalSummary
}
Get-IscsiPortNumber | ft -AutoSize
This doesnt work with all windows versions though. for instance I get this error message on a windows server 2003 box:
PS C:\Documents and Settings\Administrator\Desktop> .\test.ps1
New-Object : A parameter cannot be found that matches parameter name 'Property'.
At C:\Documents and Settings\Administrator\Desktop\test.ps1:8 char:57
+ $CurrentPort = New-Object PsObject -Property <<<< @{
New-Object : A parameter cannot be found that matches parameter name 'Property'.
At C:\Documents and Settings\Administrator\Desktop\test.ps1:8 char:57
+ $CurrentPort = New-Object PsObject -Property <<<< @{
New-Object : A parameter cannot be found that matches parameter name 'Property'.
At C:\Documents and Settings\Administrator\Desktop\test.ps1:8 char:57
+ $CurrentPort = New-Object PsObject -Property <<<< @{
New-Object : A parameter cannot be found that matches parameter name 'Property'.
At C:\Documents and Settings\Administrator\Desktop\test.ps1:8 char:57
+ $CurrentPort = New-Object PsObject -Property <<<< @{
PS C:\Documents and Settings\Administrator\Desktop>
I have nearly zero experience with ps so I dont really know why... the last couple of hours I have tried to explore wmi with ps and the wmi objectbrowser. In the objectbrowser I can perfectly see all the stats I need. see the screenshot. Since I have literally no idea how arrays and properties etc. work in ps I hope someone can help me.
regards