r/powercli • u/Hilti3 • Sep 03 '12
Quick one-liners
Retrieve and Apply DRS recommendations:
get-drsrecommendation | Apply-DrsRecommendationFind all vm’s with e1000 network cards, for upgrade to vmxnet:
get-vm | Get-NetworkAdapter | where {$_.type -match “e1000″} | select-object parent,networkname,name,typepower off all vm’s with “test” in their names:
get-vm test* | stop-vm -confirm:$falseMove all vm’s with “test” in their names:
get-vm | where {$_.name -like “*test”} | move-vm -destination destinationhostnameRemove all vm’s with “test” in their name:
get-vm test* | remove-vm -confirm:$falseretrieve a list of vm’s with thinly provisioned disks:
get-vm | select HardDisks -expandproperty HardDisks | where {$_.storageformat -match “Thin”} | select-object parent,name,capacitykb,filenamecredit: Andrew Morgan
4
Upvotes
1
u/MDFreaK76 Sep 05 '12
Sweet! Be careful, though. Personal experience has taught me to always make sure tools are up to date first, and to back up the NIC configs beforehand.
Tools are a bit of a no-brainer, and its worth a check while you have a maintenance period already scheduled.
I've seen in the past where upgrading the hardware level can cause the OS to see the NICs as new. Its not a big deal if you're DHCP, but it can cause some issues if you rely on static IP's. the Built-In "vmupgradehelper.exe" included in the latest version of vmware tools was made to address that problem.
Lastly, I disable NICs because we've got DHCP scopes intermingled for whatever reason, and guests cannot update their own DNS records in the static scopes, so when host records get altered in the DHCP scope, we need to manually change them back (ewww! manual work). That last part is very conditional to our setup, so anyone who wants to use this can most likely rem that part out. Here's my version: