forked from vMarkusK/vSphere-Modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-VMID.psm1
58 lines (52 loc) · 3.76 KB
/
Get-VMID.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function Get-VMID {
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2016.09 ver 1.0 Base Release
===========================================================================
External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/
===========================================================================
Tested Against Environment:
vSphere Version: 5.5 U2
PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1
PowerShell Version: 4.0, 5.0
OS Version: Windows 8.1, Server 2012 R2
===========================================================================
Keywords vSphere, ESXi, VM, vDisk
===========================================================================
.DESCRIPTION
This Function reports all VM IDs
.Example
Get-VM -Name TST* | Get-VMID
.Example
Get-Folder -Name TST | Get-VM | Get-VMID | ft -AutoSize
#Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#>
[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
}
}