<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automating VMware ESX snapshot notification</title>
	<atom:link href="http://blogs.kraftkennedy.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.kraftkennedy.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/</link>
	<description>Trends and insight into legal technology, infrastructure and strategic thinking.</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:59:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: John Jore</title>
		<link>http://blogs.kraftkennedy.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/comment-page-1/#comment-72</link>
		<dc:creator>John Jore</dc:creator>
		<pubDate>Sun, 11 Oct 2009 16:46:59 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.research.kkl.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/#comment-72</guid>
		<description>Nice script. For Exchange 2007 / Outlook 2007 I needed to add two lines for the formatting to take effect:

$head = $head + &quot;&lt;style&gt;&quot;

at the beginning of the header and 

$head = $head + &quot;&lt;style&gt;&quot; at the end


JJ</description>
		<content:encoded><![CDATA[<p>Nice script. For Exchange 2007 / Outlook 2007 I needed to add two lines for the formatting to take effect:</p>
<p>$head = $head + &#8220;&lt;style&gt;&#8221;</p>
<p>at the beginning of the header and </p>
<p>$head = $head + &#8220;&lt;style&gt;&#8221; at the end</p>
<p>JJ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Evans</title>
		<link>http://blogs.kraftkennedy.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/comment-page-1/#comment-64</link>
		<dc:creator>Matthew Evans</dc:creator>
		<pubDate>Wed, 23 Sep 2009 16:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.research.kkl.com/index.php/2009/05/06/automating-vmware-esx-snapshot-notification/#comment-64</guid>
		<description>It is also possible to use the script without having to put the credentials in clear text.  Just make sure the scheduled task runs as someone who has rights in vCenter.

#############################################################################
# List all VM with snapshots						
# 									
# Created by Anders Mikkelsen, 2008					
# Updated by Anders Mikkelsen, 2009					
# www.amikkelsen.com
#
# Thanks to:
# Ryan	for updating the snapshot list (January 2009)
# John Daily 	for adding mail functionality (March 2009)		
#############################################################################
Add-PSSnapin VMware.VimAutomation.Core

$smtpServer = &quot;SMTPSERVER.DOMAIN.COM&quot; 
$strFrom = &quot;SenderUser@DOMAIN.COM&quot;
$strTo = &quot;RecipientUser@DOMAIN.COM&quot;
$VCServer = &quot;VIRTUALCENTERSERVER.DOMAIN.COM&quot;

Connect-VIServer $VCServer

# Output File
$strOutFile = &quot;C:\Windows\Temp\snapshot_list.htm&quot;

# HTML/CSS style for the output file
$head = &quot;&lt;style&gt;&quot;
$head = $head + &quot;BODY{background-color:white;}&quot;
$head = $head + &quot;TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}&quot;
$head = $head + &quot;TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFD700}&quot;
$head = $head + &quot;TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFFFF}&quot;
$head = $head + &quot;&lt;/style&gt;&quot;

# SMTP info
$strDate = get-date -DisplayHint date
$strSubject = “List of current VMware Snapshots - ” + $strDate
$strBody = &quot;Attached is the list of Snapshots&quot;
$strMail = &quot;&quot; + $strSubject + &quot;&quot;

# Get the list of VM&#039;s
$vms = Get-VM

# -------------- Logic -----------------------------
$myCol = @()
ForEach ($vm in $vms){
	$snapshots = Get-SnapShot -VM $vm
	if ($snapshots.Name.Length -ige 1 -or $snapshots.length){
		ForEach ($snapshot in $snapshots){
			$myObj = &quot;&quot; &#124; Select-Object VM, Snapshot, Created, Description
			$myObj.VM = $vm.name
			$myObj.Snapshot = $snapshot.name
			$myObj.Created = $snapshot.created
			$myObj.Description = $snapshot.description
			$myCol += $myObj
		}
	}
}

# Write the output to an HTML file
 $myCol &#124; Sort-Object VM &#124; ConvertTo-HTML -Head $head -Body $strMail &#124; Out-File $strOutFile

# Mail the output file
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($strOutFile)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = $strFrom
$msg.To.Add($strTo)
$msg.Subject = $strSubject
$msg.IsBodyHtml = 1
$msg.Body = Get-Content $strOutFile
$msg.Attachments.Add($att)
$smtp.Send($msg)</description>
		<content:encoded><![CDATA[<p>It is also possible to use the script without having to put the credentials in clear text.  Just make sure the scheduled task runs as someone who has rights in vCenter.</p>
<p>#############################################################################<br />
# List all VM with snapshots<br />
#<br />
# Created by Anders Mikkelsen, 2008<br />
# Updated by Anders Mikkelsen, 2009<br />
# <a href="http://www.amikkelsen.com" rel="nofollow">http://www.amikkelsen.com</a><br />
#<br />
# Thanks to:<br />
# Ryan	for updating the snapshot list (January 2009)<br />
# John Daily 	for adding mail functionality (March 2009)<br />
#############################################################################<br />
Add-PSSnapin VMware.VimAutomation.Core</p>
<p>$smtpServer = &#8220;SMTPSERVER.DOMAIN.COM&#8221;<br />
$strFrom = &#8220;SenderUser@DOMAIN.COM&#8221;<br />
$strTo = &#8220;RecipientUser@DOMAIN.COM&#8221;<br />
$VCServer = &#8220;VIRTUALCENTERSERVER.DOMAIN.COM&#8221;</p>
<p>Connect-VIServer $VCServer</p>
<p># Output File<br />
$strOutFile = &#8220;C:\Windows\Temp\snapshot_list.htm&#8221;</p>
<p># HTML/CSS style for the output file<br />
$head = &#8220;&lt;style&gt;&#8221;<br />
$head = $head + &#8220;BODY{background-color:white;}&#8221;<br />
$head = $head + &#8220;TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}&#8221;<br />
$head = $head + &#8220;TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFD700}&#8221;<br />
$head = $head + &#8220;TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFFFF}&#8221;<br />
$head = $head + &#8220;&lt;/style&gt;&#8221;</p>
<p># SMTP info<br />
$strDate = get-date -DisplayHint date<br />
$strSubject = “List of current VMware Snapshots &#8211; ” + $strDate<br />
$strBody = &#8220;Attached is the list of Snapshots&#8221;<br />
$strMail = &#8220;&#8221; + $strSubject + &#8220;&#8221;</p>
<p># Get the list of VM&#8217;s<br />
$vms = Get-VM</p>
<p># &#8212;&#8212;&#8212;&#8212;&#8211; Logic &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
$myCol = @()<br />
ForEach ($vm in $vms){<br />
	$snapshots = Get-SnapShot -VM $vm<br />
	if ($snapshots.Name.Length -ige 1 -or $snapshots.length){<br />
		ForEach ($snapshot in $snapshots){<br />
			$myObj = &#8220;&#8221; | Select-Object VM, Snapshot, Created, Description<br />
			$myObj.VM = $vm.name<br />
			$myObj.Snapshot = $snapshot.name<br />
			$myObj.Created = $snapshot.created<br />
			$myObj.Description = $snapshot.description<br />
			$myCol += $myObj<br />
		}<br />
	}<br />
}</p>
<p># Write the output to an HTML file<br />
 $myCol | Sort-Object VM | ConvertTo-HTML -Head $head -Body $strMail | Out-File $strOutFile</p>
<p># Mail the output file<br />
$msg = new-object Net.Mail.MailMessage<br />
$att = new-object Net.Mail.Attachment($strOutFile)<br />
$smtp = new-object Net.Mail.SmtpClient($smtpServer)<br />
$msg.From = $strFrom<br />
$msg.To.Add($strTo)<br />
$msg.Subject = $strSubject<br />
$msg.IsBodyHtml = 1<br />
$msg.Body = Get-Content $strOutFile<br />
$msg.Attachments.Add($att)<br />
$smtp.Send($msg)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

