VMware Cloud Community
netmasat
Contributor
Contributor

Need help to execute script automatizatcion delete virtual machines with PowerShell

Buenas:

The first thing to thank anyone who answers, ask forgiveness for my GOOGLE - english and

by any other aberration in PROGAMMING CODE you can say, because they have little

time in the world of computing.

My problem is that I can not automate the task of erasing virtual machines with

PowerShell, these are the lines of the file delete_clone.ps1 I try to run:

connect-viserver -server srvbackup -user administrador -password '123456'

Get-VM -Name Pruebaborrado.clon | where {$_.PowerState -match "PoweredOff"}

Remove-VM (Get-VM -Name Pruebaborrado.clon | where {$_.PowerState -match "PoweredOff"}) -DeleteFromDisk -Confirm:$false

(The script works from console or from the PowerGUI Script Editor)

And I try to automate the Windows Scheduled Tasks, adding this line in

Run the schedule at the end of the task and choose "Open Popiedades Advanced":

C: \ WINDOWS \ system32 \ WINDOW ~ 2 \ v1.0 \ powershell.exe-PSConsoleFile "C: \ Program Files \ VMware \ Infrastructure \ VIToolkitForWindows \ vim.psc1" C: \ vmware \ Scripts \ delete-clone.ps1

Either this command from vim.psc1 logged in as administrator:

at \ \ srvbackup 19:15 C: \ scripstvmware. \ delete_clone.ps1

Finally I ask existential questions why sheduler task in VMware Virtual Center does not appear or delete Delete From Disk ", and by God can we make? 6628_6628.jpg

We would greatly appreciate answers vuestrs worth it for me to finish the job of a migration to VMware Server.

Un Saludo.

0 Kudos
3 Replies
Ken_Cline
Champion
Champion

Moved to a more appropriate forum. Other admins - if there's a better-yet forum, please move again!

Ken Cline

VMware vExpert 2009

VMware Communities User Moderator

Blogging at: http://KensVirtualReality.wordpress.com/

Ken Cline VMware vExpert 2009 VMware Communities User Moderator Blogging at: http://KensVirtualReality.wordpress.com/
0 Kudos
netmasat
Contributor
Contributor

First thanks for reply and apologize for not enable us before but I'm on vacation and no internet.

I would like to ask help, because I do not understand your message well. I do not know about you as an administrator, you moved my post to another more appropriate forum or do I have to move.

Also wanted to tell me what the most appropriate forum for my post and if you can change or remove it in the title of the post there is an error in translation. I mean that I need help instead of saying if someone needs help.

Once again I apologize for my google-english and thank you very much for your attention.

0 Kudos
harkamal
Expert
Expert

Scheduling task in windows scheduler does not make it appear in vmware vi client scheduled tasks tab. VI Client has limited capability for what you can schedule.

Add the following to top of your script..

Get-Pssnapin -r | Add-pssnapin

Add windows scheduled task..

powershell.exe ./sctiptPath

0 Kudos