Setting DNS for Windows servers is straightforward using PowerShell. Utilizing Get-WMIObject Win32_NetworkAdapterConfiguration against a list of servers from a text file in a loop is the best way to handle a bulk dns change to your servers. I was prompted to share my PowerShell script after reading a post from Mike Tabor on his blog at MikeTabor.com titled How to update VMware Windows VM’s DNS using PowerCLI .
Mike Tabor goes through his process of taking an old script he found and updated it to more modern PowerCLI script. His script is very useful in that you can change the IP address in addition to setting dns for Windows servers in your VMware environment. He credits Jase McCarty who created the original script and helped Mike update it. I encourage you to go check it out.
Here is my purely PowerShell script that I have been using for the past few years to make dns changes. It does not update IP addresses but does allow for changes to dns settings. Using a foreach loop with all the necessary dns settings through Get-WMIObject makes for a simplified script. But just because it is simplified doesn’t mean you can’t do mass amounts of damage to your environment. I always test against a few individual test servers just to make sure before I send this against all my Windows servers.
It does work on both physical and virtual Windows computers. Unfortunately we still have a few Windows physical servers so I will still utilize this script when setting dns for Windows servers. However, when I need to make a mass IP and dns change to virtual machine servers I will utilize Mike Tabor’s script. I expect that soon my environment will not have any physical Windows servers. All virtual is the goal!
Caution: Like all code you download from the internet,
please understand and modify the code accordingly to prevent unforeseen
production problems. Also known as career-altering events.
This week I am sharing a very helpful PowerCLI script to vMotion a vm from one SSO domain to another SSO domain. I shamelessly borrowed this script from Romain Decker’s site Cloud Maniac. The original script was very good and functioned well. I just took it a step further and added some functions to customize it for our environment. These functions are: Get-SourcevCenter, Get-DestvCenter, Ask-VMNameForMigration, Ask-DCForMigration, Ask-ClusterForMigration, Choose-StorageForVMMigration. The names of each function should explain their use. Essentially you will need to edit the script to customize some of these functions for your environment.
I have used it dozens of times and it works flawlessly with one exception. If your EVC modes don’t quite match between vCenters there may be some vms that cannot be vMotioned while powered on. Just arrange for a downtime and try again with the vm powered off. It will work well. This sure beats downloading a vm to your desktop and then uploading it to the new vCenter environment. If you need any explanation or help with modifying this code to fit your environment please feel free to comment.
Since I work in a multiple vCenter environment, it is nice to have a function that allows for a connection choice when running a PowerCLI script. The Get-vCenter function has an array of all the vCenters I potentially might connect with to run a PowerCLI script. This array is presented in a numbered format that allows the script user to choose the vCenter they want to use for the rest of the script. You can make the array as large or small as you want. It will dynamically create a numbered choice next to each vCenter. It is simple but comes in very handy.
Caution: Like all code you download from the internet, please understand and modify the code accordingly to prevent unforeseen production problems. Also known as career-altering events.
Do you have to generate more than a few ssl certificates as part of your day-to-day job? Would you like to script it? I have a script for you. This PowerShell script has proven itself very indispensable when we had to replace all of our sha1 certificates. (Thanks Google!) I hope you find this script useful and if you do, please leave feedback.
Note: You can always modify the script to accept a list of fully qualified domain names if you need to produce a large quantity of certificates.