hi,
anybody know how to get the "UUID" with the VI-ToolKit?
thx
Just get the vm using Get-VM or other cmdlet and then pass Id to Get-View cmdlet. Then you can examine all properties exposed by the VI API VirtualMachine managed object
Get-VM <vm_name> | %{(Get-View $_.Id).config.uuid}
Regards,
Yasen
Just get the vm using Get-VM or other cmdlet and then pass Id to Get-View cmdlet. Then you can examine all properties exposed by the VI API VirtualMachine managed object
Get-VM <vm_name> | %{(Get-View $_.Id).config.uuid}
Regards,
Yasen
:smileylaugh: Thanks
Dumb question from a PowerShell expert but a relatively novice VMware guy--what is the UUID useful for?
(I like to think I've reached Journeyman status.)
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
We working with OSSV Backup. I want to make some helpfull scripts for the backup implementation.
Its the Universal Unique Identifier.
If you ever moved a VM around, you may have seen a prompt in VMware Workstation, or in ESX, asking if you want to keep the old UUID or create a new one. If you kept it, it would keep the same MAC address, etc. The VM would be seen as the same even though it have been moved (or was a copy running somewhere else).
For me, keeping track of the UUID can be useful for tracking the VM; i.e. in situations where the VM is being moved around (whether san replication, backup/recovery purposes, SRM testing, etc) from one datacenter to another, for example. For me, it can be useful to compare the old VM and it's properties, with the newly copied one running in the new environment. Just an example.
There is probably a better use for keeping track of your VM UUID's. But thats why i've tried to maintain a record of them. The script can be very helpful. I've just copied the UUID field from a VC export.
There is probably a cleaner way of doing this but I'm just starting with the Powershell scripting but I had a bizarre scenario where I knew the UUID but not the VM name so I wrote this script to list all the VM's in my environment with their UUID and output it to a text file which I could simply search:
-
#CREATE FUNCTIONS
function Find_UUID
{
foreach($vm in $vmlist)
{
echo ""
echo "UUID For $vm "
echo "UUID For $vm " >> $file3
get-vm $vm | %{(Get-View $_.Id).config.uuid}
get-vm $vm | %{(Get-View $_.Id).config.uuid} >> $file3
echo ""
echo "" >> $file3
}
}
#SET VARIABLES
$file1 = "E:\VMScripts\Variables\VMList.txt"
$file2 = "E:\VMScripts\Variables\VMList_Clean.txt"
$file3 = "E:\VMScripts\Variables\VMList_UUID.txt"
echo ""
echo "Finding UUID For VM Script..."
echo ""
echo "Producting List Of VM's..."
echo ""
get-vm | select name > $file1
echo "List Of VM's Produced"
(gc $file1) | foreach-object {$_ -replace " ", ""} | sc $file1
(gc $file2) | foreach-object {$_ -replace "Name", ""} | sc $file1
(gc $file2) | foreach-object {$_ -replace "----", ""} | sc $file1
cat $file1 | where {$_ -ne ""} > $file2
$vmlist = Get-Content $file2
echo ""
echo "Find UUID"
echo "Find UUID" > $file3
echo ""
Find_UUID
echo ""
echo "VM > UUID List Produced"
-
Someone in the room has written more than his share of CMD batch files. 🙂
[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator
Author of the book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
My theory used to be that if you couldn't do it with a batch file, it probably wasn't worth doing!
Very cool Thank you
Louis Ndjouou from ITOPSM, in Canada, delivering IT services
If you want it a little bit more compact then the version from Hpapy_Gilmore10. Use this:
Get-VM | Select-Object Name, @{ Name = "UUID"; Expression = {(Get-View $_.Id).config.uuid}}