<?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: PowerCLI: Shutdown your Virtual Infrastructure</title>
	<atom:link href="http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/</link>
	<description>Virtually everything is poshable</description>
	<lastBuildDate>Sat, 11 Feb 2012 14:14:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Chad</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-10456</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Fri, 04 Nov 2011 13:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-10456</guid>
		<description>Nevermind -- I had changed the wait time, and it was looping at 65 secs, I changed it again and all is well.  Thank you for a great script!

BTW, some may find it useful to use the VMWare credential store, as opposed to storing their credentials in a script, here&#039;s the connection string I have based on this:

http://communities.vmware.com/thread/199583

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\VSphere PowerCLI\vim.psc1” -NoExit –Command 
$creds =  Get-VICredentialStoreItem -Host &#039;yourhost&#039; 
Connect-VIServer -Server yourserver -User $creds.User -Password $creds.Password
# Connect to the VC server credential store</description>
		<content:encoded><![CDATA[<p>Nevermind &#8212; I had changed the wait time, and it was looping at 65 secs, I changed it again and all is well.  Thank you for a great script!</p>
<p>BTW, some may find it useful to use the VMWare credential store, as opposed to storing their credentials in a script, here&#8217;s the connection string I have based on this:</p>
<p><a href="http://communities.vmware.com/thread/199583" rel="nofollow">http://communities.vmware.com/thread/199583</a></p>
<p>C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\VSphere PowerCLI\vim.psc1” -NoExit –Command<br />
$creds =  Get-VICredentialStoreItem -Host &#8216;yourhost&#8217;<br />
Connect-VIServer -Server yourserver -User $creds.User -Password $creds.Password<br />
# Connect to the VC server credential store</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vmware ESXi shutdown &#171; DefaultGateway</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-10416</link>
		<dc:creator>Vmware ESXi shutdown &#171; DefaultGateway</dc:creator>
		<pubDate>Thu, 03 Nov 2011 22:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-10416</guid>
		<description>[...] telepíthetünk. APC és Powerware termékek esetén ez megoldott. Illetve létezik egy PowesShell script is. Ez is hasznos tud [...]</description>
		<content:encoded><![CDATA[<p>[...] telepíthetünk. APC és Powerware termékek esetén ez megoldott. Illetve létezik egy PowesShell script is. Ez is hasznos tud [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-10353</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Wed, 02 Nov 2011 20:01:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-10353</guid>
		<description>Hi, for those VMs that do not have MVtools, they will cause the script to wait, and not shut down the host.  I&#039;m setting up this script to trigger on heat or water in server room, so want things off, how would I set it so that it does a hard shut down of any VMs that have hung?</description>
		<content:encoded><![CDATA[<p>Hi, for those VMs that do not have MVtools, they will cause the script to wait, and not shut down the host.  I&#8217;m setting up this script to trigger on heat or water in server room, so want things off, how would I set it so that it does a hard shut down of any VMs that have hung?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-7551</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 25 Aug 2011 20:55:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-7551</guid>
		<description>Thanks for very useful script. The only problem i had is VCENTER is VM. I did see post above about creating folders but this is what i did to exclude VCENTER until all VM&#039;s down

# For each of the VMs on the ESX hosts
Foreach ($VM in ($ESXSRV &#124; Get-VM &#124; Where { $_.PowerState -eq “poweredOn” } &#124; Where { $_.Name -ne &quot;VCENTER&quot; })){</description>
		<content:encoded><![CDATA[<p>Thanks for very useful script. The only problem i had is VCENTER is VM. I did see post above about creating folders but this is what i did to exclude VCENTER until all VM&#8217;s down</p>
<p># For each of the VMs on the ESX hosts<br />
Foreach ($VM in ($ESXSRV | Get-VM | Where { $_.PowerState -eq “poweredOn” } | Where { $_.Name -ne &#8220;VCENTER&#8221; })){</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anon</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-7550</link>
		<dc:creator>Anon</dc:creator>
		<pubDate>Thu, 25 Aug 2011 15:16:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-7550</guid>
		<description>I&#039;m going round in circles with this script. I just want to stop all VM&#039;s in a RP and not get a warning if they are already powered off. Any help much appreciated.

# Stop all VM&#039;s in a RP

do

{
# Get the name of the Resource Pool
$ResourcePool = read-host &quot; Insert the Name of the Resource Pool to Stop&quot;
# Get the members of that RP
$VMName = (get-resourcepool $ResourcePool &#124; get-vm)
# For each of the VMs in the RP
    {
    Foreach ($VMName in ($ResourcePool &#124; get-vm &#124; Where-object {$_.PowerState -eq “poweredOn” }))
    }        
            # Shutdown the guest cleanly
            {$VMName &#124; Stop-VM -Confirm:$false}
}
until ($script:response -eq &quot;quit&quot;);</description>
		<content:encoded><![CDATA[<p>I&#8217;m going round in circles with this script. I just want to stop all VM&#8217;s in a RP and not get a warning if they are already powered off. Any help much appreciated.</p>
<p># Stop all VM&#8217;s in a RP</p>
<p>do</p>
<p>{<br />
# Get the name of the Resource Pool<br />
$ResourcePool = read-host &#8221; Insert the Name of the Resource Pool to Stop&#8221;<br />
# Get the members of that RP<br />
$VMName = (get-resourcepool $ResourcePool | get-vm)<br />
# For each of the VMs in the RP<br />
    {<br />
    Foreach ($VMName in ($ResourcePool | get-vm | Where-object {$_.PowerState -eq “poweredOn” }))<br />
    }<br />
            # Shutdown the guest cleanly<br />
            {$VMName | Stop-VM -Confirm:$false}<br />
}<br />
until ($script:response -eq &#8220;quit&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: XXXXX</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-6460</link>
		<dc:creator>XXXXX</dc:creator>
		<pubDate>Fri, 20 May 2011 14:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-6460</guid>
		<description>This is how I got around the VCenter as a VM problem:


Start-Transcript -Path C:\CSS_Log.txt -Append

Add-PSSnapin VMware.VimAutomation.Core
Set-PowerCLIConfiguration -DefaultVIServerMode multiple -Confirm:$False

Connect-VIServer HOSTA,HOSTB,HOSTC -User &#039;USER&#039; -Password &#039;PASSWORD&#039;
Get-VMHost &#124; Get-VMHostStartPolicy &#124; Set-VMHostStartPolicy -Enabled:$True -WaitForHeartBeat:$True
Get-VM &#124; Get-VMStartPolicy &#124; Set-VMStartPolicy -StartAction PowerOn -UnspecifiedStartOrder
Get-VM -Name SVR-SQL01 &#124; Get-VMStartPolicy &#124; Set-VMStartPolicy -StartAction PowerOn -StartOrder 3
Get-VM -Name SVR-VC01 &#124; Get-VMStartPolicy &#124; Set-VMStartPolicy -StartAction PowerOn -StartOrder 2
Get-VM -Name SVR-DC01 &#124; Get-VMStartPolicy &#124; Set-VMStartPolicy -StartAction PowerOn -StartOrder 1
Get-VM &#124; Shutdown-VMGuest -Confirm:$False
DO {Get-VM &#124; Get-VMGuest} WHILE (Get-VM &#124; Get-VMGuest &#124; where {$_.State -eq &quot;Running&quot;})
Get-VM &#124; Stop-VM -Confirm:$False
DO {Get-VM} WHILE (Get-VM &#124; where {$_.PowerState -eq &quot;PoweredOn&quot;})
Get-VMHost &#124; Stop-VMHost -Force -Confirm:$False

Stop-Transcript</description>
		<content:encoded><![CDATA[<p>This is how I got around the VCenter as a VM problem:</p>
<p>Start-Transcript -Path C:\CSS_Log.txt -Append</p>
<p>Add-PSSnapin VMware.VimAutomation.Core<br />
Set-PowerCLIConfiguration -DefaultVIServerMode multiple -Confirm:$False</p>
<p>Connect-VIServer HOSTA,HOSTB,HOSTC -User &#8216;USER&#8217; -Password &#8216;PASSWORD&#8217;<br />
Get-VMHost | Get-VMHostStartPolicy | Set-VMHostStartPolicy -Enabled:$True -WaitForHeartBeat:$True<br />
Get-VM | Get-VMStartPolicy | Set-VMStartPolicy -StartAction PowerOn -UnspecifiedStartOrder<br />
Get-VM -Name SVR-SQL01 | Get-VMStartPolicy | Set-VMStartPolicy -StartAction PowerOn -StartOrder 3<br />
Get-VM -Name SVR-VC01 | Get-VMStartPolicy | Set-VMStartPolicy -StartAction PowerOn -StartOrder 2<br />
Get-VM -Name SVR-DC01 | Get-VMStartPolicy | Set-VMStartPolicy -StartAction PowerOn -StartOrder 1<br />
Get-VM | Shutdown-VMGuest -Confirm:$False<br />
DO {Get-VM | Get-VMGuest} WHILE (Get-VM | Get-VMGuest | where {$_.State -eq &#8220;Running&#8221;})<br />
Get-VM | Stop-VM -Confirm:$False<br />
DO {Get-VM} WHILE (Get-VM | where {$_.PowerState -eq &#8220;PoweredOn&#8221;})<br />
Get-VMHost | Stop-VMHost -Force -Confirm:$False</p>
<p>Stop-Transcript</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lethalduck</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-6287</link>
		<dc:creator>lethalduck</dc:creator>
		<pubDate>Thu, 12 May 2011 00:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-6287</guid>
		<description>I&#039;m not using $host as a variable.
The PowerCLI admin manual on pg 14 is.
As shown above.
So obviously it&#039;s another VMware error?

Also be aware that any shutdown will not work on ESXi.
As They have disabled write access to the host.

So I&#039;m in the process of writing a shutdown application to get around this new limitation and will be posting on my blog when done if anyone interested.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not using $host as a variable.<br />
The PowerCLI admin manual on pg 14 is.<br />
As shown above.<br />
So obviously it&#8217;s another VMware error?</p>
<p>Also be aware that any shutdown will not work on ESXi.<br />
As They have disabled write access to the host.</p>
<p>So I&#8217;m in the process of writing a shutdown application to get around this new limitation and will be posting on my blog when done if anyone interested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Virtu-Al</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-6275</link>
		<dc:creator>Virtu-Al</dc:creator>
		<pubDate>Wed, 11 May 2011 16:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-6275</guid>
		<description>Yeah, you shouldnt use $host as a variable as this is a reserved variable, type $host in PowerShell and you will get information about the current powershell session, I would change the $host in your script to $h as you are then calling $h on the next line.</description>
		<content:encoded><![CDATA[<p>Yeah, you shouldnt use $host as a variable as this is a reserved variable, type $host in PowerShell and you will get information about the current powershell session, I would change the $host in your script to $h as you are then calling $h on the next line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cowboy</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-6260</link>
		<dc:creator>cowboy</dc:creator>
		<pubDate>Tue, 10 May 2011 08:12:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-6260</guid>
		<description>@Virtu-Al

thank you for your advice.i added the flowing code to my script
	if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {
		Write-Host &quot;add-pssnapin ...&quot;
		add-pssnapin VMware.VimAutomation.Core
	}else{
		Write-Host &quot;already exist.no need to add&quot;
	}
it shows  &quot;already exist.no need to add&quot;.and no output from get-vm cmdlet.</description>
		<content:encoded><![CDATA[<p>@Virtu-Al</p>
<p>thank you for your advice.i added the flowing code to my script<br />
	if (!(get-pssnapin -name VMware.VimAutomation.Core -erroraction silentlycontinue)) {<br />
		Write-Host &#8220;add-pssnapin &#8230;&#8221;<br />
		add-pssnapin VMware.VimAutomation.Core<br />
	}else{<br />
		Write-Host &#8220;already exist.no need to add&#8221;<br />
	}<br />
it shows  &#8220;already exist.no need to add&#8221;.and no output from get-vm cmdlet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lethalduck</title>
		<link>http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/#comment-6200</link>
		<dc:creator>lethalduck</dc:creator>
		<pubDate>Fri, 06 May 2011 04:46:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=1270#comment-6200</guid>
		<description>Hi.

I&#039;m looking at shutting down a ESXi host with running guests.
The guests should get automaticaly shutdown by the host if configured correctly.
So just need to shutdown the host cleanly.
Also need to shut down another FreeNAS box, but that&#039;s another story.
Been playing with a few scripts, then saw one in the vSphere PowerCLI Administration Guide on pg 14:
Downloadable from here http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/index.html
5 Shut down the myHost virtual machine host
  $host = Get-VMHost myHost
  $hv = Get-View $h.ID
  $hv.ShutdownHost_Task($true)
Any one got any idea what the $h is?
Also when I run the first line in PowerGUI Script Editor I get:
Cannot overwrite variable Host because it is read-only or constant.
At C:\Users\user\AppData\Local\Temp\7aad3dc5-990e-4568-a06b-987092d00575.ps1:5 char:6
+ $host &lt;&lt;&lt;&lt;  = Get-VMHost $vSphereServername
    + CategoryInfo          : WriteError: (Host:String) [], SessionStateUnauthorizedAccessException
    + FullyQualifiedErrorId : VariableNotWritable
 
Then for the second line I get:
Get-View : Cannot validate argument on parameter &#039;VIObject&#039;. The argument is null or empty. Supply an argument that is not null or empty and then try the
 command again.
At C:\Users\user\AppData\Local\Temp\7aad3dc5-990e-4568-a06b-987092d00575.ps1:6 char:15
+ $hv = Get-View &lt;&lt;&lt;&lt;  $h.ID

I&#039;ve already established connection to the host by way of Connect-VIServer.
Anyone got any ideas?</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>I&#8217;m looking at shutting down a ESXi host with running guests.<br />
The guests should get automaticaly shutdown by the host if configured correctly.<br />
So just need to shutdown the host cleanly.<br />
Also need to shut down another FreeNAS box, but that&#8217;s another story.<br />
Been playing with a few scripts, then saw one in the vSphere PowerCLI Administration Guide on pg 14:<br />
Downloadable from here <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/index.html" rel="nofollow">http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/index.html</a><br />
5 Shut down the myHost virtual machine host<br />
  $host = Get-VMHost myHost<br />
  $hv = Get-View $h.ID<br />
  $hv.ShutdownHost_Task($true)<br />
Any one got any idea what the $h is?<br />
Also when I run the first line in PowerGUI Script Editor I get:<br />
Cannot overwrite variable Host because it is read-only or constant.<br />
At C:\Users\user\AppData\Local\Temp\7aad3dc5-990e-4568-a06b-987092d00575.ps1:5 char:6<br />
+ $host &lt;&lt;&lt;&lt;  = Get-VMHost $vSphereServername<br />
    + CategoryInfo          : WriteError: (Host:String) [], SessionStateUnauthorizedAccessException<br />
    + FullyQualifiedErrorId : VariableNotWritable</p>
<p>Then for the second line I get:<br />
Get-View : Cannot validate argument on parameter &#039;VIObject&#039;. The argument is null or empty. Supply an argument that is not null or empty and then try the<br />
 command again.<br />
At C:\Users\user\AppData\Local\Temp\7aad3dc5-990e-4568-a06b-987092d00575.ps1:6 char:15<br />
+ $hv = Get-View &lt;&lt;&lt;&lt;  $h.ID</p>
<p>I&#039;ve already established connection to the host by way of Connect-VIServer.<br />
Anyone got any ideas?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

