Forum

Bildirimler
Hepsini Temizle

Virtual Host Hyper-V Powershell Inventory

2 Yazılar
2 Üyeler
0 Reactions
1,173 Görüntüleme
(@gokhanceyhan)
Gönderiler: 126
Estimable Member
Konu başlatıcı
 

Merhaba arkadaşlar,

Virtual hosttaki hyper v makinaların listesini powershell komutuyla almak istiyorum.

Sunucu adı - Açık veya Kaplı olduğu - Ram - Cpu - Ip adresi - İşletim sistemi- Disk kapasitesi

bilgilerinin olacağı bir powershell kodu hazırlamam gerekiyor aşağıdaki kodda Sunucu adı - Açık veya Kaplı olduğu - Ram - Cpu bilgileri var ancak diğer bilgiler bulunmuyor Ip adresi - İşletim sistemi- Disk kapasitesi eklenmesi konusunda yardımcı olabilirseniz çok sevinirim.

###############################################
# Get-VMResourceSummary.ps1
# a script to display RAM and CPU usage by
# Hyper-V VMs on a single host
#
# Adjust $Hostname to query remote host
# otherwise use as it is to query local host
#
# Run without parameters as an Admin
#
# by Nils Kaczenski, www.michael-wessel.de
# no warranty, use at your own risk
###############################################

# enter host name here or leave it as it is for localhost
$Hostname = $env:COMPUTERNAME

$VMs = (Get-VM -ComputerName $Hostname)

"Host name: $Hostname"
'Number of VMs: ' + ($VMs.Count)
''
$colVMs = @()
foreach ($VM in $VMs)
{
$objVM = New-Object System.Object
$objVM | Add-Member -MemberType NoteProperty -Name VMName -Value $VM.VMName
$objVM | Add-Member -MemberType NoteProperty -Name VMState -Value $VM.State
$objVM | Add-Member -MemberType NoteProperty -Name VMDynamicMemoryEnabled -Value $VM.DynamicMemoryEnabled
$objVM | Add-Member -MemberType NoteProperty -Name VMStaticRAM -Value $VM.MemoryStartup
if ($vm.DynamicMemoryEnabled) {
$objVM | Add-Member -MemberType NoteProperty -Name VMDynamicMemoryMax -Value $VM.MemoryMaximum
} else {
$objVM | Add-Member -MemberType NoteProperty -Name VMDynamicMemoryMax -Value 0
}
$objVM | Add-Member -MemberType NoteProperty -Name VMCPUCount -Value ([int]$VM.ProcessorCount)

$colVMs += $objVM
}

# display all VMs and their values, nicely formatted
$a = @{Expression={$_.VMName};Label='VM Name'}, `
@{Expression={$_.VMState};Label='State'}, `
@{Expression={$_.VMDynamicMemoryEnabled};Label='DynMem enabled'}, `
@{Expression={('{0:N1}' -f($_.VMStaticRAM/1GB))};Label='Static/startup RAM (GB)';align='right'}, `
@{Expression={('{0:N1}' -f([Double]$_.VMDynamicMemoryMax/1GB))};Label='Dynamic Mem max (GB)';align='right'}, `
@{Expression={$_.VMCPUCount};Label='vCPU count';align='right'}

$colVMs | Sort-Object VMName | Format-Table $a -AutoSize

# display sums, max/min, and averages
$b = @{Expression={$_.Property};Label='Property'}, `
@{Expression={$_.Count};Label='Count'}, `
@{Expression={('{0:N1}' -f($_.Sum/1GB))};Label='Sum';align='right'}, `
@{Expression={('{0:N1}' -f($_.Minimum/1GB))};Label='Minimum';align='right'}, `
@{Expression={('{0:N1}' -f($_.Maximum/1GB))};Label='Maximum';align='right'}, `
@{Expression={('{0:N1}' -f($_.Average/1GB))};Label='Average';align='right'}

'All VMs'
'======='
$colVMs | Measure-Object VMStaticRAM,VMDynamicMemoryMax -Minimum -Maximum -Sum -Average | Format-Table $b -AutoSize
$colVMs | Measure-Object VMCPUCount -Minimum -Maximum -Sum -Average | Format-Table Property,Count,Sum,Minimum,Maximum,Average -AutoSize

'Running VMs'
'==========='
$colVMs | Where-Object {$_.VMState -eq 'Running'} | Measure-Object VMStaticRAM,VMDynamicMemoryMax -Minimum -Maximum -Sum -Average | Format-Table $b -AutoSize
$colVMs | Where-Object {$_.VMState -eq 'Running'} | Measure-Object VMCPUCount -Minimum -Maximum -Sum -Average | Format-Table Property,Count,Sum,Minimum,Maximum,Average -AutoSize

# add host hardware values
$HostHW = Get-WmiObject Win32_ComputerSystem -ComputerName $Hostname
"Host $Hostname total RAM: " + ('{0:N0}' -f($hostHW.TotalPhysicalMemory / 1GB) + ' GB')
"Host $Hostname Logical Processors: " + $HostHW.NumberOfLogicalProcessors

 
Gönderildi : 27/04/2020 15:37

(@turancoskun)
Gönderiler: 4100
Üye
 

Merhaba,

Talep ettiklerinize biraz araştırma yaparak ulaşmak mümkün.

Referans adresleri inceleyebilirsiniz.

https://gallery.technet.microsoft.com/Hyper-V-Reporting-Script-4adaf5d0

https://gallery.technet.microsoft.com/Get-HyperVInventory-Create-2c368c50

https://www.gngrninja.com/script-ninja/2016/1/15/get-vmware-guest-list-with-powercli

****************************************************************
Probleminiz Çözüldüğünde Sonucu Burada Paylaşırsanız.
Sizde Aynı Problemi Yaşayanlar İçin Yardım Etmiş Olursunuz.
Eğer sorununuz çözüldü ise lütfen "çözüldü" olarak işaretlerseniz diğer üyeler için çok büyük kolaylık sağlayacaktır.
*****************************************************************

 
Gönderildi : 27/04/2020 16:03

Paylaş: