<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tech Dashboard</title>
	<atom:link href="http://briangordon.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://briangordon.wordpress.com</link>
	<description>Powershell and VMware Script Spot</description>
	<lastBuildDate>Mon, 03 Oct 2011 15:07:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='briangordon.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tech Dashboard</title>
		<link>http://briangordon.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://briangordon.wordpress.com/osd.xml" title="Tech Dashboard" />
	<atom:link rel='hub' href='http://briangordon.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Powershell: Remove-Datastore</title>
		<link>http://briangordon.wordpress.com/2011/02/21/powershell-remove-datastore/</link>
		<comments>http://briangordon.wordpress.com/2011/02/21/powershell-remove-datastore/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 03:52:41 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[Add]]></category>
		<category><![CDATA[datastore]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[Host]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[Remove]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=156</guid>
		<description><![CDATA[Here&#8217;s the cousin script to the add NFS datastore to multiple esx hosts.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=156&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the cousin script to the <a href="http://briangordon.wordpress.com/2010/09/10/powershell-add-nfs-datastore-to-multiple-esx-hosts/">add NFS datastore to multiple esx hosts</a>.</p>
<pre class="brush: powershell;">
$ds_name = (Read-Host &quot;Enter datastore name to delete&quot;)
$vm_hosts = Get-VMHost -Datastore $ds_name

foreach($esx in $vm_hosts)
{
Remove-Datastore -VMHost $esx.Name -Datastore $ds_name -ErrorAction SilentlyContinue -Confirm:$false -RunAsync | Out-Null
Write-Host $ds_name removed from $esx.Name
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=156&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2011/02/21/powershell-remove-datastore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Count The Number Of VM&#8217;s On A Datastore</title>
		<link>http://briangordon.wordpress.com/2011/01/17/powershell-count-the-number-of-vms-on-a-datastore/</link>
		<comments>http://briangordon.wordpress.com/2011/01/17/powershell-count-the-number-of-vms-on-a-datastore/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 20:27:36 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=145</guid>
		<description><![CDATA[Getting information like number of VM&#8217;s on a specific datastore is easy within the VIC. You can get this information from the Datastores Summary tab. However, if for some reason you needed it scripted or were building a script that required this information to act on, here is how you could pull it. You can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=145&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Getting information like number of VM&#8217;s on a specific datastore is easy within the VIC. You can get this information from the Datastores Summary tab. However, if for some reason you needed it scripted or were building a script that required this information to act on, here is how you could pull it.</p>
<pre class="brush: powershell;">
param ($ds)

Get-Datastore -Name $ds| Foreach-Object {
$number = $_ | Get-VM | Select-Object Name
Write-Host $number.Count
}

Disconnect-VIServer -Confirm:$false
</pre>
<p>You can run this script from the command line by calling the script and specifying which datastore you want to run it against. For example: .\script.ps1 datastore1</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=145&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2011/01/17/powershell-count-the-number-of-vms-on-a-datastore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Check if IIS is Running on a Remote Server</title>
		<link>http://briangordon.wordpress.com/2010/10/27/powershell-check-if-iis-is-running-on-a-remote-server/</link>
		<comments>http://briangordon.wordpress.com/2010/10/27/powershell-check-if-iis-is-running-on-a-remote-server/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 16:16:43 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IISADMIN]]></category>
		<category><![CDATA[Remote]]></category>
		<category><![CDATA[Running]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Service]]></category>
		<category><![CDATA[Started]]></category>
		<category><![CDATA[Win32_Service]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=139</guid>
		<description><![CDATA[This is a quick script that will tell you if IIS is running on a list of remote servers. Just like my other scripts this one requires a &#8220;servers.txt&#8221; file in the same location as the script. I enter all the servers I want to check in that file.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=139&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a quick script that will tell you if IIS is running on a list of remote servers. Just like my other scripts this one requires a &#8220;servers.txt&#8221; file in the same location as the script. I enter all the servers I want to check in that file.</p>
<pre class="brush: powershell;">
$servers = (Get-Content servers.txt)

foreach($vm in $servers){
$iis = get-wmiobject Win32_Service -ComputerName $vm -Filter &quot;name='IISADMIN'&quot;

if($iis.State -eq &quot;Running&quot;)
{Write-Host &quot;IIS is running on $vm&quot;}

else
{Write-Host &quot;IIS is not running on $vm&quot;}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=139&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/10/27/powershell-check-if-iis-is-running-on-a-remote-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Add NFS Datastore to Multiple ESX Hosts</title>
		<link>http://briangordon.wordpress.com/2010/09/10/powershell-add-nfs-datastore-to-multiple-esx-hosts/</link>
		<comments>http://briangordon.wordpress.com/2010/09/10/powershell-add-nfs-datastore-to-multiple-esx-hosts/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 22:04:50 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[Add]]></category>
		<category><![CDATA[datastore]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[Host]]></category>
		<category><![CDATA[Mount]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=128</guid>
		<description><![CDATA[Adding a datastore to an esx host isn&#8217;t to time consuming or difficult but to save a little bit of time and avoid the repetitiveness, here&#8217;s a script to do it for you. This script will mount an NFS datastore. Of course, you can change the protocol by using a different switch like -cifs. The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=128&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Adding a datastore to an esx host isn&#8217;t to time consuming or difficult but to save a little bit of time and avoid the repetitiveness, here&#8217;s a script to do it for you. This script will mount an NFS datastore. Of course, you can change the protocol by using a different switch like -cifs.</p>
<pre class="brush: powershell;">
$esx = (Get-Content esx_servers.txt)
$Host_Name = (Read-Host &quot;Enter the server (ex:storage-server-san:&quot;)
$Path = (Read-Host &quot;Enter the path (ex:/vol/vol/ds_name):&quot;)
$Name = (Read-Host &quot;Enter the name of the datastore:&quot;)

foreach($server in $esx){
Get-VMHost $server | New-Datastore -Nfs -NfsHost $Host_Name -Path $Path -Name $Name
}
</pre>
<p>The script asks for the following information:<br />
1. Storage server<br />
2. Path to the storage location<br />
3. Datastore Name</p>
<p><font color="red">Note: The script will only mount the SAME datastore on each esx server you specify. You&#8217;ll need to create a text file called &#8220;esx_servers.txt&#8221; in the same location as the script and enter the esx server names in it.</p>
<p>UPDATE: I&#8217;ve had to modify this script to add multiple datastores to multiple esx hosts. Here is the updated code: </font></p>
<pre class="brush: powershell;">
$servers = @()
$paths = @()
$datastores = @()

$answer = &quot;y&quot;

while($answer -eq &quot;y&quot;){
$servers += Read-Host &quot;Enter the server (ex:usadc-nas05a-san)&quot;
$paths += Read-Host &quot;Enter the path (ex:/vol/vol/ds_name)&quot;
$datastores += Read-Host &quot;Datastore name ?&quot;
$answer = Read-Host &quot;Enter another NFS mount?&quot;}

$Error.Clear()

Get-Content servers.txt | %{
$esx = Get-VMHost -Name $_
$countNFS = $servers.Count
if($countNFS -ne 0){
0..($countNFS - 1) | %{
$esx | New-Datastore -Nfs -NfsHost $servers[$_] -Path $paths[$_] -Name $datastores[$_] | Out-Null
if($Error.count -gt 0){
$Error | out-file ('c:\powershell scripts\logs\' + $esx + '.txt') -append
$Error.Clear()
}
}
}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=128&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/09/10/powershell-add-nfs-datastore-to-multiple-esx-hosts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Mount Datastore ISO to Multiple VM&#8217;s</title>
		<link>http://briangordon.wordpress.com/2010/09/09/powershell-mount-iso-to-multiple-vms/</link>
		<comments>http://briangordon.wordpress.com/2010/09/09/powershell-mount-iso-to-multiple-vms/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 17:26:18 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[datastore]]></category>
		<category><![CDATA[ISO]]></category>
		<category><![CDATA[Mount]]></category>
		<category><![CDATA[Power Shell]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=102</guid>
		<description><![CDATA[I had to install a piece of software on several vm&#8217;s a few days ago and got somewhat bored of the same repetitive task of mounting the ISO to all of the vm&#8217;s cd-rom drive. So, I wrote a script that will automatically mount the ISO that I specify and connect the cd-rom drive. What [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=102&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had to install a piece of software on several vm&#8217;s a few days ago and got somewhat bored of the same repetitive task of mounting the ISO to all of the vm&#8217;s cd-rom drive. So, I wrote a script that will automatically mount the ISO that I specify and connect the cd-rom drive. </p>
<pre class="brush: powershell;">
$VMs = (Get-Content servers.txt)
$ds = (Read-Host &quot;Type the datastore name:&quot;)
$ISO_Path = (Read-Host &quot;Type the path to the iso file:&quot;)

foreach($vm in $VMs){
	Get-CDDrive $vm | Set-CDDrive -StartConnected:$true -Connected:$true -IsoPath [$ds]  $ISO_Path -Confirm:$false
}
</pre>
<p>What this script does is prompt you for the datastore location that your ISO&#8217;s are located in. For example, if your ISO is located in the datastore &#8220;ISOs&#8221; you would type that. The script then prompts you for the full path to the iso. This is what your input should look like</p>
<p>1. Type the datastore name: vm_isos<br />
2. Type the path to the iso file: folder/folder1/folder2/file.iso</p>
<p>On the flip side if you want to disconnect the cd-rom from multiple vm&#8217;s, you just need to modify the script a bit. </p>
<pre class="brush: powershell;">
$VMs = (Get-Content servers.txt)

foreach($vm in $VMs){
	Get-CDDrive $vm | Set-CDDrive -NoMedia -StartConnected:$false
-Connected:$false -Confirm:$false
}
</pre>
<p><font color="red">Note: This will actually remove the mounted iso (-NoMedia) but it will also disconnect the cd-rom and set the startconnected switch to false.</font></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=102&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/09/09/powershell-mount-iso-to-multiple-vms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Shutdown VM and Delete From Disk</title>
		<link>http://briangordon.wordpress.com/2010/09/02/powershell-shutdown-vm-and-delete-from-disk/</link>
		<comments>http://briangordon.wordpress.com/2010/09/02/powershell-shutdown-vm-and-delete-from-disk/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 15:27:08 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[Decommission]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[Disk]]></category>
		<category><![CDATA[Remove-VM]]></category>
		<category><![CDATA[Stop-VM]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=97</guid>
		<description><![CDATA[This is a fairly simple script but I thought I&#8217;d share. I needed to delete a group of about 6 virtual machines this morning. I could easily do this through the vSphere GUI but I figured I&#8217;d write a quick script so I could use it for future deletions. Updated Script: This script will run [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=97&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a fairly simple script but I thought I&#8217;d share. I needed to delete a group of about 6 virtual machines this morning. I could easily do this through the vSphere GUI but I figured I&#8217;d write a quick script so I could use it for future deletions. </p>
<pre class="brush: powershell;">

$VMs = (Get-Content servers.txt)

foreach($vm in $VMs){
$active = Get-VM $vm
if($active.PowerState -eq &quot;PoweredOn&quot;){
Stop-VM -VM $vm -Confirm:$false
Start-Sleep -Seconds 10
Remove-VM -VM $vm -DeleteFromDisk -Confirm:$false -RunAsync}
else
{Remove-VM -VM $vm -DeleteFromDisk -Confirm:$false -RunAsync}
}
</pre>
<p><font color="red">Updated Script:</font></p>
<pre class="brush: powershell;">
$VMs = (Get-Content servers.txt)
$vmObj = Get-vm $vms

foreach($active in $vmObj){
if($active.PowerState -eq &quot;PoweredOn&quot;){
Stop-VM -VM $active -Confirm:$false -RunAsync | Out-Null}
}
Start-Sleep -Seconds 7

foreach($delete in $vmObj){
Remove-VM -VM $delete -DeleteFromDisk -Confirm:$false -RunAsync | Out-Null}
</pre>
<p>This script will run a lot quicker and the code is a bit cleaner. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=97&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/09/02/powershell-shutdown-vm-and-delete-from-disk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: List VM Name, Hard Drive Name and Datastore Name</title>
		<link>http://briangordon.wordpress.com/2010/09/01/powershell-list-vm-name-hard-drive-name-and-datastore-name/</link>
		<comments>http://briangordon.wordpress.com/2010/09/01/powershell-list-vm-name-hard-drive-name-and-datastore-name/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 13:44:03 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[datastore]]></category>
		<category><![CDATA[filename]]></category>
		<category><![CDATA[locations]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=85</guid>
		<description><![CDATA[I recently had a request for a script that listed virtual machines hard drives and datastore locations. This is a fairly quick and easy script. The only problem is the formatting. Since some VM&#8217;s have more than one HD the formatting is a little odd. Instead of use the Export-CSV cmdlet I decided to use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=85&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently had a request for a script that listed virtual machines hard drives and datastore locations. This is a fairly quick and easy script. The only problem is the formatting. Since some VM&#8217;s have more than one HD the formatting is a little odd. Instead of use the Export-CSV cmdlet I decided to use the Out-File cmdlet and save the results to a text file. It looks a bit cleaner to me. </p>
<pre class="brush: powershell;">
$VMs = Get-vm

foreach ($vm in $VMs){
$ds = Get-HardDisk -VM $vm | Select-Object name,filename
$vm.Name,$ds | Format-Table | Out-File -Append -FilePath &quot;c:\filename.txt}
</pre>
<p>Here&#8217;s a preview of the output:<br />
<img src="http://briangordon.files.wordpress.com/2010/09/ds_example2.jpg?w=640&#038;h=158" alt="" title="ds_example" width="640" height="158" class="aligncenter size-full wp-image-94" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=85&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/09/01/powershell-list-vm-name-hard-drive-name-and-datastore-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>

		<media:content url="http://briangordon.files.wordpress.com/2010/09/ds_example2.jpg" medium="image">
			<media:title type="html">ds_example</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Clone Multiple Virtual Machines Simultaneously</title>
		<link>http://briangordon.wordpress.com/2010/07/21/clone-multiple-virtual-machines-siultaneously/</link>
		<comments>http://briangordon.wordpress.com/2010/07/21/clone-multiple-virtual-machines-siultaneously/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 14:23:52 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=42</guid>
		<description><![CDATA[One of my roles is to stand up environments for development or testing projects. I receive requests on a weekly basis for anywhere from 1-10 virtual machine environments. If I were to use the typical method of vSphere to clone a set of 10 it may take 4-5 hours. The thing about this script is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=42&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of my roles is to stand up environments for development or testing projects. I receive requests on a weekly basis for anywhere from 1-10 virtual machine environments. If I were to use the typical method of vSphere to clone a set of 10 it may take 4-5 hours. The thing about this script is in order to clone multiple VM&#8217;s the specs need to be the same, meaning vCPU, RAM and hard drives. You also need to determine the names you want to use for the virtual machines and then write them down in a text file called servers.txt. I&#8217;ll break down the code to show you exactly what it&#8217;s doing.</p>
<pre class="brush: powershell;">
$VM_Location = &quot;Example&quot;
$servers = (Get-Content servers.txt)
</pre>
<p><strong>Line 1.</strong> Change this variable to suite your environment. This is the inventory location. Where your virtual machine will be stored in the inventory list.<br />
<strong>Line 2.</strong> Read in the server names from the servers.txt file &#8211; Store in the same location as this script.</p>
<pre class="brush: powershell;">
function clone_vms {
	$template_name = (Read-Host &quot;Enter the template name&quot;).Trim()
	$ESX_host = (Read-Host &quot;Enter the ESX host&quot;).Trim()
	$datastore = (Read-Host &quot;Enter the datastore location for the c:\ drive&quot;)
	foreach($server in $servers)
	{
		New-VM -Location $VM_Location -VMHost $ESX_host -Name $server -Template $template_name -Datastore $datastore
	}
}</pre>
<p><strong>Line 1.</strong> Simply creating a function to clone the virtual machines. Makes the code a bit more organized and cleaner.<br />
<strong>Line 2.</strong> Prompting the user for the name of the template. This needs to be exact.<br />
<strong>Line 3.</strong> Prompting the user for the name of the esx host to place these virtual machines on.<br />
<strong>Line 4.</strong> Prompting the user for the name of the datastore for the c:\ drive.<br />
<strong>Line 5.</strong> Simple foreach statement which says for each server in the servers.txt file do the following block of code {xxxxx}<br />
<strong>Line 7.</strong> New-VM is the cmdlet used to create a new virtual machine. Here we define the inventory location with the $VM_Location variable. We also define the ESX Host where we want to place this vm, the name of the VM, the template to use and the datastore location. <strong>Just a tip</strong>, if you want to run multiple clones at the same time use the -RunAsync at the end of line 6, inside the two }}. Be warned though if you run more than 4-5 at a time this will severely impact the performance of vCenter. Right now once one vm clone is finished it automatically starts the next one.</p>
<pre class="brush: powershell;">
function change_vcpu{
	$vCPU = Read-Host &quot;Enter the number of vCPU's&quot;
	foreach($server in $servers)
	{
		Set-VM $server -NumCpu $vCPU -Confirm:$false -RunAsync
	}
}</pre>
<p><strong>Line 4.</strong> Set-VM cmdlet is used to change things like vCPU. We define the $server we want to change the vCPU on based on the foreach loop. We also need to let the cmdlet know how many vCPU we are changing to. The -Confirm:$false switch is telling the cmdlet to not prompt me for permission to change this. The -RunAsync switch says change all servers at the same time. </p>
<pre class="brush: powershell;">
function add_harddrive {
	$size = (Read-Host &quot;Enter size in KB&quot;).Trim()
	$datastore = (Read-Host &quot;Enter DataStore Location&quot;).Trim()
		foreach($server in $servers)
		{
			New-HardDisk -VM $server -CapacityKB $size -ThinProvisioned -DataStore $datastore
		}
}
</pre>
<p><strong>Line 6.</strong> The New-HardDisk cmdlet gives us the ability to add hard drives to a VM. The -VM switch lets the cmdlet know which VM we are adding a hard disk to. The -CapacityKB switch tells the cmdlet how large of a hard drive we are creating. I&#8217;ll talk more about the -ThinProvisioned switch in another blog.</p>
<pre class="brush: powershell;">
function change_ram_amount {
	$ram = Read-Host &quot;Enter amount of RAM in MB&quot;
	foreach($server in $servers)
		{
			Set-VM $server -MemoryMB $ram -Confirm:$false -RunAsync
		}
}
function power_on_vms {
	foreach ($server in $servers)
	{
		Start-VM $server -RunAsync
	}
Write-Host &quot;$server has been powered on&quot;
}

clone_vms

$change_vcpu = (Read-Host &quot;Do you want to change the vCPU count [y] or [n]&quot;).Trim()
if($change_vcpu -eq &quot;y&quot;) {change_vcpu}

$add_harddrive = (Read-Host &quot;Do you want to add a harddrive [y] or [n]&quot;)
if($add_Harddrive -eq &quot;y&quot;) {add_harddrive}

$change_ram = (Read-Host &quot;Do you want to change the amount of RAM [y] or [n]&quot;)
if($change_ram -eq &quot;y&quot;) {change_ram_amount}

power_on_vms
</pre>
<p>I&#8217;ve pretty much gone through all of the cmdlets used, all of the switches used, etc. The last section is changing the RAM amount with the Set-VM cmdlet and then defining the function power_on_vms which does exactly what it says. The next chunk is what actually makes the script run.</p>
<p>Lets take line 18-19 as an example. Line 18 is asking the user whether or not they want to change the RAM amount on the virtual machines and storing the response in a variable called $change_vcpu. Line 19 is a conditional statement saying if $change_vcpu is equal to &#8220;y&#8221; then call the change_vcpu function. If the user types anything other than &#8220;y&#8221; the conditional statement is not equal and moves on to the next one which is prompting to add a hard drive. The same procedure is followed through the rest. </p>
<p>What I do is run a set of 10 virtual machines, specify what I need to and move on to something else. Once I see in vCenter that the virtual machines are all done being created, I check my console again to modify the vCPU, RAM and hard drive specs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=42&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/07/21/clone-multiple-virtual-machines-siultaneously/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Identify all VMs using a particular NIC</title>
		<link>http://briangordon.wordpress.com/2010/07/20/identify-all-vms-using-a-particular-nic/</link>
		<comments>http://briangordon.wordpress.com/2010/07/20/identify-all-vms-using-a-particular-nic/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 17:08:30 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=37</guid>
		<description><![CDATA[Can you imagine going through hundreds or thousands of VM&#8217;s looking for a specific NIC. To do that manually would have taken hours if not days. I was asked if I had a way to identify which VM&#8217;s are running the &#8220;vmxnet3&#8243; adapter. I wrote up this little script which gave us the answers we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=37&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Can you imagine going through hundreds or thousands of VM&#8217;s looking for a specific NIC. To do that manually would have taken hours if not days. I was asked if I had a way to identify which VM&#8217;s are running the &#8220;vmxnet3&#8243; adapter. I wrote up this little script which gave us the answers we were looking for in about 20-30 minutes.</p>
<pre class="brush: powershell;">#Identify all VMs with a specific NIC name

$VMs = (Get-VM)

#Change the adapter_name variable to match the NIC name you are looking for
$adapter_name = &quot;vmxnet3&quot;

#Change the network_path variable to point to your text file that will store the results
$network_path = &quot;c:\powershell scripts\network_adapter.txt&quot;

ForEach ($VM in $VMs){
	$VM_Name = $VM.name
	$Get_Adapter = Get-NetworkAdapter $VM
	$Get_Adapter_Type = $Get_Adapter.Type
	if($Get_Adapter_Type -eq $adapter_name)
		{$VM_name, $Get_Adapter_type | Out-File -FilePath $network_path -append}}
</pre>
<p><font color="red">Note: This script took quite a while to run. I&#8217;ve modified it to run much much more efficiently. This script will finish in about 5 minutes for 1,500+ vm&#8217;s. </font></p>
<pre class="brush: powershell;">
$VMs = Get-VM | Select-Object -Property Name,@{N=&quot;Adapter Type&quot;;E={(Get-NetworkAdapter -VM $_).Type}} |
`Export-Csv -NoTypeInformation -Path network_adapters.csv
</pre>
<p>The only thing about this script is right now it will only report the NIC type for vm&#8217;s with 1 NIC. If the VM has two NIC&#8217;s it won&#8217;t report a type. Also, it will report all NIC types. You will need to open the CSV file and apply a filter based on the type you&#8217;re looking for. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=37&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/07/20/identify-all-vms-using-a-particular-nic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell: Count the number of VMs with memory limits and determine the difference</title>
		<link>http://briangordon.wordpress.com/2010/07/16/powershell-count-the-number-of-vms-with-memory-limits-and-determine-the-difference/</link>
		<comments>http://briangordon.wordpress.com/2010/07/16/powershell-count-the-number-of-vms-with-memory-limits-and-determine-the-difference/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 15:45:26 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Powershell Script]]></category>

		<guid isPermaLink="false">http://briangordon.wordpress.com/?p=27</guid>
		<description><![CDATA[Count the number of VMs with memory limits and determine the difference between configured memory and memory limit. Output the data to two different text files in order to manipulate in different ways. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=27&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am in the process of building several very large dashboards in order for managers and executive managers to be able to quickly determine the state of our, VMware, NetApp and database environments. While writing this script I decided to include the number of &#8220;trimmed&#8221; virtual machines or virtual machines with memory limits. The reason I did this is because a lot of people don&#8217;t understand the difference between how physical memory on a single server is managed vs memory on a hypervisor. After taking a look at CapacityIQ I quickly realized the majority of our VMs were oversized. Half of the memory and cpu weren&#8217;t even being utilized nor had never been utilized. Because VMware doesn&#8217;t have the capability to reconfigure the RAM without resetting a server we decided to set limits. This doesn&#8217;t require a reboot and is easy to change if the ESX server decides to balloon the VM or force it to swap for one reason or another. It&#8217;s also a good statistic for management to see and be able to dissect. Here is the script I wrote to determine how many VMs have limits and what the difference between the configured memory and the limit is. This way we&#8217;re able to tell how much unused memory we&#8217;ve actually recovered.</p>
<pre class="brush: powershell;">
#Get VM Objects
$VMs = Get-VM

#Initialize variables to 0
$count = 0
$Difference = 0
$Recovered_Memory = 0
$Total = 0

#Get limit data for each virtual machine
Write-Host &quot;Collecting VM limit information...&quot;
foreach($vm in $VMs){
	$result = (Get-VMResourceConfiguration -VM $vm)
		if($result.MemLimitMB -ne '-1')
		{
			$Count += &quot;1&quot;
			$vm_memory = $vm.MemoryMB
			$vm_limit = $result.MemLimitMB
			$Difference = ($vm_memory - $vm_limit)
			$Recovered_memory += $Difference
		}
}
Write-Host &quot;Generating results files...&quot;

$final = ($Recovered_Memory/1024)
&quot;{0:N2}&quot; -f $final | Out-File -FilePath recovered_memory.txt
$count | Out-File -FilePath vms_with_limits.txt
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/briangordon.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/briangordon.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/briangordon.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=briangordon.wordpress.com&amp;blog=14591388&amp;post=27&amp;subd=briangordon&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://briangordon.wordpress.com/2010/07/16/powershell-count-the-number-of-vms-with-memory-limits-and-determine-the-difference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c817a8e283003147da96f4089bdd1a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">briangordon</media:title>
		</media:content>
	</item>
	</channel>
</rss>
