<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script to kill a hung vCenter task in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496436#M85006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks much Luc. Finally i disconnected that host from VC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible from powershell to retrieve a list of all services running/stopped on a ESX(i) host just like the output of "service --status-all" command?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jun 2010 05:14:58 GMT</pubDate>
    <dc:creator>Sureshadmin</dc:creator>
    <dc:date>2010-06-22T05:14:58Z</dc:date>
    <item>
      <title>Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496432#M85002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking for a script to kill a hung vCenter task. There was esx box(v3.5) which had problems and i has to disconnect and reconnect back in vCenter. When i tried to reconnect the esx box back, the task is in "In progress" state for several hours without timing out. I tried restarting mgmt-vmware and virtual center services in the ESX box but no luck. Can this task be killed via a powershell script or do i have to restart vCenter services?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 03:13:07 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496432#M85002</guid>
      <dc:creator>Sureshadmin</dc:creator>
      <dc:date>2010-06-21T03:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496433#M85003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That depends, some tasks are not cancelable.&lt;/P&gt;&lt;P&gt;You would first have to "get" the task ID and then you can use the Stop-Task cmdlet.&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
Get-Task -Status "running"
&lt;/PRE&gt;&lt;P&gt;will return all running task and you will have to select the one you're trying to kill.&lt;/P&gt;&lt;P&gt;Then you can use the Stop-Task cmdlet.&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
$task = Get-Task -Status "Running" | where {$_.Name -eq $tgtName}
Stop-Task -Task $task -Confirm:$false
&lt;/PRE&gt;&lt;P&gt;Here the task is selected based on the name, but there are other properties you could use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;____________&lt;/P&gt;&lt;P&gt;Blog: &lt;A href="http://lucd.info"&gt;LucD notes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Twitter: &lt;A href="http://twitter.com/lucd22"&gt;lucd22&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 05:34:39 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496433#M85003</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2010-06-21T05:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496434#M85004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're right. I got a error msg "This task is not cancellable"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So is there a way from powershell to force disconnect a ESX server from VC and de-register all the virtual machines in that esxbox and reconnect it back to the virtual center?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 06:20:52 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496434#M85004</guid>
      <dc:creator>Sureshadmin</dc:creator>
      <dc:date>2010-06-21T06:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496435#M85005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To remove all VMs on a specific host from the inventory, you can do&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
Get-VMHost -Name &amp;lt;esxname&amp;gt; | Get-VM | Remove-VM -DeleteFromDisk:$false
&lt;/PRE&gt;&lt;P&gt;To disconnect/connect an ESX(i) host you can do the following.&lt;/P&gt;&lt;P&gt;I assume there are no guests running on the host.&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
$esxName = &amp;lt;esxname&amp;gt;
Get-VMHost -Name $esxName | Remove-VMHost
Add-VMHost -Name $esxName -Credential (Get-Credential) 
&lt;/PRE&gt;&lt;P&gt;To add the guests back to the inventory, you could eventually use the script from my &lt;A href="http://www.lucd.info/2009/12/02/raiders-of-the-lost-vmx/"&gt;Raiders of the Lost VMX&lt;/A&gt; post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;____________&lt;/P&gt;&lt;P&gt;Blog: &lt;A href="http://lucd.info"&gt;LucD notes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Twitter: &lt;A href="http://twitter.com/lucd22"&gt;lucd22&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 06:43:03 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496435#M85005</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2010-06-21T06:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496436#M85006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks much Luc. Finally i disconnected that host from VC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible from powershell to retrieve a list of all services running/stopped on a ESX(i) host just like the output of "service --status-all" command?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 05:14:58 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496436#M85006</guid>
      <dc:creator>Sureshadmin</dc:creator>
      <dc:date>2010-06-22T05:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496437#M85007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm afraid not witha PowerCLI cmdlet.&lt;/P&gt;&lt;P&gt;This&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
Get-VMHost $esxName | Get-VMHostService
&lt;/PRE&gt;&lt;P&gt;only returns the status of the ntpd, sshd,vmware-vpxa and vmware-webaccess services.&lt;/P&gt;&lt;P&gt;You can of course use the plink.exe trick to launch the "service --status-all" command and capture the output.&lt;/P&gt;&lt;P&gt;Something like this (provided sudo is set up correctly)&lt;/P&gt;&lt;PRE __jive_macro_name="code"&gt;
$ESXserver = &amp;lt;esxname&amp;gt;

$User = &amp;lt;esx-account&amp;gt;
$Pswd = &amp;lt;esx-password&amp;gt;
$plink = &amp;lt;PuTTY directory&amp;gt;\Putty\plink.exe"
$plinkoptions = "-v -batch -pw $Pswd"
$cmd1 = "/sbin/service --status-all"

$remoteCommand = "'" + $cmd1 + "'"
$command = $plink + " " + $plinkoptions + " " + $User + "@" + $ESXserver + " " + $remoteCommand

$msg = Invoke-Expression -command $command
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;____________&lt;/P&gt;&lt;P&gt;Blog: &lt;A href="http://lucd.info"&gt;LucD notes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Twitter: &lt;A href="http://twitter.com/lucd22"&gt;lucd22&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 05:33:43 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496437#M85007</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2010-06-22T05:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496438#M85008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jun 2010 04:32:37 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2496438#M85008</guid>
      <dc:creator>Sureshadmin</dc:creator>
      <dc:date>2010-06-23T04:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919786#M107506</link>
      <description>&lt;P&gt;I don't want use it with variable for example when I run :&lt;/P&gt;&lt;PRE&gt;Get-Task -Status "Running"&lt;/PRE&gt;&lt;P&gt;it shows follow&amp;nbsp; :&lt;/P&gt;&lt;P&gt;Name ;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;complete:&lt;/P&gt;&lt;P&gt;Deploy myvm&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;running&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0%&lt;/P&gt;&lt;P&gt;Now I want use follow command and just type the task name . How can do it ?&lt;/P&gt;&lt;PRE&gt;Stop-Task -Task&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 15:47:09 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919786#M107506</guid>
      <dc:creator>baber</dc:creator>
      <dc:date>2022-07-21T15:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919787#M107507</link>
      <description>&lt;P&gt;How is this related in any way to the original question in this thread from 2010?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 15:49:29 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919787#M107507</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-07-21T15:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script to kill a hung vCenter task</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919792#M107511</link>
      <description>&lt;P&gt;No problem . I will open new topic&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:01:38 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-to-kill-a-hung-vCenter-task/m-p/2919792#M107511</guid>
      <dc:creator>baber</dc:creator>
      <dc:date>2022-07-21T16:01:38Z</dc:date>
    </item>
  </channel>
</rss>

