PowerShell CLI gets VM information

Source: Internet
Author: User

Beans recently took over some ESXi 5.0, which has many virtual machines, but the SCSI drivers for these VMs are still using older versions such as Lsibasci,lsisas and so on. I want to update them to paravirtual driver, the Update method is very simple, manually add a hard disk and SCSI drive, select Paravirtual, and so on, the operating system recognized the hard drive will indicate that the driver has been automatically installed, Then delete this new hard drive and modify the drive type on the boot disk.


But first I have to get the SCSI and operating system type of all the VMS to facilitate the next steps.


Connecting vcenter is easy, download the corresponding powercli, and add Snappin on the line. If you do not bother to do it every time, you can configure it to automatically load every time you start the Ise in PowerShell profile.

Add-pssnapin VMware.VimAutomation.Core


You can then connect to vcenter to see the type. The statement itself has nothing to say, I used a tee to save the variable so that I can see the results on the screen at the same time. Finally, the results are exported.

Connect-viserver SYDVCS2012GET-VM | Select Version,name, PowerState, Numcpu, MEMORYGB, @{n= "IP address"; e={@ ($_.guest. Ipaddress[0])}},@{n= "OS"; E={$_.guest.osfullname}, @{n= "SCSI"; e={(Get-scsicontroller $_.name). Type} | Tee-variable Result$result | Sort SCSI | Export-csv C:\temp\mel.csv-NoTypeInformationDisconnect-VIServer


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7C/D3/wKiom1bY1knRRZtOAAD4EnyHjfU539.png "title=" 3.PNG " alt= "Wkiom1by1knrrztoaad4enyhjfu539.png"/>



It is worth mentioning that GET-VM at the beginning of a few problems, because I also installed the Hyper-V module, Hyper-V also has GET-VM this command. Sometimes PowerShell is confused about which module I need to command.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7C/D2/wKioL1bY1laQ_p_XAAAXV2S_PI8584.png "style=" float: none; "title=" 1.PNG "alt=" Wkiol1by1laq_p_xaaaxv2s_pi8584.png "/>


If you need to prefix the module name to avoid confusion, there will be no conflict.


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7C/D3/wKiom1bY1d2RoGNXAABLUdTLKKA899.png "style=" float: none; "title=" 2.PNG "alt=" Wkiom1by1d2rognxaabludtlkka899.png "/>


This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1747412

PowerShell CLI gets VM information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.