HI,
Is there a command to stop a VM, relocated it to another datastore and then restarted it on the new datastore (or in 2 commands).
Thx
You can download PowerCLI from http://www.vmware.com/go/powercli. There you can also find the documentation. PowerCLI is a snapin for Microsoft Windows PowerShell that you can download from http://blogs.msdn.com/powershell/pages/download-windows-powershell.aspx if you don't have it allready. PowerShell is a scripting language and a shell like the DOS box. A very good book about PowerCLI is Hal Rottenberg's Managing VMware Infrastructure with Windows PowerShell TFM. And if you have any question about PowerCLI, you can ask them in the VMware PowerCLI Community.
Regards, Robert
You can do this in PowerCLI. Something like:
Connect-VIServer MyvCenterServer Get-VM MyVM | Stop-VM | Move-VM -Datastore MyDatastore | Start-VM
Regards, Robert
Hi,
Thank you for your answer.
I don't know how to use PowerCLI.
How to install it ? and how to use it ?
Have you any quick guide about it or any link ?
Thx
You can download PowerCLI from http://www.vmware.com/go/powercli. There you can also find the documentation. PowerCLI is a snapin for Microsoft Windows PowerShell that you can download from http://blogs.msdn.com/powershell/pages/download-windows-powershell.aspx if you don't have it allready. PowerShell is a scripting language and a shell like the DOS box. A very good book about PowerCLI is Hal Rottenberg's Managing VMware Infrastructure with Windows PowerShell TFM. And if you have any question about PowerCLI, you can ask them in the VMware PowerCLI Community.
Regards, Robert
When I type your command line it ask me for an answer (typ D for .., A for All etc)
Is it possible to automate my answer and not typing any character ?
Thx
When I type your command line it asks me for an answer.
Is it possible to automate my answer and not typing any chararcter ?
ThX
It is probably the Stop-VM cmdlet that asks for a confirmation. You can prevent that question by adding "-Confirm:$false" to the cmdlet. That changes the code into:
Connect-VIServer MyvCenterServer Get-VM MyVM | Stop-VM -Confirm:$false | Move-VM -Datastore MyDatastore | Start-VM
Remember that you have to use the Connect-VIserver cmdlet only once in your session.
More information about the -Confirm parameter and other ways to prevent this question can be found at the Windows PowerShell Blog.
Regards, Robert
Thx for all your answers.
Now how can I launch these commands in a script ans how can I invoke this script ? (what is the syntax ?)
Thx
To run a PowerCLI script you have to put all the commands in a text file that you save with the extension .PS1. If you save the script as MyScript.PS1 in the current directory, you can run the script with:
.\MyScript.PS1
Regards, Robert
Ok thank you very much for your help.
I've already seen this information but I believed it was "psL" and not "ps1" extention and so it didn't work.
Now all is OK
Thx
I've put your command line in a file.ps1
Now I want to schedule this comand line.
To do that I use the "at" command with this syntax :
d:\tmp> at 14:40 .\file.ps1
Now I've got schedule this commands. When I test it at 14:41 for ie, the at command returns :
Error 1 Tomorrow 14:41 .\file.ps1
Can you help me with the correct syntax or is there something else ?
Thx
Is it possible to give login and password without typing it with command
<code>Connect-VIServer MyvCenterServer</code>What I want to do is automaticaly giving it my login / password.How can I do that please ?
Thx