Scripts

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.

Function to convert VMs from thin to thick using #PowerCLI & #PowerShell

Written March 20th, 2012 by
Categories: Scripts, Virtualization
4 comments

Most people want to go from thick to thin to save space. I, on the other hand, want to convert my VMs from thin to thick. Thin provisioning buys you time, basically, but what do you do when you’re vastly over provisioned and your VMs are filling up available physical storage? Sure, you can manually go to each VM and use the GUI to migrate them and convert each one to thick. I had a couple hundred that were thin provisioned and needed them converted to thick.

I’ve been moving from 500GB LUNs to 1TB LUNs, so I scripted it out to migrate VMs over, as well as convert to thick using the New-Object cmdlet.

Read the rest of this entry »

Easy way to check if your PowerShell variable is an array or not

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

I had a script that assumes something was an array, then failed when it wasn’t, so I needed a little checking:

$variable -is [system.array] will say True if it is an array, or False if not. You can also do $variable -isnot [system.array] and expect the exact opposite.

I chose to do this:

if($variable -isnot [system.array]){do some code expecting the $variable is not an array}
if($variable -is [system.array]){do some other stuff with $variable[0] being an array}

Use Powershell to change SCCM cache directory & cache size

Some of our older servers are running out of disk space on C:, so I needed to change the SCCM cache directory to D:. By default, this is where I wanted it anyway on our servers, leaving C: only for OS-related files. My OSD Task Sequences all have SMSCACHEDIR set to a folder on D in the client configuration step, but I noticed it wasn’t actually working. You know I had to find a way to fix that using powershell :D It actually ended up being really REALLY easy to do…

Read the rest of this entry »

Function to export VMs with thin provisioned disks to CSV file

Written September 12th, 2011 by
Categories: Scripts, Virtualization
No Comments »

I wanted to know how many disks in our environment are thin provisioned, so I wrote a quick function to export that list to a CSV file.

I have it pull the VM name, vmdk path & name, Size in GB, and if it’s Thin Provisioned (Boolean, which should always be true).

Read the rest of this entry »

function to list all VMs with Snapshots

Written September 12th, 2011 by
Categories: Scripts, Virtualization
No Comments »

Using the PowerGUI, you can list all snapshots, but unfortunately, it doesn’t list the parent VM.

I wrote a quick little function to search all VMs that have snapshots and list them.
Read the rest of this entry »

Create new role & user on ESXi host via PowerCLI & PowerShell

In this post I talked about automated deployment that launches the remote console for me. Since I had 24 hosts that need the user & role, I created a script that does it for me. Nothing special, just something quick that works…
Read the rest of this entry »

Automated deployment script builds VM, registers in SCCM

This is a follow-up to my last post about fully automated deployment

Below is the script. After it pulls the information from you, it creates the VM, adds the second disk, sleeps for 15 seconds, pulls the MAC from the new VM, creates the computer object in SCCM, adds it to the collection, sleeps for 15 seconds, refreshes the collection, sleeps for 15 seconds, then powers on the VM. If you’ve got a mandatory OSD advertised to the collection specified, and the OSD is fully automated, it will lay down the OS and the computername will be the name you provided to the script.
Read the rest of this entry »

PowerCLI + VMware + SCCM = sweetness, aka automated deployment

Written May 26th, 2011 by
Categories: Scripts
3 comments

So I’m creating a script that builds a VM for you, imports the NetBIOS name & MAC address into SCCM, adds it to a specific collection, and then powers on the VM. If you have a mandatory OS Deployment for that collection, you don’t have to do anything but sit back and watch (given your Task Sequence is fully automated).

It prompts you for vCenter name, VM name, cpu, ram, description, disk size, queries vcenter for clusters, networks, datastores (sorted by free space), and verifies with you before building…

I’m excited & pleased that it’s actually working. It’s currently proprietary to my work environment, but I will try to strip all that out and let you change what needs to be changed to use it where you like.

Happy Scripting!!!

Designed by ThepHuck
Wordpress Themes
Scroll to Top