<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>danejeffrey.com &#187; powershell</title>
	<atom:link href="http://danejeffrey.com/blog/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://danejeffrey.com/blog</link>
	<description>Good ways to break things.</description>
	<lastBuildDate>Wed, 05 Oct 2011 00:13:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State</title>
		<link>http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/</link>
		<comments>http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 05:44:31 +0000</pubDate>
		<dc:creator>danejeff</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://danejeffrey.com/blog/?p=504</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/' addthis:title='VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The following will get CPU (num of cores) counts from hosts and will also get vCPU counts from VM&#8217;s. It will also get the operating system of each VM, its power state and the average CPU for the past week. The end of each section also has a count of the number of objects (hosts [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/' addthis:title='VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/' addthis:title='VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The following will get CPU (num of cores) counts from hosts and will also get vCPU counts from VM&#8217;s. It will also get the operating system of each VM, its power state and the average CPU for the past week. The end of each section also has a count of the number of objects (hosts and VMs) in the environment.</p>
<pre class="brush:vb">Connect-VIServer &lt;Your_vCenter_Server&gt;
# define start and finish days (1 week period)
$startdate=(get-date).addDays(-7)
$finishdate=(get-date).addDays(-1)
# initialise counters
$vmcount=0
$hostcount=0

ForEach ($esxhost in (Get-VMHost | Sort Name)){
	Write-Host $esxhost.Name","$esxhost.NumCPU
    $hostcount++
}
Write-Host "Total Hosts:" $hostcount

ForEach ($vm in (Get-VM | Sort Name)){
    If ($vm.PowerState -eq 'PoweredOn'){
        $vstats = (Get-Stat -entity $vm -stat cpu.usage.average -Start $startdate -Finish $finishdate | measure-object -property value -average)
        # round to two decimal places
        $vavg = [system.math]::round($vstats.average,2)
    }Else{
        $vavg = 0
    }
	Write-Host $vm.Name","$vm.Guest.OSFullName","$vm.PowerState","$vm.NumCPU","$vavg
    $vmcount++
}

Write-Host "Total VM's:" $vmcount</pre>
<img src="http://danejeffrey.com/blog/?ak_action=api_record_view&id=504&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/' addthis:title='VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://danejeffrey.com/blog/2011/01/25/vmware-powercli-for-host-and-guest-cpu-details-includes-os-and-power-state/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows PowerShell Send Email</title>
		<link>http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/</link>
		<comments>http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 01:16:11 +0000</pubDate>
		<dc:creator>danejeff</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://danejeffrey.com/blog/?p=337</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/' addthis:title='Windows PowerShell Send Email '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>This is posted in heaps of places online (this post is pretty useful &#8211; includes details on message format and attachments), so mainly for my own reference: $emailFrom = "someone@domain.com" $emailTo = "someone_else@domain.com" $subject = "Subject" $body = "Some text" $smtpServer = "mail-server.domain.com" $smtp = new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($emailFrom, $emailTo, $subject, $body)<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/' addthis:title='Windows PowerShell Send Email ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/' addthis:title='Windows PowerShell Send Email '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>This is posted in heaps of places online (this <a href="http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/5f7a9d63-6a37-4d98-b710-d76fde920a37">post</a> is pretty useful &#8211; includes details on message format and attachments), so mainly for my own reference:</p>
<pre class="brush:ps">
$emailFrom = "someone@domain.com"
$emailTo = "someone_else@domain.com"
$subject = "Subject"
$body = "Some text"
$smtpServer = "mail-server.domain.com"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)</pre>
<img src="http://danejeffrey.com/blog/?ak_action=api_record_view&id=337&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/' addthis:title='Windows PowerShell Send Email ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://danejeffrey.com/blog/2010/07/06/windows-powershell-send-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

