Looking for a script that will power on VM's that are not powered on contained in either a folder or possibly a resource pool, not sure which will be used depending on the complexity. The VM's can be powered on without waiting for the response back as in Start-VM -Confirm:$false -RunAsync as I believe that will not waiting for return response.
Also, because this is for DR purposes the VM's are on different disk and the questioned is raised "VMware ESX needs to know if this virtual machine was moved or copied." Is there a way to answer the question through the same PowerCLI script?
Thanks for any help you can provide.
ps How do colorize the script contents that I see posted here in replies. It obviously allows for better readability.
You can use the Get-VMQuestion and Set-VMQuestion for that.
To have html text have a look at my Some ways to enter PowerCLI code under the new forum SW
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The colorized script content is taken from PowerGUI's CopyAsHTML option.
In the forum editor switch to HTML editor and paste the HTML code from PowerGUI.
Thanks for info. I think it should work for me was I figure out a few things.
Obviously, being a n00b to scripting I was wondering how you find all the different options available. For example in the below samples where are all the possible options listed for the parameters of Path, Notes, -match, -eq, etc? I'm sure there are plenty others that I'm not considering. Thanks again.
where {$_.Path
where {$_.Notes -match
-eq
There are a couple of PowerShell cmdlets that help the beginning (and advanced) user.
With the Get-Command cmdlet, you can retrieve the parameters of a cmdlet.
Get-Command -Name Where-Object -Syntax
Or you use the Get-Help cmdlet which gives you the complete help for the cmdlet
Get-Help Where-Object -Full
In both case I assumed you knew that 'where' is an alias for the Where-Object cmdlet. But if you don't, you always list the existing aliases.
Get-Alias where
or just
Get-Alias
to see them all.
Another cmdlet shows you all properties and methods for an object.
For example
Get-VM MyVM | Get-Member
will return all properties on the object that Get-VM returns.
For a good introduction to PowerShell have a look at this free ebook called Master PowerShell.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great info. Just beginning to get familiar.
Here's what I have which should work;
Get-VM -Location (Get-Folder -Name Production) | where {$_.PowerState -eq "PoweredOff"}
The rest I'm not so sure, need to test, may need to reverse these;
| Start-VM Confirm:$false - RunAsync | Set-VMQuestion "I moved it"
As soon as my browser stops having a fit I'll reward points.
Thank you both for the help.