PowerCli to Increase Hardware on Multiple VMs

The other night I had a task of upgrading 22 VMs with additional vCPUs and memory.  I also had a maintenance window of 60 minutes to get this completed.  So I wasn’t going to do this more than once, so I just wrote a simple PowerCli script that would handle this process for me.

$servers = "VMServer01","VMServer02","VMServer03","VMServer04","VMServer05"

foreach ($server in $servers){
Shutdown-VMGuest $server -confirm:$false
Do {
sleep -Seconds 5
$Status = (Get-vm $server).powerstate
If($status -eq "PoweredOff")
{"$Server has been powered off adding hardware"}
else{
"$server is still powered on looping until off"
}
}
While ($Status -eq "PoweredOn")

$TotalvCPU=6
$Cores=1
$VMname = get-vm $server
$spec=New-Object –Type VMware.Vim.VirtualMAchineConfigSpec –Property @{“NumCoresPerSocket” = $cores}
($VMname).ExtensionData.ReconfigVM_Task($spec)

$VMname | Set-VM -MemoryGB 28 -NumCpu $TotalvCPU -Confirm:$false

Sleep -Seconds 5
Start-VM $server -Confirm:$false
}

So this script starts off identifying the servers that the work is going to be performed on.… Continue reading

Using PowerCli to gather NIC settings

We had some changes recently in the environment, and the old DNS and WINS servers were decommissioned.  So I was tasked with getting all of the NIC settings of the virtual machines so we can see how many were using the old settings.  So I started with a simple WMI call to gather the settings from the NICs.… Continue reading

VMware PowerCLI Hands-on-Learning Review

Have you been wanting to learn PowerCLI but don’t have a test environment to practice with out the fear of breaking live production? That is where this hands-on-learning (HOL) lab from VMware can come in handy.  I personally worked through this HOL and found that the information that was provide to be very thorough to help with beginners wanting to start with PowerCLI.  … Continue reading

Using PowerCLI to set IP and Update VMware Tools

This is a continuation of my last post, Using PowerCli to Build multiple VMs.

After automating the building of VMs, what’s the sense of having to manually add the IP information or updating the VMware tools? It’s pointless. So we need to add the IP information to the CSV file that was used to build the VMs.… Continue reading

Using PowerCLI to build multiple VMs

My first script that I ever wrote was a script to build VMs. I was the newest member on the team, and i was giving the task of building 50 VMs for a new project that was getting started. It was a very daunting task, due to the completion date to have these 50 VMs to be completed.… Continue reading

PowerCLI to find all VMs with thick provisioned VMDK

In my environment at work we have a policy that we thin provision all new VMs. We had an issue with a datastore that was running out of space, so I starting looking into it and found that several of the VMs on this datastore were set with thick provisioning on the hard drives.

Get-Datastore | Get-VM | Get-HardDisk | Where {$_.storageformat -eq "Thick" } | Select Parent, Name, CapacityGB, storageformat | FT -AutoSize

This outputs a list of VMs with the storageformat that is set to thick. … Continue reading

PowerCli to get list of unused RDMs on VM Cluster – Updated

After finishing the last post and starting to use it after limited testing I found that my script wasn’t filtering out the Datastores as expected.  This information was presented to me via our storage team.  So I have went back to the Integrated Scripting Environment (ISE) to resolved my issues.

$Cluster = "Cluster name here"
#This Line gets all of the LUNs that are connected to the first host in the cluster.
Continue reading

PowerCli to get list of unused RDMs on VM Cluster

This page has been updated. Please visit http://notesofascripter.com/?p=23 for the updated script.

Since my last post was about RDMs, lets continue the discusion.  In my work environment we have been consolidating our VMware platform.
So we have been moving VMs with RDMs attached from one cluster to another.  So its been a messy process, and we haven’t had the time to
clean up behind ourselves. … Continue reading