Automatic Plex Media Server update script for Linux/Ubuntu

Written March 14th, 2016 by
Categories: Scripts

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!

Sounds awesome! Why are you writing a post?

Read the rest of this entry »

vSphere Fault Tolerance Role Privilege names have changed from vSphere 5.5 to 6.0

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

Get-VIPrivilege | ? {$ -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!

PowerCLI script to migrate clusters to new vCenter

Written April 30th, 2014 by
Categories: Scripts, Virtualization

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.

What does it do?

Read the rest of this entry »

PowerShell User Management script for Windows Server 2012 Core

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!

Here’s a screenshot:
User Management Script Menu Read the rest of this entry »

Reader Request: Scripted VM Conversion to Thick from input CSV file using PowerShell PowerCLI

Written August 14th, 2013 by
Categories: Scripts, Virtualization
No Comments »

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. Read the rest of this entry »

Added VMware’s PowerCLI cmdlets to the powershell.php for WP-Syntax & GeSHi

Written February 14th, 2013 by
Categories: Scripts
No Comments »

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…

Scripting it old school! Bash shell script to apply ESX 3.5 Update 5a

Written December 14th, 2012 by
Categories: Scripts, Virtualization
No Comments »

So you’re still using ESX 3.5 and need to patch it manually? Bummer, I know, I’m in that boat right now, or was.  I ran “esxupdate -a query” to find out the latest patch and saw, “ESX Server 3.5.0 Update 4”.  Then went to VMware’s downloads site to download Update 5a, and when it prompted me to download all dependencies, I did.

What did that give me? Nineteen (19) bundles/depots/zip files, one of which was ‘’ Read the rest of this entry »

PowerCLI one liner to move all VMs on one datastore to another and convert to thick or thin

Written June 13th, 2012 by
Categories: Scripts, Virtualization

I wrote this post a while back on how to use the API to convert VMs from thin to thick, which you could also go from thick to thin using it. I had written it because I was trying to use the inflate function, which isn’t allow against powered on VMs.

It was pointed out by a reader that I could have simply used Move-VM to accomplish the same task. This is great, shows how a second set of eyes and a different perspective can help you solve the problem. You could simply do

Move-VM vmservername -Datastore datastorename -DiskStorageFormat thick

and it will move your VM to the specified datastore and convert to thick. You could use either thin or thick.

If you wanted to move every VM on a datastore, say Datastore1, to a new datastore, say Datastore2, and convert all of them to either thin or thick, you could do it like this:

Get-VM -Datastore Datastore1 | Move-VM -Datastore Datastore2 -DiskStorageFormat thick

You cannot specify the current datastore as the destination datastore, though. It will complete, but it will not convert your VM’s disk format, you have to actually Storage vMotion the VM to a different datastore. It basically validates the destination datastore is where it currently resides and exits without trying to convert your vmdk.

You could then take it a step farther and make a function that supports parameters, like if you wanted to move VMs on multiple datastores, or a given list of VMs to a specific datastore. For instance, you could create something like “convert-vms.ps1” and run it like this

convert-vms.ps1 -vms ("vm1",vm2","vm3","vm4") -destination datastore2 -thick

and it would move all four VMs to datastore2 and convert them to thick in the process. Or something like

convert-vms.ps1 -source ("datastore1","datastore2") -destination datastore3 -thin

That would move all VMs from datastores 1 & 2 and thin provision them on datastore3.

If anyone’s interested in the actual script/function, let me know and I can put one together fairly quickly.

Script to join ESXi 5 hosts to Active Directory for Directory Services Authentication

I’m getting ready to upgrade a ton of our ESXi hosts to 5 and wanted a quick way to join all of them to AD after. I could probably do a fresh install and incorporate this into my ESXi Config Script, that’s a consideration, but for the time being, a script that targets clusters, folders, vDCs, etc, will work. The script can also target individual ESXi hosts, they do not have to be joined to vCenter.
Read the rest of this entry »

Next release of #PowerCLI will stop on invalid certificates

I’m a little late to the game, but finally got around to installing PowerCLI 5.0.1. Upon connecting to my lab vCenter, I learned of the behavior change that will appear in future releases of PowerCLI. In short, you won’t be able to connect.

By default, it’s unset:

To change that, set the Invalid Certificate Action to Ignore:

You simply type this:

set-PowerCLIConfiguration -invalidCertificateAction "ignore" -confirm:$false

It could potentially break all your scripts if you upgrade to whatever’s after 5.0.1.

Designed by ThepHuck
Wordpress Themes
Scroll to Top