In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
[CmdletBinding ()]
Param (
[Parameter (Mandatory=$true,HelpMessage='VMM Server Name')]
[Alias ('VMMServer')]
[String] $VMMServerName
[Parameter (HelpMessage='VMM HostGroupName')] [Alias ('GroupName')] [String] $HostGroupName
)
Try {
Connect to VMM ServerWrite-Verbose "Connecting to VMM server..." New-CimSession-ComputerName $VMMServerName-ErrorAction Stop | Out-Null} Catch {Write-Error "Cannot connect to VMMServer: $($Error [0] .E xception.Message) Exiting" Exit} Variables
$filedate = Get-date
$FromEmail = "VMMReport@domain.net"
$ToEmail1 = "ITAdmin@domain.net"
$ToEmail2 = "ITOperator@domain.net"
$tableColor = "WhiteSmoke"
$DiskSpaceUsed = $null
Establish Connection to SMTP server
$smtpServer = "smtp.mail.net"
$smtpCreds = new-object Net.NetworkCredential ("username", "password")
$smtp = new-object Net.Mail.SmtpClient ($smtpServer)
$smtp.UseDefaultCredentials = $false
$smtp.Credentials = $smtpCreds
HTML Style Definition
$report = ""
$report = ""
$report = ""
$report = $report + "TABLE {border-width:2px;border-style: solid;border-color: # C0C0C0; border-collapse: collapse;width: 100%}"
$report = $report + "TH {border-width: 2pxscape padding: 0pxposition bordercopyright style: solid;border-color: # C0C0C0; text-align: left}"
$report = $report + "TD {border-width: 2pxscape padding: 0pxposition bordercopyright style: solid;border-color: # C0C0C0; text-align: left}"
$report = $report + "TD {border-width: 2pxscape padding: 0pxposition bordercopyright style: solid;border-color: # C0C0C0; text-align: left}"
$report = $report + "H1 {font-family:Calibri;}"
$report = $report + "H2 {font-family:Calibri;}"
$report = $report + "Body {font-family:Calibri;}"
$report = $report + ""
$report + = "Get-SCVMVirtualDisk-ScriptVersion: 4.0 | Created By: Charbel Nemnom-CDM MVP | Feedback: https://charbelnemnom.com
"
Report Header
$report = $report + "Virtual Machines and Virtual Hard Disks Report on: $($VMMServerName)"
If ($HostGroupName)
{
Report Title$report = $report + "Data for VMM HostGroup: $($HostGroupName): $($filedate)" Write-Verbose "Get VMM Host Group..." $hostGroups = Get-SCVMHostGroup-Name $HostGroupName-VMMServer $VMMServerNameIf (! $hostGroups) {Write-Error "VMM HostGroup named $($HostGroupName) does not exist... Exiting!" Exit} $hostGroups = $hostGroups.AllChildHostsForeach ($hostGroup in $hostGroups) {$SCVMs + = @ (Get-SCVirtualMachine-VMMServer $VMMServerName-VMHost $HostGroup.Name)}
}
Else
{
$SCVMs + = @ (Get-SCVirtualMachine-VMMServer $VMMServerName)
}
Write-Verbose "Generating Report"
Foreach ($SCVM in $SCVMs)
{
$DiskUsed = $null
Write-Verbose "Checking VM: $SCVM Virtual Hard Disks on $($SCVM.HostName)"
$SCVHDs = Get-SCVirtualMachine $SCVM.Name-VMHost $SCVM.HostName | Get-SCVirtualHardDisk | Select-Object Size
Foreach ($SCVHD in $SCVHDs) {
$DiskUsed + = $SCVHD.Size
}
$DiskSpaceUsed + = $DiskUsed
$report = $report + "TH {background-color:Indigo} TR {background-color:$ ($tableColor)}"
$report = $report + (Get-SCVirtualMachine $SCVM.Name | Select-Object @ {Label= "Host Name"; Expression= {$.VMHost}}, @ {Label= "VM Name"; Expression= {$.Name}}, @ {Label= "ComputerName"; Expression= {$.ComputerName}}, @ {Label= "VM Generation"; Expression= {$.Generation}} | ConvertTo-HTML-as Table-Fragment)
$report = $report + "TH {background-color:Blue} TR {background-color:$ ($tableColor)}"
$report = $report + (Get-SCVirtualMachine $SCVM.Name | Get-SCVirtualDiskDrive | Select-Object @ {Label= "VHD Name"; Expression= {$.VirtualHardDisk}}, @ {Label= "Controller Type"; Expression= {$.BusType}}, Lun | ConvertTo-HTML-as Table-Fragment)
$report = $report + "TH {background-color:DarkGreen} TR {background-color:$ ($tableColor)}"
$report = $report + (Get-SCVirtualMachine $SCVM.Name | Get-SCVirtualHardDisk | Select-Object @ {Label= "VHDType"; Expression= {$.VHDType}}, @ {Label= "VHD Location"; Expression= {$.location}}, @ {Label= "Max Disk Size (GB)"; Expression= {($_ .MaximumSize / 1GB)}}, @ {Label= "Disk Space Used (GB)"; Expression= {"0:N2}"-f ($_ .Size / 1GB)}
@ {Label= "Disk Space Used (%)"; Expression= {[math]:: Round (($.size / 1GB) / ($.MaximumSize / 1GB)) * 100)}}, `
@ {Label= "Free Disk Space (GB)"; Expression= {"{0:N2}"-f (($.MaximumSize / 1GB)-($.size / 1GB))}} | ConvertTo-HTML-as Table-Fragment)
$report = $report + "Total Disk Space Used for VM: $($SCVM.Name) in (GB) is $({{0:N2}}-f ($DiskUsed/1GB))" + "
"
$report = $report + "
"
}
Write-Verbose "Calculating Total Disk Space Used for All Virtual Machines..."
$report = $report + "Total DiskSpaceUsed for All VMs in (GB) is $({{0:N2}}-f ($DiskSpaceUsed/1GB))"
Finalizing Report
Write-Verbose "Finalizing Report"
$report = $report + ""
Send Email
Write-Verbose "Sending Report"
$email = new-object Net.Mail.MailMessage
$email.Priority = [System.Net.Mail.MailPriority]:: High
$email.Subject = "Virtual Machines and Virtual Hard Disks Report: $($filedate)"
$email.From = new-object Net.Mail.MailAddress ($FromEmail)
$email.IsBodyHtml = $true
$email.Body = $report
$email.To.Add ($ToEmail1)
$email.To.Add ($ToEmail2)
$smtp.Send ($email)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.