Scripts

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
No 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 »

Script to pull host UUID for VMware PowerCLI

Written February 2nd, 2011 by
Categories: Scripts
8 comments

A reader on a previous post asked about pulling host UUIDs, so I wipped together this script.

Usage is like this:
Get-VMHostUUID.ps1 -vmhosts ("host1","host2","host3")or
Get-VMHostUUID.ps1 -vc vcenterserver -container cluster1/folder/dc/etc
Read the rest of this entry »

ESXi Auto configuration script

Lets face it, repetition sucks. When provisioning ESX hosts, using such things as the EDA make life easier, but it only does so much for ESXi.

The install for ESXi is simple and straight forward, but when done, you have to go and set everything else (IP, hostname, DNS, local users, etc…). Doing this for 20 hosts could be a PITA (Pain In The A..), so I set out on writing a script that does all of this for you.

All you have to do is set the IP & root password, then verify you can ping the host by it’s hostname (set host/A record in DNS). Once that’s verified, here’s what the script does for you:

  • Creates an Admins group and assigns it to the Administrator role
  • Creates local users, sets their default password, and adds them to the Admins group
  • Sets primary & secondary NTP & DNS servers
  • Sets DNS search suffix
  • Combines the provided hostname with DNS search suffix to populate the hostname FQDN
  • Sets EnableNaviReg to 0, disabled (requested by my storage team)
  • Disables iSCSI (disabled by default, but enabled in my sd image I created from previous post, thus the need to disable)
  • Disabled Tech Support Mode, aka ‘unsupported’ console

This is a slightly more advanced script, and it’s not fully polished, but works. Read the rest of this entry »

Using PowerCLI to rescan HBA and VMFS v2

I wanted to expand This Script to allow you to specify hosts as well, instead of just vCenter.

This came about because we have 20 new hosts that need storage so we can build our new vCenter server on them, and my old script wouldn’t suffice.

I know you can rescan at the container level (cluster, folder, datacenter), but sometimes the processes would hang on large clusters, other times I’d have to rescan twice. I like this script because it rescans all HBAs one by one, then rescans VMFS after. One could probably add the -runasync, but then it’s the same as the right-click in vCenter.

So, without further ado, here’s the updated script: Read the rest of this entry »

Finding WWNs for HBAs in multiple ESX or ESXi hosts, standalone or clustered

**Update May 07, 2012 – Use the new script here: Updated: Finding WWNs for HBAs in ESXi hosts, now with Get-VMHostHba

When building a new cluster, your storage team (or you) may need to add several hosts into the shared storage zone. It’s a pain to go to each host, configuration, storage adapters, then copy out the WWN.

With this script, you can supply a vCenter server and Cluster/Folder/Datacenter (any logical container) and it will list all the WWNs for Fibre Channel devices. But what if you don’t have vCenter stood up yet? No problem, you can also supply a list of ESX/ESXi hosts to scan.

Shawn & I built this because we have 20 hosts we need the WWNs from to provide to our storage team, and vCenter isn’t alive yet.

Our script: Read the rest of this entry »

PowerCLI script to get Datastore UUIDs

Written April 29th, 2010 by
Categories: Scripts, Virtualization
18 comments

Awhile back a guy at the San Antonio VMUG asked the technical group how you could get the actual LUN UUID for a particular Datastore. I informed him that it was available via the PowerCLI and to contact me via the VMUG forums. He never did. My storage guy at work loves this script, though, so I thought I’d share it with everybody.

Here’s the script: Read the rest of this entry »

Using PowerCLI to rescan HBA and VMFS in a cluster

Written April 20th, 2010 by
Categories: Scripts, Virtualization
1 Comment »

Having an ESX cluster is nice, and adding shared LUNs can sometimes become click redundant (host, config, storage, rescan; repeat).

Since we’ve been migrating to a new storage array, we’ve been adding quite a few LUNs to different clusters on different vCenter servers, so I wanted an easy way to rescan everything.

So here’s my script: Read the rest of this entry »

Mass Storage Migrations using vSphere Storage vMotion and PowerCLI

We ran into an issue where we needed an entire SAN frame retired. Problem is, there are several datastores and several guests running on that frame.

I wanted to script it out, which worked just fine. Then, we had more to do, so I edited the script and ran it again. After the third or fourth time, I decided to write a script that takes params via the cli.

Make sure your datastore names are similar, for instance, mine appends ‘_New’ to the end. So my datastores have to be named like this: ‘vmdatastore’ and ‘vmdatastore_New’. It will get all guests on the datastore and migrate them one by one over to the new datastore. When done, just delete the old datastore (or rename it to _Old) and rename the new one to match.

My script: Read the rest of this entry »

Designed by ThepHuck
Wordpress Themes
Scroll to Top