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 
{ 

$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
}
}

嗨,我无法从这个函数返回输出,有人可以帮帮我吗!

4

1 回答 1

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}
    }
}
于 2011-08-14T01:43:03.077 回答