Trying to query non-windows native program (dell racadm) info and format string into csv file with other info. Everything works until I get to the iDracIP and it returns blank in the csv file. I know my syntax is bad but I cannot figure out what to command use to grab the “IP Address” string and pipe it into the csv file. I have tried select-object, get-itemproperty.
$logregion = “TEST”
$host.ui.RawUI.WindowTitle = "IP FQDN - $logRegion"
$currentdate = get-date -f yyyy-MM-dd
function get_info_func {
$a = Get-Content "$PSScriptRootservers.txt"
$get_info_array = @()
foreach ($i in $a){
write-host $i
$array = New-Object PSObject
$array | Add-Member -type NoteProperty -Name "Name From List" -Value $i
$array | Add-Member -type NoteProperty -Name "Host Name" -Value (Get-WmiObject -Class Win32_ComputerSystem -computername $i | Select-Object -expandproperty dnshostname)
$array | Add-Member -type NoteProperty -Name "Domain" -Value (Get-WmiObject -Class Win32_ComputerSystem -computername $i | Select-Object -expandproperty Domain)
$array | Add-Member -type NoteProperty -Name "IPAddress" -Value ([string](Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $i | Select-object -expandproperty IPAddress) )
$array | Add-Member -type NoteProperty -Name "IpSubnet" -Value ([string](Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $i | Select-object -expandproperty IpSubnet) )
$array | Add-Member -type NoteProperty -Name "DefaultIPGateway" -Value ([string](Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $i | Select-object -expandproperty DefaultIPGateway) )
$array | Add-Member -type NoteProperty -Name "DNSServerSearchOrder" -Value ([string](Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $i | Select-object -expandproperty DNSServerSearchOrder) )
$array | Add-Member -type NoteProperty -Name "Mac Address" -Value ([string](Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computername $i | Select-object -expandproperty MACAddress) )
$array | Add-Member -type NoteProperty -Name "OS" -Value (Get-WmiObject -class Win32_OperatingSystem -computername $i | Select-Object -expandproperty Caption)
$array | Add-Member -type NoteProperty -Name "MODEL" -Value (Get-WmiObject -Class Win32_ComputerSystem -computername $i | Select-Object -expandproperty Model)
$array | Add-Member -type NoteProperty -Name "Serial Number" -Value (Get-WmiObject -class WIN32_systemenclosure -computername $i | Select-Object -expandproperty SerialNumber)
$array | Add-Member -type NoteProperty -Name "iDrac IP" -Value ([string](Invoke-Command -scriptblock { racadm.exe getniccfg } -computername $i) | Select-Object -expandproperty "IP Address")
$get_info_array += $array
}
$get_info_array | Export-Csv "$PSScriptRootIPinfo_$($logregion)_$(get-date -f yyyy-MM-dd).csv" -NoTypeInformation -append
}#end function
& get_info_func
New contributor
Von is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.