中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

獲取在SCVMM虛擬機磁盤信息-創新互聯

<#
//-----------------------------------------------------------------------

10年積累的成都網站建設、做網站經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先做網站設計后付款的網站建設流程,更有襄陽免費網站建設讓你可以放心的選擇與我們合作。

// Copyright (c) {charbelnemnom.com}. All rights reserved.

//-----------------------------------------------------------------------

.SYNOPSIS
Get the list of all Virtual Machines in SCVMM including their disks.

.DESCRIPTION
Get the list of all Virtual Machines in Virtual Machine Manager and enumerate all their drives.

.NOTES
File Name : Get-SCVMVirtualDisk.ps1
Author : Charbel Nemnom
Version : 4.0
Date : 05-February-2018
Requires : PowerShell Version 3.0 or above
OS : Windows Server 2012 R2 or 2016
Product : System Center Virtual Machine Manager 2012 R2 or 2016

.LINK
To provide feedback or for further assistance please visit:
https://charbelnemnom.com

.EXAMPLE
./Get-SCVMVirtualDisk -VMMServerName <VMMServerName>
This example will get all Virtual Machines including their Virtual Disks from VMM <VMMServerName>,
Then calculate the size and percentage used by each VM/VHD(X), total disk size of all VMs and send the report via e-mail.

.EXAMPLE
./Get-SCVMVirtualDisk -VMMServerName <VMMServerName> -HostGroupName <HostGroupName>
This example will get all Virtual Machines including their Virtual Disks from a particular VMM Host Group <HostGroupName>,
Then calculate the size and percentage used by each VM/VHD(X), total disk size of all VMs and send the report via e-mail.
#>

[CmdletBinding()]
param(
[Parameter(Mandatory=$true,HelpMessage='VMM Server Name')]
[Alias('VMMServer')]
[String]$VMMServerName,

[Parameter(HelpMessage='VMM Host Group Name')]
[Alias('GroupName')]
[String]$HostGroupName

)

Try {

Connect to VMM Server

Write-Verbose "Connecting to VMM server..."
New-CimSession -ComputerName $VMMServerName -ErrorAction Stop | Out-Null
}
Catch {
Write-Error "Cannot connect to VMM Server: $($Error[0].Exception.Message) Exiting"
Exit
}

Variables

$filedate = Get-date
$FromEmail = "[email protected]"
$ToEmail1 = "[email protected]"
$ToEmail2 = "[email protected]"
$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 = "<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">"
$report = "<html xmlns="http://www.w3.org/1999/xhtml"><body>"
$report = "<style>"
$report = $report + "TABLE{border-width:2px;border-style: solid;border-color: #C0C0C0 ;border-collapse: collapse;width: 100%}"
$report = $report + "TH{border-width: 2px;padding: 0px;border-style: solid;border-color: #C0C0C0 ;text-align: left}"
$report = $report + "TD{border-width: 2px;padding: 0px;border-style: solid;border-color: #C0C0C0 ;text-align: left}"
$report = $report + "TD{border-width: 2px;padding: 0px;border-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 + "</style>"
$report += "<center><p style=""font-size:12px;color:#BDBDBD"">Get-SCVMVirtualDisk - ScriptVersion: 4.0 | Created By: Charbel Nemnom - CDM MVP | Feedback: https://charbelnemnom.com</p></center>"

Report Header

$report = $report + "<h2>Virtual Machines and Virtual Hard Disks Report on: $($VMMServerName)</h2>"

If ($HostGroupName)
{

Report Title

$report = $report + "<h3>Data for VMM Host Group: $($HostGroupName) : $($filedate)</h3>"
Write-Verbose "Get VMM Host Group..."
$hostGroups = Get-SCVMHostGroup -Name $HostGroupName -VMMServer $VMMServerName
If (!$hostGroups) {
   write-Error "VMM Host Group named $($HostGroupName) does not exist... Exiting!"
    Exit }
$hostGroups =  $hostGroups.AllChildHosts
Foreach ($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 + "<style>TH{background-color:Indigo}TR{background-color:$($tableColor)}</style>"
$report = $report + (Get-SCVirtualMachine $SCVM.Name | Select-Object @{Label="Host Name";Expression={$.VMHost}},@{Label="VM Name";Expression={$.Name}},@{Label="Computer Name";Expression={$.ComputerName}},@{Label="VM Generation";Expression={$.Generation}} | ConvertTo-HTML -as Table -Fragment)
$report = $report + "<style>TH{background-color:Blue}TR{background-color:$($tableColor)}</style>"
$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 + "<style>TH{background-color:DarkGreen}TR{background-color:$($tableColor)}</style>"
$report = $report + (Get-SCVirtualMachine $SCVM.Name | Get-SCVirtualHardDisk | Select-Object @{Label="VHD Type";Expression={$.VHDType}},@{Label="VHD Location";Expression={$.Location}}, <br/>@{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 + "<B>Total Disk Space Used for VM: $($SCVM.Name) in (GB) is $({{0:N2}} -f ($DiskUsed/1GB))</B>" + " <br>"
$report = $report + " <br>"
}

Write-Verbose "Calculating Total Disk Space Used for All Virtual Machines..."
$report = $report + "<h5><B>Total Disk Space Used for All VMs in (GB) is $({{0:N2}} -f ($DiskSpaceUsed/1GB))</B></h5>"

Finalizing Report

Write-Verbose "Finalizing Report"
$report = $report + "</body></html>"

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)

另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章標題:獲取在SCVMM虛擬機磁盤信息-創新互聯
網址分享:http://m.2m8n56k.cn/article0/dgsiio.html

成都網站建設公司_創新互聯,為您提供域名注冊、定制開發、網站制作手機網站建設、網站維護、App設計

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名
主站蜘蛛池模板: 成人免费一区二区三区在线观看 | 日韩一区二区三区四区不卡 | 国产成人91 | 曰韩毛片 | 成人小视频在线观看免费 | 欧美精品亚洲 | 久久久久一区二区三区 | 国产日韩视频在线观看 | 亚洲人成网址在线播放a | 日本一级~片免费永久 | 女人张开腿让男人捅爽 | 91精品国产免费久久久久久青草 | 青草福利在线 | 精品国产呦系列在线看 | 国产99视频精品草莓免视看 | 欧美a欧美 | 国产v日韩v欧美v精品专区 | 亚洲成人偷拍 | 亚洲综合网在线观看 | 亚洲精品视频久久久 | 国产精品国产高清国产专区 | 一级毛片免费看 | yellow中文字幕久久网 | 成人无遮挡毛片免费看 | 国产成人福利视频在线观看 | 综合久久久久久中文字幕 | 国产黄a三级三级三级 | 免费人成黄页网站在线观看 | 小明台湾成人永久免费看看 | 亚洲日本激情 | 国产欧美日韩高清专区手机版 | 国产精品亚洲高清一区二区 | 久久精品成人国产午夜 | 日韩一级不卡 | 精产网红自拍在线 | 亚洲精品成人久久 | 亚洲视频精品在线观看 | 偷拍自拍第一页 | 91色综合综合热五月激情 | 久久久久毛片免费观看 | 国产精品二区高清在线 |