2011-08-12 57 views
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 
} 
} 

嗨我無法返回此功能的輸出,可有人請幫助我!無法返回輸出功能

+0

@JasonMArcher可以請你幫助我與http://stackoverflow.com/questions/7104316/unable-to-extract-virtualnetwork-name-using-scvmm-powershell-modules – PowerShell

回答

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