Tuesday, October 19, 2021

Snapshot report using PowerCLI script

 Snapshot report using PowerCLI script


#### HTML Output Formatting #######

$a = "<style>"

$a = $a + "BODY{font-family:Calibri;font-size:12pt;}"

$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse; padding-right:5px}"

$a = $a + "TH{border-width: 1px;padding: 5px;border-style: solid;border-color: black;color:black;background-color:#FFFFFF }"

$a = $a + "TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:Silver}"

$a = $a + "</style>"


Connect-VIServer vcenterserver

Remove-Item D:\temp\SnapshotReport.html

$CurrentDate = Get-Date

$CurrentDate = $CurrentDate.ToString('dd-MMM-yyyy')

$HeadLines = "<BR><i>Snapshot Report - $CurrentDate </i>"


$post = "<BR><i>Snapshots older than 10 Days as of $CurrentDate </i>"

Get-VM | ?{$_.PowerState -eq "PoweredOn"} | Get-Snapshot | Where-Object {$_.Created -lt (Get-Date).AddDays(-10)} | Select-Object VM, Description, Created, @{Label=”Age”;Expression={(New-TimeSpan -Start $_.Created -End (Get-Date)).Days}}, @{Label=”SizeGB”;Expression={“{0:N2} GB” -f ($_.SizeGB)}} | Sort-Object "Age" -Descending | ConvertTo-html -Head $a -PreContent $post -Body "<H2> </H2>" >> D:\temp\SnapshotReport.html


$body = [System.IO.File]::ReadAllText('D:\temp\SnapshotReport.html')

Send-MailMessage -To To@Mailaddress.com -From From@Mailaddress.com -Subject "Snapshot Report - $CurrentDate" -Body $body -SmtpServer smtp.Mailaddress.com -BodyAsHtml

Disconnect-VIServer vcenterserver -Confirm:$False

1 comment:

  1. What is even more attention-grabbing is that most all} playing venues in Korea have a prohibition for Koreans and are solely open for foreigners. Moreover, firms usually are not allowed to offer playing actions to Koreans even on-line. The solely way to gamble that is not restricted for residents of South Korea is to play at on-line casinos that are not regulated underneath the jurisdiction of the country. Players can get pleasure from their gaming expertise and wager their cash till the particular on-line casino just isn't blocked by the government. Those who really wish to gamble at on-line casinos have their choice of the most important and most reputable on-line playing operators to select from. Established in 2014, BK8 슬롯커뮤니티 is arguably the leading operator for on-line playing in Asia.

    ReplyDelete