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_FCAdapterHBAAttribute s -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
function Get-HBAWin {
param(
[String[]]$ComputerName = $ENV:ComputerName
)
$ComputerName | ForEach-Object {
$Computer = $_
$Namespace = "root\WMI"
Get-WmiObject -class MSFC_FCAdapterHBAAttribute
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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"
You will get a single Excel worksheet, but that is ok since the computer name is part of each line.
ASKER