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
Powershell

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Qlemo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
syseng007

ASKER
Thank you for the input. You forgot to include a line to get servers list from a file.... Thanks again!
Qlemo

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes