How to stop VMware Tools Install en masse with PowerCLI!

The other day I was looking at one of my SRM sites and noticed that a CRAP load of VMs were complaining about a CD-Rom mounted, and I was all like, “deh, what is going on!” Well, there was a mass-installation of the VMware tools in place, or at least the tools were mounted.

This is awesome and all, but I didn’t want these VMs to have the tools installer active any more and instead wanted to CANCEL ALL OF THEM!  Sure I could right click on each VM and deactivate the tools installer, but this was for hundreds of VMs, and that sounds annoying.

So, for your benefit and very simply…

Get-VM * | Dismount-Tools

Yes, it is literally that easy. :)  Poof and you’re done! You can call out specific VMs if you’d like, but I think you have that under control by now!

Using PowerCLI to Shutdown a VM resize vCPU and Memory and Power back on!

You ever been in that situation of “Oh no, I need to modify a VM to increase/decrease the number of vCPUs and Memory, but I can’t do it during normal business hours” Or whatever the situation may be?  Well, fellow #vExpert @BoBolander and I were discussing this recently, and worked together to create this!  This also will apply if you’re doing this to multiple virtual machines!

Well, look no further. :) You can script this, as in to execute it as a script to happen while you’re at home asleep during your maintenance window, but also even if you’re modifying a simple VM and want the LEAST amount of time and effort possible, minimizing the downtime of the VM this will work also!

Shutting down your Virtual Machine via PowerCLI

This will seem simple, that is because it frankly is.  For the purpose of these descriptions I’m going to use a long VM name so you know this works if a VM has a name with quotes or spaces in it.  So for these purposes, the VM in question will be named, “VMware vCenter Log Insight 1.0.4”

Shutdown-VMGuest –VM “VMware vCenter Log Insight 1.0.4” –Confirm:$False

Wow, that was simple! So I run that and my virtual machine is shut down? Yes. Yes it is.

Changing your Virtual Machines vCPU and Memory

There you are, your VM is currently rocking out at 4GB of Memory and 1vCPU and you’re all “I really want this to be 8GB of memory and 2vCPUs! You know, because I did the analysis and notice that it’ll perform better, no I’m not just blindly following some vendors ‘best practices’” Ok, if you’re serious about this, here you go!

Set-VM “VMware vCenter Log Insight 1.0.4” –MemoryGB 8 –NumCPU 2 –Confirm:$False

Whoa, that was it? My VM now has its resources resized just like that? Yes. Just like that. You’re done!

Please Power my VM Back on! I have work to do!

Alright alright, you want to power your VM back on, you’ve made your change and you’re set! Well, here you go just as simply…

Start-VM –VM “VMware vCenter Log Insight 1.0.4”

And poof your VM will start back up and you’ll be set!

You can combine The Set-VM and Start-VM ya know!

Yea, that’s correct! You can instead run the last two components as a single one-liner command like;

Get-VM “VMware vCenter Log Insight 1.0.4” | Set-VM –MemoryGB 8 –NumCPU 2 –Confirm:$False | Start-VM

Unfortunately I’ve yet to find a way to combine the VM Shutdown component and the Set-VM Component without it breaking, thus…

Hey but wait, I thought you said this was scriptable

You’re all like, “I can’t just copy and paste these in sequence because my VM hasn’t shut down in time and I get an error trying to use CPU hot plug, and I can’t power the VM back on because it’s still shutting down!!!”    Yep, you got it, you’re absolutely correct! The initial steps were more to provide the steps of how you can go about modifying all of this from the PowerCLI command line, now if we’re really serious about this, here’s a multi-liner which will perform all of these tasks in sequence! Will this work if you don’t have VMware Tools installed? No. No it will not. Get your tools installed, ya’here! :)

  • $vm_name = Get-VM “VMware vCenter Log Insight 1.0.4”
  • ForEach ($vm in $vm_name){
  • $vm_name | Shutdown-VMGuest –Confirm:$False
  • Sleep 60
  • $vm_name | Set-VM –MemoryGB 8 –NumCpu 2 –Confirm:$False
  • $vm_name | Start-VM
  • }

A few things… I had to do this in a bulleted list because otherwise the spacing between it was ridiculous, and secondly, am I proud of the utter lack of elegance of this code? No. Not in the least. I think this is the ugliest thing I’ve ever seen. Does it work? Yes. It works QUITE well.  I can equally execute this as an Import-CSV to perform this against a whole series of Virtual Machines but that is outside the scope of this particular blog post. :)

If you happen to have a more elegant want to execute a VMGuest Shutdown while ALSO executing a Set-VM within the same command-set, preferably within one line, feel free to include it in the comments, otherwise this will work and can be scripted whether you’re performing against one virtual machine or more.   I personally will use this to script/execute easy modification of resources when I need to grow or shrink a virtual machines allocations without having to go through and ‘right click – wait’ over and over again, and especially so when I’m performing this against more than one virtual machine.

Good luck, I look forward to your comments, thoughts, and any improvements you may have! Hopefully this helps improve your own management!

Free VMware vCenter Log Insight book on Understanding Real-time Log Analytics!

Understanding Real-time Log Analytics

I’ve been meaning to post this blog for a few months now, but hey here it is now!

This little gem was posted some time ago Free eBook: vCenter Log Insight sweet post right?! I mean, I’m sure you’ve played with vCenter Log Insight at this point like VMware Log Insight EXPOSED! Splitting your Syslog with an axe!

But even if you haven’t check it out and get a dive into this cool technology to advance your datacenter!

Click here to get your free copy of Understanding Real-time Log Analytics. You’ll need to fill out a little form but beyond that you’re set! Check it out! <3

OMG! Free Microsoft Virtualization Certification Voucher! (MS 74-409)

So you’re all like, Whaaaaaat?!!? That’s right. Until June 30th 2014, you can get a free voucher in super fast fashion!

Visit this handy link; http://www.microsoftvirtualacademy.com/offers/virtualizationsquaredoffer

Free Microsoft Certification!

Then just click on the “Get Free Voucher” – Which will pop up with a window like this; (And Yes, it is an ACTUAL Pop-up so pop-ups cannot be blocked)

image

Here is the real catch, you click the green check mark itself. Yes it says that, but sometimes we ignore the words it says.  :)

Then it will ask you to login to your Live account, or create an Microsoft Virtual Academy account (basically a live account) and boom! FREE VOUCHER!

Then it’s just a matter of scheduling your exam, studying of course and poof, getting another exam freeeee of charge! Good luck ya’ll!

A VMworld Public Service Announcement from your favorite #vExpert :) (Book your hotel NOW!) 2014 Edition!

Some of you may have read my past VMworld posts like;

Well guess what.. the time is here again for this announcement! Which unfortunately has some good news and some bad news!

In 2013 I put that announcement of booking your hotel out in January, great, right? It lets you get ahead of things so you can get that hotel BOOKED! Well, this time I sat on it for a few months, hey the warzone gets in the way… It was on my task list and I finally decided to publish this helpful reminder.

Where the bad news starts to slip in is… I was looking at hotel pricing (using Marriott.com as an example) and HOLY OMG. The “cheapest” hotel I could find while still being near Moscone was $269 a night, then it went $409, $469, and then north of $500.  Oh that was with special discount codes too, to make it “cheaper”.  Yea, it’s time to book things, note: booking a hotel ‘reserves’ the room and you can cancel it at any time in theory.

When you use something like Airbnb you’re charged immediately but the prices tend to be a bit more reasonable.

I’m currently trying to line up my OWN Accommodations but I couldn’t let you suffer the same challenge I did while trying to find what ‘housing’ I’ll be pinned down with come VMworld :)   So get out there and get your booking on! Worst case you can cancel your hotel booking and free it up if you find yourself not attending or such!

<3 Your favorite Warzone #vExpert :)