function Get-NaLUNbyMap {
<#
.DESCRIPTION
Gets Lun Information for a particular initiatorgroup name & lunid
.EXAMPLE
Get-Inventory -computername server-r2
.EXAMPLE
Import-Module NaLUNbyMap
Get-NaLUNbyMap -igroup "IA" -lunid 1
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[string[]]$igroup,
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[string[]]$lunid
)
Process
{
$info = (Get-NaLun |Select @{Name="LUN";Expression={$_.path}},@{Name="Size";Expression={[math]::Round([decimal]$_.size/1gb,0)}},@{Name="OnlineStatus";Expression={$_.online}},@{Name="Group";Expression={([string]::Join(",",(Get-NaLun $_.path | get-nalunmap | select -ExpandProperty initiatorgroupname)))}},@{Name="LunID";Expression={Get-NaLun $_.path | get-nalunmap | select -ExpandProperty lunid}} | ?{$_.group -eq $igroup -and $_.lunid -eq $lunid})
return $info
}
}
嗨我无法从此功能返回输出,有人可以帮帮我!
答案 0 :(得分:1)
这是一些丑陋的代码。 :(
这是一个清理版本。我想我找到了你的问题。您的参数是数组,当它们应该是基于您使用它们的方式的单个值时。
function Get-NaLUNbyMap {
<#
.DESCRIPTION
Gets Lun Information for a particular initiatorgroup name & lunid
.EXAMPLE
Get-Inventory -computername server-r2
.EXAMPLE
Import-Module NaLUNbyMap
Get-NaLUNbyMap -igroup "IA" -lunid 1
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[string]$igroup
,
[Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[string]$lunid
)
process {
$Luns = foreach ($Lun in Get-NaLun) {
$LunMap = Get-NaLunMap $_.Path
New-Object PSObject -Property @{
"LUN"= $_.Path
"Size" = [Math]::Round([Decimal]$_.Size / 1gb, 0)
"OnlineStatus" = $_.Online
"Group" = $LunMap | Select-Object -ExpandProperty InitiatorGroupName
"LunId" = $LunMap | Select-Object -ExpandProperty LunId
}
}
$Luns | Where-Object {$_.Group -eq $igroup -and $_.LunId -eq $lunid}
}
}