From e91b0c064913422ba6cd9aa70d7d4b02fbf203a2 Mon Sep 17 00:00:00 2001 From: mycloudrevolution Date: Wed, 27 Jul 2016 23:42:23 +0200 Subject: [PATCH] Get-VMID This will quickly return all IDs of VMs --- Scripts/Get-VMID.ps1 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Scripts/Get-VMID.ps1 diff --git a/Scripts/Get-VMID.ps1 b/Scripts/Get-VMID.ps1 new file mode 100644 index 0000000..a081bb3 --- /dev/null +++ b/Scripts/Get-VMID.ps1 @@ -0,0 +1,41 @@ +function Get-VMID { +<# + .NOTES + =========================================================================== + Created by: Markus Kraus + Organization: Private + Personal Blog: mycloudrevolution.com + Twitter: @vMarkus_K + =========================================================================== + .DESCRIPTION + This will quickly return all IDs of VMs + .Example + Get-VMID -myVMs (Get-VM) | ft + .Example + $SampleVMs = Get-VM "tst*" + Get-VMID -myVMs $SampleVMs +#> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true, + ValueFromPipeline=$True, + Position=0)] + [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] + $myVMs + ) +Process { + + $MyView = @() + ForEach ($myVM in $myVMs){ + $UUIDReport = [PSCustomObject] @{ + Name = $myVM.name + UUID = $myVM.extensiondata.Config.UUID + InstanceUUID = $myVM.extensiondata.config.InstanceUUID + LocationID = $myVM.extensiondata.config.LocationId + MoRef = $myVM.extensiondata.Moref.Value + } + $MyView += $UUIDReport + } + $MyView + } +} \ No newline at end of file