Skip to content

Instantly share code, notes, and snippets.

@lamw
Created March 1, 2022 15:55
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 lamw/f3a3b7134c03b2d945d741a250c3f05f to your computer and use it in GitHub Desktop.
Save lamw/f3a3b7134c03b2d945d741a250c3f05f to your computer and use it in GitHub Desktop.
PowerCLI snippet to map PVC to vSphere Datastore
$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