Add datastore by LUN ID


/ Published in: Windows PowerShell
Save to your folder(s)

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


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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.