250 likes | 398 Views
VI Toolkit/ PowerShell for VMware. Randy Snyder. Microsoft PowerShell. Command line shell and scripting language Download Windows PowerShell 1.0 and install http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx Open a command prompt .
E N D
VI Toolkit/PowerShell for VMware Randy Snyder
Microsoft PowerShell • Command line shell and scripting language • Download Windows PowerShell 1.0 and install • http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx • Open a command prompt
Next steps • Get-Help • Can use tabbing to finish commands • Commands like ls, pwd, dir etc… work • Files are saved as a .PS1 • Not only for Windows, (VMware, Quest, F5, Full Armor etc..)
VMware VI Toolkit • New version release January 28, 2009 • Quick Reference Guide • VMware forum • VMware Europe Lab • http://www.vmwarescripting.com/ • http://www.peetersonline.nl/ • http://www.ntpro.nl/blog/categories/10-VMware-PowerShell
The Problem • Need to get data from a number of servers • Data is not in a script that I could find • Field is not somewhere I would normally look
Finding Data • Get-VM vm_name | get-view | format-custom >c:\out.txt • Summary = • class VirtualMachineSummary • { • Vm = • class ManagedObjectReference • { • Type = VirtualMachine • Value = vm-149535 • }
Step 1 Connect • #Set variables • $vcserver = “insert VC Server Name“ • #Connect to VC • $VC = Connect-VIServer $VCServer
Loop the command • #Tell it to loop through the names • foreach ($object in $vmname){ • #Provide the command to increase the RAM • $vm = Get-VM $object • ($vm | Get-View).summary.vm.value + " " + $vm.name • }
Additional Resources • VMware Administrator’s guide for VI Toolkit 1.5 • Undocumented Features • Real Time Publishers • VI-Toolkit.com • PowerScripting Podcast • Power of Shell