CategoryQuick tips

Quick PowerShell script to Storage VMotion a list of VMs

Everyone has simple scripts they use to get through their day, I’m sure. The following scenario deals with having a large list (as provided in a .csv) of VMs needing to be migrated to a different datastore cluster. When dealing with multiple migrations, Storage DRS doesn’t update as quickly as one would like. Therefore, the current LUN with the most space can quite quickly be pushed to capacity. Thus, in this script we sort all of the LUNS by the amount of free space, grab the top 10 with the most free space, and randomly pick a lun to migrate the next VM.

For our own purposes, we prefer to make sure all the .vmdks are eager zeroed. So just in case, we transform any potential non-thick provisioned eager zeroed disk.

Cleaning up Bad or ‘Stuck’ Requests in vRealize Automation (7.1)

Had a few requests that stayed within the system even though the builds failed.  This led to repeated attempts by vRA to expire items that didn’t exist.  Got together with VMware Tech Support and learned this handy method of clearing these requests up.

1. SSH into the vRA appliance
2. su -c “/opt/vmware/vpostgres/9.5/bin/psql vcac” postgres (ignore the “could not change directory” error you’ll get)
3. update cat_resource set leasestate = null, status = ‘DELETED’, datedeleted = now()::timestamp where name = ‘Target Item Name‘;
4. update comp_deployment set status = ‘DELETED’ where name = ‘Target Item Name‘;
5. \q
6. Exit

Hope that helps.

© 2018 msharp tech

Theme by Anders NorénUp ↑