ITguy565
asked on
Powershell WMI scripting help
Hyper-V PowerShell Scripting Issue
I need to Modify my script to compensate for the following : Total Memory of All Hyper-V Hosts (*combined Total*)
I need to Add a calculation for Node Loss to this script:
I am open to suggestions on this, however a base calculation would be *Total Memory Pooled* / 256GB
As the Avg of my Hosts have 256 GB RAM.
I need to Modify my script to compensate for the following : Total Memory of All Hyper-V Hosts (*combined Total*)
I need to Add a calculation for Node Loss to this script:
I am open to suggestions on this, however a base calculation would be *Total Memory Pooled* / 256GB
As the Avg of my Hosts have 256 GB RAM.
#Total Count of Physical CPU Cores
#Total Count of In use CPU Cores
#Total COunt of Available CPU Cores
$cred = Get-Credential
$serverList = Get-ADComputer -Filter "Name -like '*SERVER*'" | Select-Object -ExpandProperty Name
#Get Hyper-V Fail-Over Information
$HyperVFailoverInfo = Invoke-Command -ComputerName $serverList -Credential $cred -ScriptBlock {
$vmhost = Get-CimInstance -computername $serverList -ClassName Win32_OperatingSystem -ErrorAction Stop
$win32ProcessorList = Get-WmiObject -Class Win32_Processor
$vMList = Get-VM
$freePhysicalMemory = [Math]::Round(($vmhost.FreePhysicalMemory / 1MB), 2)
$totalPhysicalMemory = [Math]::Round(((Get-WMIObject -Class Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1gb), 2)
$totalInUseMemory = [Math]::Round(($TotalPhysicalMemory - $FreePhysicalMemory), 2)
$TotalCPUCoresInUseRM = ($vMList | Where-Object {$_.State -eq 'Running'} | Get-VMProcessor | Measure-Object -Property Count -Sum).Sum
$TotalCPUCoresInUse = ($vMList | Where-Object {$_.State -eq 'Running'} | Get-VMProcessor | Measure-Object -Property Count -Sum).Sum
$logicalCpuCount = ($win32ProcessorList | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
$totalCPUCoresInUse = (Get-VM | Measure-Object -Property Count -Sum).Sum
$TotalPooledMemory = $null
$TotalNodeLoss = $null
#$TotalPooledMemory = () # Total Memory of All Hyper-V Hosts (Combined)
#$TotalNodeLoss = Total Pooled Memory / 256GB
'' | Select-Object -Property `
@{n = 'Computername'; e = {$ENV:ComputerName}},
@{n = 'Free Physical Memory GB'; e = {$FreePhysicalMemory}},
@{n = 'In Use Physical Memory GB'; e = {$totalInUseMemory}},
@{n = 'Total Physical Memory GB'; e = {$TotalPhysicalMemory}},
@{n = 'Total Node Loss'; e = {$TotalNodeLoss}},
@{n = 'TotalPooledMemory'; e = {$TotalPooledMemory}},
@{n = 'Total Processors'; e = {$logicalCpuCount}},
@{n = 'TotalVirtualCPUsInUse (running Machines)'; e = {$TotalCPUCoresInUseRM}},
@{n = 'TotalVirtualCPUsInUse (All Allocated including Stopped)'; e = {$TotalCPUCoresInUs}},
@{n = 'Total Processors Available'; e = {$logicalCpuCount - $totalCPUCoresInUse}}
} |
Select-Object -Property * -ExcludeProperty PSComputerName, RunspaceId |
Sort-Object -Property ComputerName, VMName
write-host "Exported Hyper-V Failover Information to c:\Temp\"
$HyperVFailoverInfo | Export-Csv -NoTypeInformation -Path $HyperVFailoverFileName
$HyperVFailoverInfo | Out-GridView
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
glad to help :)