I have a number of admins over the weekend which will be powering off VMs and applying our VMEncryption storage policy. I am not yet comfortable to create and distribute a script for this, but I want to create a script that will monitor and email the task PercentComplete. However, I cannot obtain the VM name from the get-task objects, I can only get the objectID and cannot seem to translate that easily.
Excerpt from my script:
$Report = get-task |
Select-object Name,
PercentComplete,
objectID
Ok, got it.
Try like this
Select-object Name,
@{N='VM';E={(Get-View -Id $_.ObjectId -Property Name).Name}},
PercentComplete
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Are you using the VMware.VMEncryption module?
Mike has an accompanying post that describes the cmdlets in that module, and also how to monitor progress.
See PowerCLI for VM Encryption.
Did you check that out?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for replying Luc.
Yes I am aware of the VMware Encryption Module, I've also spoken to Mike and have some scripts to report VM Encryption Status, as well as report on all the Key IDs to we can archive this. All good on the encryption front. Not using that Module on this script though.
As you're well aware, the time it takes to encrypt a VM can vary from minutes to hours. So, I essentially just want to monitor the "Reconfigure Virtual Machine" task and report back to the user what the % is at that time. This would give them a good feeling of how much longer it would take - they can go to the park with the kids, they should stick around as it might finish in the next 20 minutes, etc.
To do this, I have taken to PowerCLI to create a report of the running tasks and send via email then scheduling it to run every 15 minutes. My report is below, but I would like to essentially include the VM name so they're aware which task is running.
$Report = get-task |
Select-object Name,
PercentComplete,
objectID
Ok, got it.
Try like this
Select-object Name,
@{N='VM';E={(Get-View -Id $_.ObjectId -Property Name).Name}},
PercentComplete
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wow, simple enough. It shows the name twice oddly but it's more than usable, really appreciate it.
If you're up for it - What If I wanted to report only on Tasks named "ReconfigVM_Task" ?
Sure, try like this
Select-object Name,
@{N='VM';E={(Get-View -Id $_.ObjectId -Property Name).Name}},
PercentComplete
What do you mean by the name twice?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm embarrassed, I don't know why I overthought that. Thanks
Two Values in VM property:
Are you by any chance connected to multiple vCenters? Or using linked-mode?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, I am in linked mode. But I have not connected using –alllinked and this occurs if I connect to one vcenter or both.
In fact, I may have been connected prior. My script does the connections and I've done a disconnect from all viserver and now it displays just one per line.
Thanks again for all your help.