Return to Snippet

Revision: 40276
at February 8, 2011 16:48 by benash


Updated Code
function New-DatastoreByLun {
  param($vmHost, [string]$hbaId, [int]$targetId, [int]$lunId, [string]$dataStoreName)
  
  $lun = $view.Config.StorageDevice.ScsiTopology | ForEach-Object { $_.Adapter } | Where-Object {$_.Key -match $hbaId} | 
         ForEach-Object {$_.Target} | Where-Object {$_.Target -eq $targetId} | ForEach-Object {$_.Lun} | Where-Object {$_.Lun -eq $lunId}

  $scsiLun = Get-VMHost $vmHost | Get-ScsiLun | Where-Object {$_.Key -eq $lun.ScsiLun}

  New-Datastore -Name $dataStoreName -Path $scsiLun.CanonicalName -Vmfs
}

Revision: 40275
at January 28, 2011 15:35 by benash


Initial Code
function New-iScsi {
  param($vmHost, [string]$hbaId, [int]$targetId, [int]$lunId, [string]$dataStoreName)
  
  $lun = $view.Config.StorageDevice.ScsiTopology | ForEach-Object { $_.Adapter } | Where-Object {$_.Key -match $hbaId} | 
         ForEach-Object {$_.Target} | Where-Object {$_.Target -eq $targetId} | ForEach-Object {$_.Lun} | Where-Object {$_.Lun -eq $lunId}

  $scsiLun = Get-VMHost $vmHost | Get-ScsiLun | Where-Object {$_.Key -eq $lun.ScsiLun}

  New-Datastore -Name $dataStoreName -Path $scsiLun.CanonicalName -Vmfs
}

Initial URL


Initial Description
Assumes the targets are already visible in the storage adapter, and you just want to create the VMFS volume

Initial Title
Add datastore by LUN ID

Initial Tags


Initial Language
Windows PowerShell