Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does PowerShell CLI get VM Information

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

PowerShell CLI how to obtain VM information, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Recently, I have taken over some ESXi 5.0s with many virtual machines, but many of the SCSI drivers of these virtual machines are still using older versions such as LSIBasci,LSISAS and so on. I want to update them all to the ParaVirtual driver, the update method is very simple, manually add a hard disk and SCSI drive, select ParaVirtual, and so on after the operating system recognizes the hard disk, it means that the driver has been automatically installed, then delete the new hard disk and change the drive type of the boot disk.

But first I have to get all the SCSI and operating system types of VM to facilitate the next step.

It's easy to connect to VCenter, download the corresponding PowerCli, and then add Snappin. If you are too lazy to execute each time, you can configure ISE to load automatically every time you start it in powershell profile.

Add-PSSnapin VMware.VimAutomation.Core

Then connect to VCenter, and you can see the type. There is nothing to say about the statement itself. I use a tee to hold the variables so that I can see the results on the screen at the same time. Finally, the results are derived.

Connect-viserver sydvcs2012get-VM | select version,Name, powerstate, numcpu, Memorygb, @ {N = "IPAddress"; 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

It is worth mentioning that there was a slight problem with get-vm at the beginning, because I also installed the module of hyper-v, and hyper-v also had the command get-vm. Sometimes powershell is confused about which module I need instructions for.

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

After reading the above, have you mastered how PowerShell CLI can get VM information? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report