Last active
May 12, 2020 14:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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