Posted By

benash on 01/28/11


Tagged

PowerShell VMware


Versions (?)

Add datastore by LUN ID


 / Published in: Windows PowerShell
 

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

  1. function New-DatastoreByLun {
  2. param($vmHost, [string]$hbaId, [int]$targetId, [int]$lunId, [string]$dataStoreName)
  3.  
  4. $lun = $view.Config.StorageDevice.ScsiTopology | ForEach-Object { $_\3.Adapter } | Where-Object {$_\3.Key -match $hbaId} |
  5. ForEach-Object {$_\3.Target} | Where-Object {$_\3.Target -eq $targetId} | ForEach-Object {$_\3.Lun} | Where-Object {$_\3.Lun -eq $lunId}
  6.  
  7. $scsiLun = Get-VMHost $vmHost | Get-ScsiLun | Where-Object {$_\3.Key -eq $lun.ScsiLun}
  8.  
  9. New-Datastore -Name $dataStoreName -Path $scsiLun.CanonicalName -Vmfs
  10. }

Report this snippet  

You need to login to post a comment.