Created
March 1, 2022 15:55
-
-
Save lamw/f3a3b7134c03b2d945d741a250c3f05f to your computer and use it in GitHub Desktop.
PowerCLI snippet to map PVC to vSphere Datastore
This file contains hidden or 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
$volumes = Get-CnsVolume | |
$results = @() | |
foreach ($volume in $volumes) { | |
$entityDetails = $volume.ExtensionData.Metadata.EntityMetadata | where {$_.EntityType -eq "PERSISTENT_VOLUME_CLAIM"} | |
if($entityDetails) { | |
$tmp = [pscustomobject] @{ | |
VolumeName = $volume.name; | |
PVCName = $entityDetails.EntityName; | |
Namespace = $entityDetails.Namespace; | |
Datastore = $volume.datastore.name; | |
CapacityMB = $volume.CapacityMB; | |
} | |
$results += $tmp | |
} | |
} | |
$results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment