Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- break
- $eql_group_addr = '1.1.1.1'
- $eql_user = 'grpadmin'
- $vcenter_addr = 'vcenter.domain.loc'
- $vcenter_user = 'administrator@vsphere.local'
- $vmhosts = '*'
- $creds = Get-Credential -UserName $vcenter_user -Message 'Enter Password'
- Connect-VIServer -Server $vcenter_addr -Credential $creds
- # Manage EqualLogic with PowerShell
- Import-Module -Name 'C:\Program Files\EqualLogic\bin\EqlPSTools.dll'
- $eql_creds = Get-Credential -UserName $eql_user -Message 'Enter Password'
- Connect-EqlGroup -GroupAddress $eql_group_addr -Credential $eql_creds
- #################################################################################################################################################################
- $datastore = Get-Datastore -Name 'VMFS01'
- $esxi_hosts = Get-VMHost -Name $vmhosts
- $equallogic_lun = Get-ScsiLun -Datastore $datastore | Select-Object -First 1
- $equallogic_lun_path = Get-ScsiLunPath -ScsiLun $equallogic_lun | Select-Object -First 1
- $equallogic_volume_name = (Get-EqlVolume | Where-Object { $_.iSCSITargetName -match $equallogic_lun_path.SanId }).VolumeName
- $equallogic_canonical_name = $equallogic_lun.CanonicalName
- 'EqualLogic Volume Name: {0}' -f $equallogic_volume_name
- 'EqualLogic Canonical Name: {0}' -f $equallogic_canonical_name
- # List the contents of the datastore to ensure that it is empty
- New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root '\' | Out-Null; ls ds:; Remove-PSDrive ds
- # Unmount/detach datastore from all hosts
- Unmount-Datastore -Datastore $datastore
- Detach-Datastore -Datastore $datastore
- # List the datastore status for each host
- Get-DatastoreMountInfo -Datastore (Get-Datastore -Name $datastore.Name) | Sort-Object Datastore, VMHost | Format-Table -AutoSize
- # Set the EqualLogic volume offline and list the status
- Set-EqlVolume -VolumeName $equallogic_volume_name -OnlineStatus offline; Get-EqlVolume -VolumeName $equallogic_volume_name | Select-Object OnlineStatus
- # Rescan all HBAs on all hosts
- Get-VMHostStorage -VMHost $esxi_hosts -RescanAllHBA -RescanVmfs | Out-Null
- # Remove the datastore from the detached datastores cache on all hosts and list the status
- # ESXi 5.5 and older
- $esxi_hosts | ForEach-Object -Process { try { (Get-EsxCli -vmhost $_.name).storage.core.device.detached.remove($equallogic_canonical_name) } catch {} }
- # ESXi 6.0 and newer
- $esxi_hosts | ForEach-Object -Process { try { (Get-EsxCli -vmhost $_.name).storage.core.device.detached.remove($true, $equallogic_canonical_name) } catch {} }
- $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