-
Notifications
You must be signed in to change notification settings - Fork 10
/
Get-FreeEsxiLUNs.ps1
48 lines (46 loc) · 1.61 KB
/
Get-FreeEsxiLUNs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Get-FreeEsxiLUNs {
##############################
#.SYNOPSIS
#Shows free or unassigned SCSI LUNs/Disks on Esxi
#
#.DESCRIPTION
#The Get-FreeEsxiLUNs cmdlet finds free or unassigned SCSI LUNs/Disks on VMWare Esxi server. Free or unassigned disks are unformatted LUNs and need to format VMFS datastore or use as RDM (Raw Device Mapping)
#
#.PARAMETER Esxihost
#This is VMware Esxi host name
#
#.EXAMPLE
#Get-FreeEsxiLUNs -Esxihost Esxi001.vcloud-lab.com
#
#Shows free unassigned storage Luns disks on Esxi host name Esxi001.vcloud-lab.com
#
#.NOTES
#http://vcloud-lab.com
#Written using powershell version 5
#Script code version 2.0
###############################
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true)]
[System.String]$Esxihost
)
Begin {
if (-not(Get-Module vmware.vimautomation.core)) {
Import-Module vmware.vimautomation.core
}
#Connect-VIServer | Out-Null
}
Process {
$VMhost = Get-VMhost $EsxiHost
$AllLUNs = $VMhost | Get-ScsiLun -LunType disk
$Datastores = $VMhost | Get-Datastore
foreach ($lun in $AllLUNs) {
$Datastore = $Datastores | Where-Object {$_.extensiondata.info.vmfs.extent.Diskname -Match $lun.CanonicalName}
if ($Datastore.Name -eq $null) {
$lun | Select-Object VMHost, CanonicalName, CapacityGB, Vendor, Model, MultipathPolicy, ConsoleDeviceName, SerialNumber
}
}
}
End {}
}
#Get-FreeEsxiLUNs -Esxihost <Esxi001.vcloud-lab.com>