Last week my boss came to me and asked if I could write a script for a customer to register VM’s after being replicated from once VI environment to another. I agreed to take on the project and go for it.
Like everything I do these days I decided to use powershell to write the script. I have taken a liking to it and the fact that I can run the scripts on both ESX and ESXi hosts saves me from having to re-create scripts all the time. So I plugged away to 3am wrote the script, tested it inside out and sideways in my lab. I was confident in the scripts ability to register all vm’s form all datastores I went ahead and sent it off to the customer.
Read more…
Share on Facebook
Categories: Other, Powershell, Scriptng, VI_Toolkit, VMware Tags: Automated Deployment, Disaster Recovery, ESX, ESX 3.5, ESX4, PowerShell, Script, scripting, VI Toolkit, VMware
This is just a shameless plug to try selling books on DailyHypervisor.com…As you already know, Hal Rottenberg has written a book called “Managing VMware Infrastructure with Windows PowerShell TFM
”
Get it here:
Read more…
Share on Facebook
If you want to learn something about PowersHell and the VI Toolkit for Winders, the community forum is the best spot right now. Hal Rottenberg is one of the pillars of that section of the forums. Always glad to help figure out your code when things are not working and always ready to explain what the heck is going on with it. I think he taught me most of the things that I know about the VI Toolkit.
Well he has written a book called “Managing VMware Infrastructure with Windows PowerShell” Stop over to his blog and pre order the book. I am sure it will become a valuable asset in your tech library.
Read more…
Share on Facebook
This is a good powershell script for tacking virtual machine inforamtion for change management. It will output the vm’s name, the host it is on, the powerstate, Memory, Number of CPU’s, IP address, and FQDN to a csv file.
$IPprop = @{ Name = "IP Address"; Expression = { $_.Guest.IpAddress } }
$HostNameProp = @{ Name = "Hostname"; Expression = { $_.Guest.Hostname } }
Get-VM | select name, host, powerstate, MemoryMB, numCPU, $IPprop, $HostNameProp | export-csv c:\vm_info.csv
Share on Facebook
I was “forced” to learn how Powershell and the VI Toolkit works for an engagement a few months ago. Once you learn how powershell works and how the VI Toolkit integrates with Powershell, you will love it. This is coming from a linux guy who sees some of the VBScript stuff and just goes “HUH?!?” If you like VB SCripts, check out this post on Jase’s Place. Back in the day, I knew DOS scripting pretty well and I have learned rudimentary bash and perl scripting. To be frank, Powershell was easy for a knucklehead like me to pick up. I use it frequently to automate tasks in VI3 and the winders VMs it manages.
In my last post, I mentioned that VCB snapshots will cause VMware Tools to appear to go off line, even though they are still running. The fixes were to restart the management services on the host or login/logout of the guest. Restarting the management services on the host could cause issues if someone set up to automatically start VMs on boot. Logging in to the VMs is fine unless you have hundreds of VMs.
Read more…
Share on Facebook