Link to home
Start Free TrialLog in
Avatar of syseng007
syseng007

asked on

Powershell Gurus - Please Help

Need help on tweaking the attached Powershell code. I need to find HBA and WWN storage info from a list of servers, and output it in a Excel worksheet. Please help! Thank you.

function Get-HBAWin {
param(
[String[]]$ComputerName = $ENV:ComputerName  
)
 
$ComputerName | ForEach-Object {
$Computer = $_
$Namespace = "root\WMI"  
Get-WmiObject -class MSFC_FCAdapterHBAAttributes -computername $Computer -namespace $namespace |
ForEach-Object {
$hash=@{
ComputerName     = $_.__SERVER
NodeWWN          = (($_.NodeWWN) | ForEach-Object {"{0:x}" -f $_}) -join ":"
Active           = $_.Active
DriverName       = $_.DriverName
DriverVersion    = $_.DriverVersion
FirmwareVersion  = $_.FirmwareVersion
Model            = $_.Model
ModelDescription = $_.ModelDescription
}
New-Object psobject -Property $hash
}#Foreach-Object(Adapter)
}#Foreach-Object(Computer)
 
}#Get-HBAWin
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of syseng007
syseng007

ASKER

Thank you for the input. You forgot to include a line to get servers list from a file.... Thanks again!
No, I did not forget that - there was no request to do so yet. But that's easy:
Get-HBAWin (gc "C:\temp\servers.txt") | export-xls "C:\temp\HBAWin.xls"

Open in new window

You will get a single Excel worksheet, but that is ok since the computer name is part of each line.