Guest User

Untitled

a guest
Jun 21st, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. break
  2.  
  3. $eql_group_addr = '1.1.1.1'
  4. $eql_user = 'grpadmin'
  5. $vcenter_addr = 'vcenter.domain.loc'
  6. $vcenter_user = 'administrator@vsphere.local'
  7. $vmhosts = '*'
  8.  
  9. $creds = Get-Credential -UserName $vcenter_user -Message 'Enter Password'
  10. Connect-VIServer -Server $vcenter_addr -Credential $creds
  11.  
  12. # Manage EqualLogic with PowerShell
  13. Import-Module -Name 'C:\Program Files\EqualLogic\bin\EqlPSTools.dll'
  14. $eql_creds = Get-Credential -UserName $eql_user -Message 'Enter Password'
  15. Connect-EqlGroup -GroupAddress $eql_group_addr -Credential $eql_creds
  16.  
  17. #################################################################################################################################################################
  18. $datastore = Get-Datastore -Name 'VMFS01'
  19. $esxi_hosts = Get-VMHost -Name $vmhosts
  20. $equallogic_lun = Get-ScsiLun -Datastore $datastore | Select-Object -First 1
  21. $equallogic_lun_path = Get-ScsiLunPath -ScsiLun $equallogic_lun | Select-Object -First 1
  22. $equallogic_volume_name = (Get-EqlVolume | Where-Object { $_.iSCSITargetName -match $equallogic_lun_path.SanId }).VolumeName
  23. $equallogic_canonical_name = $equallogic_lun.CanonicalName
  24. 'EqualLogic Volume Name: {0}' -f $equallogic_volume_name
  25. 'EqualLogic Canonical Name: {0}' -f $equallogic_canonical_name
  26.  
  27. # List the contents of the datastore to ensure that it is empty
  28. New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root '\' | Out-Null; ls ds:; Remove-PSDrive ds
  29.  
  30. # Unmount/detach datastore from all hosts
  31. Unmount-Datastore -Datastore $datastore
  32. Detach-Datastore -Datastore $datastore
  33.  
  34. # List the datastore status for each host
  35. Get-DatastoreMountInfo -Datastore (Get-Datastore -Name $datastore.Name) | Sort-Object Datastore, VMHost | Format-Table -AutoSize
  36.  
  37. # Set the EqualLogic volume offline and list the status
  38. Set-EqlVolume -VolumeName $equallogic_volume_name -OnlineStatus offline; Get-EqlVolume -VolumeName $equallogic_volume_name | Select-Object OnlineStatus
  39.  
  40. # Rescan all HBAs on all hosts
  41. Get-VMHostStorage -VMHost $esxi_hosts -RescanAllHBA -RescanVmfs | Out-Null
  42.  
  43. # Remove the datastore from the detached datastores cache on all hosts and list the status
  44. # ESXi 5.5 and older
  45. $esxi_hosts | ForEach-Object -Process { try { (Get-EsxCli -vmhost $_.name).storage.core.device.detached.remove($equallogic_canonical_name) } catch {} }
  46. # ESXi 6.0 and newer
  47. $esxi_hosts | ForEach-Object -Process { try { (Get-EsxCli -vmhost $_.name).storage.core.device.detached.remove($true, $equallogic_canonical_name) } catch {} }
  48. $esxi_hosts | ForEach-Object -Process { try { (Get-EsxCli -vmhost $_.name).storage.core.device.detached.list($equallogic_canonical_name) } catch {} }
Add Comment
Please, Sign In to add comment