Scripts

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

Written March 20th, 2012 by
Categories: Scripts, Virtualization
12 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
7 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}

OR

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 »

Script to export VMs with thin provisioned disks to CSV file

Written September 12th, 2011 by
Categories: Scripts, Virtualization
3 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!!!

Script I needed to get info for multiple VMs = Get-VMInfo.ps1

Written May 5th, 2011 by
Categories: Scripts, Virtualization
2 comments

I’ve recently had a ton of requests for information about specific VMs. They want to know how many disks they have, CPU count, how much RAM, and which environment the VM resides in.

Instead of constantly searching vCenter, I wrote this quickly during the meeting to query multiple servers.
Read the rest of this entry »

PowerShell multithreaded script to recursively search for file types, shows count and total size

Written February 10th, 2011 by
Categories: Scripts
4 comments

I recently had a requirement to build a script that listed all PST files on some of our DFS folders. I know there are a bunch of ways to get this done, but I wanted to build my own way. Since we needed to search roughly 20 directories, I decided to play with the Start-Job cmdlet so I could have one script to spawn multiple worker processes. At first, it was tricky (since I had never even messed with it), but anyone can easily pick it up.

Read the rest of this entry »

Designed by ThepHuck
Wordpress Themes
Scroll to Top