Skip to content

Instantly share code, notes, and snippets.

@mccbryan3
Last active May 12, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccbryan3/28c544d13f1e05e6f29b41789475392c to your computer and use it in GitHub Desktop.
Save mccbryan3/28c544d13f1e05e6f29b41789475392c to your computer and use it in GitHub Desktop.
This script will locate all luns on hosts that are not currently datastores and set output
try{
$luns = get-vmhost | Get-Datastore | Get-ScsiLun -ErrorAction SilentlyContinue
# $luns.CanonicalName
} catch {
"Error getting lun info for one or more luns"
}
$array = @()
Get-VMHost | Get-ScsiLun | ?{$_.CanonicalName -notlike "mpx.*"} | %{
if(($luns.CanonicalName -notcontains $_.CanonicalName) -and ($array -notcontains $_.CanonicalName)) {
$array += $_.CanonicalName
$hash = @{
VMHost = $_.VMHost
RuntimeName = $_.RuntimeName
LunId = [regex]::Match($_.RuntimeName, "L\d+").Value
CanonicalName = $_.CanonicalName
Model = $_.Model
Vendor = $_.Vendor
CapacityGB = $_.CapacityGB
}
}
New-Object psobject -Property $hash
$hash = $null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment