Some Quick One-Liners to help with Day to Day changes. Copy and Adapt as needed.
Quick Notes***
Ram and HardDisk Capacity numbers are in GB. The bottom code to increase a VMs existing HardDisk has a WMI call to get the Drive letters (For Windows VMs). This will help match Hard Disk to Drive letter before you issue the last command to expand it.
####### Edit your VM name here #######
$theVM = get-vm “MySuperCoolVM”
######Increase vCPU#######
$thevm | set-vm -numcpu “3” -confirm:$false
#######Increase RAM#######
$thevm | set-vm -memoryGB “8” -confirm:$false
#######Rename to old_X and move to old folder
$thevm | set-vm -name (“old_”+($thevm.name)) -confirm:$false
$thevm | move-vm -destination (get-folder “old”)
#######add new Drive to VM#######
$thevm |new-harddisk -capacityGB “50”
#######increase drive on VM#######
$thevm | get-harddisk | select name,capacityGB,filename
$report = @()
$temp = get-WmiObject win32_logicaldisk -Computername ($thevm.name)
foreach($b in ($temp | where {$_.drivetype -eq “3”})){
$reportrow = “” | select VMname, DriveLetter, VolumeName,CapacityGB, FreespaceGB,percentFree
$reportrow.vmname = $thevm.name
$reportrow.driveletter = $b.DeviceID
$reportrow.VolumeName = $b.VolumeName
$reportrow.capacityGB = “{0:N3}” -f ($b.Size / 1073741824)
$reportrow.freespaceGB = “{0:N3}” -f ($b.FreeSpace / 1073741824)
$reportrow.percentfree = [System.Math]::floor(($b.FreeSpace / $b.Size)*100)
$report += $reportrow
}
$report | ft
$thevm | get-harddisk | where {$_.name -eq “Hard disk 3”} | set-harddisk -capacityGB “50” -confirm:$false