Quantcast
Channel: VMware Communities : Blog List - All Communities
Viewing all articles
Browse latest Browse all 3135

PowerCLI - Adding memory to vm

$
0
0

This is a simple way of adding memory to a powered-on vm, which has the Memory hot plug option enabled. It reads the server names from a file (deploy.csv) and updates the memory to what is specified in the script.

  • First the deploy.csv file
name
vmserver01
vmserver02

 

  • Actual script, MemoryMB needs to be updated
#Connect to vcenter server
connect-viserver vcenter.domain.local
#Import vm name and ip from file
Import-Csv deploy.csv |
foreach {    $strNewVMName = $_.name       write-host "Server ----- $strNewVMName"       #MemoryMB needs to change    Set-VM -VM $strNewVMName -MemoryMB 6144    Sleep 2       Get-VM -name $strNewVMName | Select Name, MemoryGB       $Report += $strNewVMName
}
write-host "Sleeping ..." 
Sleep 10
#Send out an email with the names
$emailFrom = "<from email id>"
$emailTo = "<to email id>"
$subject = "List of servers with upgraded memory"
$smtpServer ="<smtp server name>"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject
, $Report)

Viewing all articles
Browse latest Browse all 3135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>