• RSS
  • Twitter
  • FaceBook

Virtualization Forums

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

POWERCLI get a total memory

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [VMware Virtualization] >> General >> POWERCLI get a total memory Page: [1]
Login
Message << Older Topic   Newer Topic >>
POWERCLI get a total memory - 28.Oct.2011 4:33:14 AM   
yassine

 

Posts: 2
Joined: 28.Oct.2011
Status: offline
Hi every body,


I am new on this Forum, and virtualization aspect too,
I would like to run Script to get informations from vCenter: name of VM, on wich vmHost, CPU information and the total memory


thanks for helps
Post #: 1
RE: POWERCLI get a total memory - 29.Oct.2011 1:07:52 PM   
atc

 

Posts: 66
Joined: 19.Oct.2011
Status: offline
If I am not mistaken, scripts are run against host and not vCenter.

This site has good resource on scripts:

http://www.virtuallyghetto.com

(in reply to yassine)
Post #: 2
RE: POWERCLI get a total memory - 2.Nov.2011 11:14:25 AM   
yassine

 

Posts: 2
Joined: 28.Oct.2011
Status: offline
thanks for Help
I Found another Script
I hope that the script will help every body



# VARIABLES
$outputFile = ''
$VCServer = "localhost" # Virtual Center Server
C:\"Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
Add-PSSnapin VMware.VimAutomation.Core
# SCRIPT

$Date = get-date
$Datefile = ( get-date ).ToString('yyyy-MM-dd-hhmmss')
$ErrorActionPreference = "SilentlyContinue"
# Variable to change
$CreateCSV= "no"
$GridView = "yes"
$HTML = "yes"
$DisplayHTMLOnScreen = "yes"
$EmailHTML = "yes"
$SendEmail = "yes"
$EmailFrom = "vminfo@tdf.fr"
$EmailTo = ""
$EmailTo2 = ""
$EmailSubject = "VMs settings information"
$EmailSMTP = ""
$FileHTML = New-Item -type file "C:\VM_setup\healthcheck\VMInfo_$datefile.html"
$FileCSV = New-Item -type file "C:\VM_setup\healthcheck\VMInfo_$datefile.csv"

#Add Text to the HTML file
Function Create-HTMLTable
{
param([array]$Array)
$arrHTML = $Array | ConvertTo-Html
$arrHTML[-1] = $arrHTML[-1].ToString().Replace('</body></html>',"")
Return $arrHTML[5..2000]
}

$output = @()
$output += '<html><head></head><body>'
$output +=
'<style>table{border-style:solid;border-width:1px;font-size:8pt;background-color:#CCCC99;width:100%;}th{text-align:left;}td{background-color:#fff;width:20%;border-style:so
lid;border-width:1px;}body{font-family:verdana;font-size:12pt;}h1{font-size:12pt;}h2{font-size:10pt;}</style>'
$output += '<H1>VMware VM information</H1>'
$output += '<H2>Date and time</H2>',$date


$VC = Connect-VIServer $VCServer
$myCol = @() # Prepare output collection
$VMs = Get-VM | Sort Name # Get all VMs (sorted)
$counter = 0 # Initialize counter for progress bar
ForEach ($VM in $VMs) # Loop through VMs
{
$counter++ # Increase counter for progress bar
Write-Progress -Activity "Gathering disk information" -Status "Processing VM $VM" -PercentComplete (100*($counter/$VMs.count)) # Display progress bar
$VMHost = Get-VMHost -VM $VM # Get this VM's host
$VMHostView = $VMHost | Get-View # Get advanced properties of host

#ForEach ($DISK in $VM.HardDisks) # Loop through VM's harddisks
# {

# $myObj = "" | Select-Object NomVM, AddressIP, ClusterIP, TotalMemory, TotalCPU, HostESX,
$myObj = "" | Select-Object NomVM, AddressIP, ClusterIP, TotalCPU, CpuUsageMHZ, TotalMemory, UsageRAM, HostESX # Create output object
$myObj.HostESX = $VMHost.Name # ESX Server Name
$myObj.NomVM = $VM.Name # Virtual Machine Name
$myObj.AddressIP = $vm.Guest.IPAddress[1]
$myObj.ClusterIP = $vm.Guest.IPAddress[2]
# $myObj.TotalMemory = $vm.summary.config.memorysizemb
# $myObj.CapDisk = $VirtualDiskDevice.CapacityInKB*1KB
# $myCol +=$myObj
# }
$vm = Get-View $VM
$myObj.TotalMemory = $vm.summary.config.memorysizemb
$myObj.TotalCPU = $vm.summary.config.numcpu
$myObj.CpuUsageMHZ= $vm.summary.quickStats.OverallCpuUsage
$myObj.UsageRAM = $vm.summary.quickStats.guestMemoryUsage
$myCol +=$myObj
}

#Output
if ($GridView -eq "yes") {
$myCol | Out-GridView }


if ($CreateCSV -eq "yes") {
$myCol | Export-Csv $FileCSV -NoTypeInformation }

if ($HTML -eq "yes") {
$output += '<p>'
$output += '<H2>VMware VM information</H2>'
$output += '<p>'
$output += Create-HTMLTable $myCol
$output += '</p>'
$output += '</body></html>'
$output | Out-File $FileHTML }

if ($DisplayHTMLOnScreen -eq "yes") {
ii $FileHTML}

if ($SendEmail -eq "yes") {
Send-MailMessage –From $EmailFrom –To $EmailTo –Subject $EmailSubject –SmtpServer $EmailSMTP -Attachments $FileHTML }

#$myCol | Export-Csv $outputFile -NoTypeInformation # Export output to csv
#Invoke-Item $outputFile # Launch outout file

(in reply to atc)
Post #: 3

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [VMware Virtualization] >> General >> POWERCLI get a total memory Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



Receive all the latest articles by email!

Receive Real-Time & Monthly VirtualizationAdmin.com article updates in your mailbox. Enter your email below!

Become a VirtualizationAdmin.com member!

Discuss all your Virtualization issues with thousands of other experts. Click here to join!