8 Replies Latest reply on Aug 8, 2017 6:53 AM by Zsoldier

    Baffled, runs interactively, doesn't run in windows task scheduler (win 2012 r2)

    SteveCSchofield Enthusiast

      baffled....The user executing the task has Logon as a Batch, is a local Administrator.   I'm using the latest download from



      I run this interactively, it works.  I run in a windows task scheduler, zero machines are returned.



      Connect-viserver -server vcenter.ss.local -user user@vsphere.local -password deleteme | out-null

      start-sleep -s 10

      $vmlist = Get-Folder -Name VRMDeleted | Get-vm

      Add-Content -path "e:\temp\log.txt" -value $vmlist.count

      foreach($vm in $vmlist)




              Add-Content -path "e:\temp\vm.txt" -value $vm.name

              Remove-VM -DeletePermanently -VM $vm -confirm:$false




              Add-Content -path "e:\temp\errors.txt" -value $error