Hello! Long time, no scripting! I’ve been blowing through VCF, deploying, redeploying, and built some scripts to help me with this. Sharing is caring, read on to see what I’ve done…
Hello! Long time, no scripting! I’ve been blowing through VCF, deploying, redeploying, and built some scripts to help me with this. Sharing is caring, read on to see what I’ve done…
I’m writing a script to deploy Azure VMware Solution (AVS) and ran into a situation many of us likely have: Some parameters depend on other parameters.
I started with Parameter Sets where I did have several parameters participating in multiple Parameter Sets, but that didn’t work how I thought it would (or should).
Here’s what didn’t work:
1 2 3 4 5 6 7 8 9 10 11 12 |
[CmdletBinding(DefaultParametersetName="cli")] param( [Parameter(ParameterSetName="cli")][Parameter(ParameterSetName="createVNET")][Parameter(Mandatory,ParameterSetName="VMInternet")][switch]$createVNET, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="createVNET")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetIPSubnet, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="createVNET")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetGatewaySubnet, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="createVNET")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetBastionSubnet, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="createVNET")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetManagementSubnet [Parameter(ParameterSetName="cli")][Parameter(ParameterSetName="VMInternet")][switch]$EnableVMInternet, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetFirewallSubnet, [Parameter(ParameterSetName="cli")][Parameter(Mandatory,ParameterSetName="VMInternet")][string]$vNetHubSubnet ) |
My intention was to have additional mandatory parameters based on additional switches. For instance, if you add “-createvNet”, the script needs four additional parameters. Also, if you used “-EnableVMInternet” without “-createvNET”, the script will also need to recognize that wasn’t supplied and make the parameters with it mandatory. Spoiler: that didn’t work.
Recently I had a colleague come to me with a request. They had a Nutanix Prism Central production environment with certain images loaded. The previous administrator failed to document where those images were stored and they could not be located. My colleague wanted to download the images from their production Prism Central so they could upload them to a new test environment. I have written a Python script that will make that quite easy.
I was reading VCDX56’s post Nutanix AHV VM Reporting Via REST API authored by Magnus Andersson @magander3 where, as the title suggests, he discusses a script he wrote to gather information about VMs running on a Nutanix AHV cluster using the REST APIs. At the end of the post, he mentioned that he would like to change the script from Bash to Python.
I have recently been doing quite a bit REST API scripting with Python, so I took a crack at it last night.
I’m sure many of you know of Plex Media Server (PMS) and how awesome it can be for letting your kids watch your movies on the go. It likely needs no introduction, but if you’d like to learn more, please click Plex Media Server to be taken to their site.
In my home lab running ESXi through my VMUG Advantage EVALexperience (shameless plug, I know), I have an ubuntu VM I built specifically for PMS with 2 vCPUs & 4GB of RAM.
I then set up the mounts for my Synology NAS where my movie folders are so they’re mounted at boot, installed PMS, configured libraries, did some customizations, and BOOM! Kids’ movies on my phone on the go!
I was playing in my lab today and ran across something I thought was strange. I exported the privileges from a test role in one lab, which happened to be vSphere 5.5, then tried to create a new role in vCenter 6.0 with the privileges I just pulled. It worked fine for almost everything, except these two:
Could not find Privilege with name 'Enable Fault Tolerance'.
Could not find Privilege with name 'Disable Fault Tolerance'.
I thought that was kind of strange, so I ran a quick
1 |
Get-VIPrivilege | ? {$_.name -like "*fault*"} | select Name,Id |
and looked for something similar. Below is the comparison of 5.5 & 6.0:
vSphere 5.5
Name - Id
------
Turn On Fault Tolerance - VirtualMachine.Interact.CreateSecondary
Turn Off Fault Tolerance - VirtualMachine.Interact.TurnOffFaultTolerance
Disable Fault Tolerance - VirtualMachine.Interact.DisableSecondary
Enable Fault Tolerance - VirtualMachine.Interact.EnableSecondary
Query Fault Tolerance compatibility - VirtualMachine.Config.QueryFTCompatibility
vSphere 6.0
Name - Id
------
Turn On Fault Tolerance - VirtualMachine.Interact.CreateSecondary
Turn Off Fault Tolerance - VirtualMachine.Interact.TurnOffFaultTolerance
Suspend Fault Tolerance - VirtualMachine.Interact.DisableSecondary
Resume Fault Tolerance - VirtualMachine.Interact.EnableSecondary
Query Fault Tolerance compatibility - VirtualMachine.Config.QueryFTCompatibility
The difference is not drastic, but one simply word, or even one character, out of place will cause your script to fail. It’s easy to see that “Turn On” and “Enable” sound the same, so the need to rename “Enable” to “Resume” makes sense to me. Same with Disable & Suspend. These are just the two I know about, I really should write another article listing which ones have changed, but that’s for another day :)
Just something to watch out for I wanted to share.
Happy scripting!
Hey scripters! I recently had a task of migrating an entire virtual datacenter from one vCenter to another. It sounds like a pretty simple task, but manually recreating the cluster(s) could cause some human errors. I decided to write a script that would look at a specific vDatacenter and get all it’s clusters, then recreate that tree in the new vCenter. It’s pretty simple, really, it pulls all the clusters, then creates new clusters with the same attributes. When moving over the hosts, it first disconnects them from the original vCenter, then removes them from inventory.
I thought about disabling HA & DRS on the source vCenter cluster right before hand, but manually disconnecting & removing shouldn’t be an issue. If you add the host to the new vCenter without first removing from the old vCenter, that’s when you’ll get some HA weirdness because the old vCenter doesn’t know what just happened.
This post is long over due. I’ve been playing with Windows Server 2012 without the GUI (aka Core) for a while and one thing that irks me is that without the Graphical Management Tools, you’re really stuck using old school “net user” commands. Sure, you can use another GUI 2012 server’s Server Manager to connect and manage your core server, but what if you only have one core server you’re testing? Or, what if you simply want to do things the hard PowerShell way?
I had some ideas, since 2012 Core has the SConfig thing, I decided to do something similar and create a user-management script specifically for this scenario.
So what does it do? Some pretty basic tasks: create & delete users, create & delete groups, as well as edit users. Editing users includes changing the password, enable & disable, and adding & removing group membership. All done from a nice little PowerShell window!
A few days ago I received a comment on This Post requesting a custom script to take a list of VMs from a file and convert them to thick. I quickly slapped something together and sent it to him for testing.
**REMEMBER** When converting thin to thick (or vice versa), you have to actually migrate the VM to a different datastore.
I’m posting this because it can be coupled with another post I have about Exporting VMs with Thin Disks to a CSV file, which would work perfectly for this. Run this one first to get a CSV with all your thin provisioned VMs.
In the Export Thin script, you will need to change the VM header in the CSV file to Name, since that’s what the migrate script looks for (or change the migrate script, up to you), add in a Destination header for the destination datastore in the CSV file after it’s exported. You could then plan it all out so your VMs are moved to specific datastores.
I added a bunch of cmdlets for VMware’s PowerCLI to the cmdlets array in the powershell.php file.
So you don’t have to export and copy & paste them in to yours, I attached it to this post.
This is for the WP-Syntax plugin for WordPress that uses GeSHi to highlight certain things in the pre tag.
Just thought I’d share…