Slackbot
02/08/2023, 4:44 PMChristian Jöns
02/08/2023, 5:20 PMnewbie1998
02/08/2023, 5:52 PMnewbie1998
02/08/2023, 5:52 PMnewbie1998
02/08/2023, 5:57 PMDaniel Madsen
02/08/2023, 6:30 PMRay Davis
02/10/2023, 11:58 AM##Records the Powershell transcript
##Import the VMware module
##Connects to vCenter, you can let it prompt you for username password or you can define it. Example(Connect-VIServer vcenter.lab.local -user Domain\username -password "password")
Start-Transcript -Path "C:\Temp\transcript0.txt" -NoClobber
Import-Module VMware.VimAutomation.Core
Connect-VIServer vcenter.lab.local -user VSPHERE.LOCAL\Administrator -password "password-example"
##Finds the VDI with a name like LABDaaS and exports it to a CSV
##Imports the CSV file
##Does a Loop and shuts down each VM and enables hotadd for memory and CPU. There is a 60 second sleep between each VM. You can change this
##Starts each
$VMsToUpgrade = get-vm |?{$_.Name -like "*LABDaaS*"} | select name | export-csv -Path C:\Temp\VMsToUpgrade.csv
$vmName = (Import-Csv -Path C:\Temp\VMsToUpgrade.csv).Name
ForEach ($vm in $vm_name){
Shutdown-VMGuest -VM $vm_name -Confirm:$False
Sleep 60
Get-VM -Name $vm_name |Set-VM -MemoryGB 12 –NumCpu 2 –Confirm:$False
$vm = Get-VM -Name $vmName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.CpuHotAddEnabled = $true
$spec.MemoryHotAddEnabled = $true
$vm.ExtensionData.ReconfigVM($spec)
Start-VM $vm_name
Stop-Transcript
}